Skip to main content

Python library for rapid GPU shader prototyping using Vulkan

Project description

Bazalt

Bazalt is a modern Python library for rapid prototyping and building graphical applications using the Vulkan API. It provides a clean, intuitive interface over a high-performance C++ core, allowing developers to create rendering applications quickly without the typical boilerplate.

Installation

You can install bazalt easily via pip:

pip install bazalt

Key Features

  • Modern Graphics API: Built on top of Vulkan for optimal hardware utilization.
  • Easy to Use Interface: Write clear and concise code with an intuitive API.
  • Automatic Shader Compilation: Compile GLSL shaders (Vertex/Fragment) directly from your code.
  • Pipeline & Buffer Management: Easy builder pattern for graphics pipelines and unified buffer creation.
  • Command Buffers: Explicit, yet simple command recording for drawing operations.
  • Event-Driven Architecture: Register callbacks easily using decorators (e.g., @engine.onFrame, @engine.onError).

Quick Start: Drawing a Triangle

Here is a minimal example demonstrating how to initialize the engine, compile shaders, create a pipeline, and draw a colorful triangle.

import bazalt as bz
import time

engine = bz.Engine()

# Optional: Register an error callback
@engine.onError
def error(msg):
    print(f"Error: {msg}")

# Register a per-frame callback
@engine.onFrame
def on_update():
    # Submit our pre-recorded command buffer to the GPU each frame
    engine.submit(cmd)

if __name__ == "__main__":
    engine.init(1024, 720, "Bazalt Demo - Triangle")

    # Load and compile shaders. The vertex shader processes our geometry,
    # and the fragment shader determines the final color of the pixels.
    vert_spv = engine.compileShader("triangle.vert", bz.ShaderStage.VERTEX)
    frag_spv = engine.compileShader("triangle.frag", bz.ShaderStage.FRAGMENT)

    # The pipeline is a baked state object that tells the GPU how to interpret our data.
    # vertexFormat specifies that each vertex consists of 6 floats:
    # 3 for Position (layout location=0) and 3 for Color (layout location=1).
    pipeline = (engine.createPipeline()
        .vertexShader(vert_spv)
        .fragmentShader(frag_spv)
        .vertexFormat([bz.Format.FLOAT3, bz.Format.FLOAT3]) # Position + Color
        .build())

    # We interleave Position (x,y,z) and Color (r,g,b) in a single flat array.
    # Vulkan's Normalized Device Coordinates (NDC) range from -1 to 1,
    # where Y points downwards and X points to the right.
    vertices = [
         0.0, -0.5, 0.0,   1.0, 0.0, 0.0, # Top / Red
        -0.5,  0.5, 0.0,   0.0, 1.0, 0.0, # Bottom-Left / Green
         0.5,  0.5, 0.0,   0.0, 0.0, 1.0, # Bottom-Right / Blue
    ]
    
    # Create Vertex Buffer
    vbuf = engine.createBuffer(vertices, bz.BufferType.VERTEX, bz.DataType.FLOAT)
    
    # Create Index Buffer
    indices = [0, 1, 2]
    ibuf = engine.createBuffer(indices, bz.BufferType.INDEX, bz.DataType.UINT32)

    # Command buffers store a sequence of commands for the GPU.
    # For a static triangle, we can record this buffer once during initialization 
    # and submit the same pre-recorded buffer every frame to save CPU time.
    cmd = engine.createCommandBuffer()
    
    cmd.begin()
    
    # beginRendering starts a render pass, automatically handling framebuffers
    # and clearing the screen to the specified color before drawing.
    cmd.beginRendering(clear_color=[0.1, 0.2, 0.3, 1.0])
    cmd.setViewport()
    cmd.setScissor()
    
    # Bind the baked pipeline and the geometry buffers
    cmd.bindPipeline(pipeline)
    cmd.bindVertexBuffer(vbuf)
    cmd.bindIndexBuffer(ibuf)
    
    # Draw 3 indices (1 triangle)
    cmd.drawIndexed(3)
    cmd.endRendering()

    engine.run()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

bazalt-0.1.0-cp313-cp313-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.13Windows x86-64

bazalt-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

bazalt-0.1.0-cp312-cp312-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.12Windows x86-64

bazalt-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

bazalt-0.1.0-cp311-cp311-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.11Windows x86-64

bazalt-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

bazalt-0.1.0-cp310-cp310-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.10Windows x86-64

bazalt-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (4.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file bazalt-0.1.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: bazalt-0.1.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bazalt-0.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 dd85fdbd3cbba2b3c119f722dd495813bbe1d4eea8e7e8be97570654684e286b
MD5 43485da3387d0e4779a44e40768adc4b
BLAKE2b-256 9c94b9311460acb4db3fa35adde00ff72130d56b63f48cde810254608dca7ef4

See more details on using hashes here.

Provenance

The following attestation bundles were made for bazalt-0.1.0-cp313-cp313-win_amd64.whl:

Publisher: build.yml on SzamockiP/bazalt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bazalt-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for bazalt-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 347a8ffda44e987cc5336e56140db00d5223c9512a6ec121c01f9c68df3b78fc
MD5 1f5499bdbe02ff96b58ebf00ac367df0
BLAKE2b-256 171570c080f872fbf4f2bca05e8489bc3499f1fa8b0009c3cdc7060cbcafe746

See more details on using hashes here.

Provenance

The following attestation bundles were made for bazalt-0.1.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build.yml on SzamockiP/bazalt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bazalt-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: bazalt-0.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bazalt-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 80e22c3481c55f0716f5dad2cd79a56bcaee4d5db86a6a19a978097702277dd7
MD5 77557b73566ce061c6f625840804590c
BLAKE2b-256 f973186714d3f3b68679cedb901507dfa2954d4caafd751258eb9aa7a583f605

See more details on using hashes here.

Provenance

The following attestation bundles were made for bazalt-0.1.0-cp312-cp312-win_amd64.whl:

Publisher: build.yml on SzamockiP/bazalt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bazalt-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for bazalt-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 83830a49115b23e2fe8e6283b0876f813c317698a56e889c19f7bbe06ba0627b
MD5 e8dc819bba690b96044a5f93be343f02
BLAKE2b-256 262130303d762aa8ecb1f3f807e536acd4c95b2b765778cdbce738b5781013fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for bazalt-0.1.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build.yml on SzamockiP/bazalt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bazalt-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: bazalt-0.1.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bazalt-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 29eb2f47655210b03059aa6bce79ac937768b654c9394df847a611b1f3209b71
MD5 5f90a1e09cc57f81b739cbf0c7084388
BLAKE2b-256 6991a353fec9d23de2cc1b89cb4f4db66fc9ad86ffdb6f4534aa6611a6688e96

See more details on using hashes here.

Provenance

The following attestation bundles were made for bazalt-0.1.0-cp311-cp311-win_amd64.whl:

Publisher: build.yml on SzamockiP/bazalt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bazalt-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for bazalt-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 66a596c97bd8159e22d01152528a67c03503b20424a1fbb76410269593a0d6e0
MD5 a04ab47387aa2fee08d09e2f7390fe5a
BLAKE2b-256 3c3ba43dc72676f9fe8128343aa2da5a98e330882c3a363e18ffab492ad74b57

See more details on using hashes here.

Provenance

The following attestation bundles were made for bazalt-0.1.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build.yml on SzamockiP/bazalt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bazalt-0.1.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: bazalt-0.1.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 2.3 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bazalt-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f6fe76d47740abd4745e2f6f06c1fb910b81c5b0ae45831fcb475211f91f552a
MD5 c502f8526f9e43d41e5495b6092eea23
BLAKE2b-256 362e1908ead9066f009ecf1f3108249e38af7e25687b5f192d3e56867e8a57c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for bazalt-0.1.0-cp310-cp310-win_amd64.whl:

Publisher: build.yml on SzamockiP/bazalt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bazalt-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for bazalt-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 278db95f951f7b0d12c0599a9dfeb0df8f29ad20a788ed60991cde2fb5ef1082
MD5 2c48b01d3f71484ce510c9ac18d71dd8
BLAKE2b-256 72e34e1282b63f9375416ec3162dd55a31dd66bed2f53406d20adf9d3b8a7ccf

See more details on using hashes here.

Provenance

The following attestation bundles were made for bazalt-0.1.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build.yml on SzamockiP/bazalt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page