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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bazalt-0.2.0-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: bazalt-0.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
060c157b60bb1466f453b3f45ed86842777914ac09bf31c6a8226edf326c366d
|
|
| MD5 |
23bf056714080a3dab51c692a6c6c7ba
|
|
| BLAKE2b-256 |
f43d62ce8bdec7e2a81f1a0b581a8eaeb9b287a0c0977f97f8b09e6aac6e914f
|
Provenance
The following attestation bundles were made for bazalt-0.2.0-cp313-cp313-win_amd64.whl:
Publisher:
build.yml on SzamockiP/bazalt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bazalt-0.2.0-cp313-cp313-win_amd64.whl -
Subject digest:
060c157b60bb1466f453b3f45ed86842777914ac09bf31c6a8226edf326c366d - Sigstore transparency entry: 2165214378
- Sigstore integration time:
-
Permalink:
SzamockiP/bazalt@86150eee0023172582105b7ac9bbd70a4e9e0f5d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/SzamockiP
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@86150eee0023172582105b7ac9bbd70a4e9e0f5d -
Trigger Event:
release
-
Statement type:
File details
Details for the file bazalt-0.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: bazalt-0.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 4.1 MB
- Tags: CPython 3.13, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cea1e7443f3327eb9d54148065e23d1df9c6bf2d87265fd772bb46ca22bffc7
|
|
| MD5 |
6c6fb429c91f0518440eaa115e992186
|
|
| BLAKE2b-256 |
0c46622d6a902b99f78358f4022d505a0f62d41b6f7d66b9510512876e380a54
|
Provenance
The following attestation bundles were made for bazalt-0.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
build.yml on SzamockiP/bazalt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bazalt-0.2.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
1cea1e7443f3327eb9d54148065e23d1df9c6bf2d87265fd772bb46ca22bffc7 - Sigstore transparency entry: 2165214548
- Sigstore integration time:
-
Permalink:
SzamockiP/bazalt@86150eee0023172582105b7ac9bbd70a4e9e0f5d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/SzamockiP
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@86150eee0023172582105b7ac9bbd70a4e9e0f5d -
Trigger Event:
release
-
Statement type:
File details
Details for the file bazalt-0.2.0-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: bazalt-0.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2230089be315e67a775e6c9b2cdd164a4f41c2ba2802c0e625228e29916eb536
|
|
| MD5 |
45d5949f25f5b0033d4cc3bd82dcc0dd
|
|
| BLAKE2b-256 |
1e733615d537498211dba86bd43587cdd33697c46c966a32267d52c673512389
|
Provenance
The following attestation bundles were made for bazalt-0.2.0-cp312-cp312-win_amd64.whl:
Publisher:
build.yml on SzamockiP/bazalt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bazalt-0.2.0-cp312-cp312-win_amd64.whl -
Subject digest:
2230089be315e67a775e6c9b2cdd164a4f41c2ba2802c0e625228e29916eb536 - Sigstore transparency entry: 2165214329
- Sigstore integration time:
-
Permalink:
SzamockiP/bazalt@86150eee0023172582105b7ac9bbd70a4e9e0f5d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/SzamockiP
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@86150eee0023172582105b7ac9bbd70a4e9e0f5d -
Trigger Event:
release
-
Statement type:
File details
Details for the file bazalt-0.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: bazalt-0.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 4.1 MB
- Tags: CPython 3.12, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
501f5649d0928b9ee1acbd8b1899c95d6d7a3c9e32e0743fdcd0f7cb948f3e1f
|
|
| MD5 |
379298a9aef8372e5a6699175d8ea07b
|
|
| BLAKE2b-256 |
663913f4d60ff6d6071a89dd20bd9564eab9f9c32b58004d45a4ed245719d485
|
Provenance
The following attestation bundles were made for bazalt-0.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
build.yml on SzamockiP/bazalt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bazalt-0.2.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
501f5649d0928b9ee1acbd8b1899c95d6d7a3c9e32e0743fdcd0f7cb948f3e1f - Sigstore transparency entry: 2165214508
- Sigstore integration time:
-
Permalink:
SzamockiP/bazalt@86150eee0023172582105b7ac9bbd70a4e9e0f5d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/SzamockiP
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@86150eee0023172582105b7ac9bbd70a4e9e0f5d -
Trigger Event:
release
-
Statement type:
File details
Details for the file bazalt-0.2.0-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: bazalt-0.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e228a21afe2ce715b4702282c827c8e28a5b720590ebfe348dd9c90fc4cd04c
|
|
| MD5 |
b3eafdcbdb1466f5a814d396f6e63d5c
|
|
| BLAKE2b-256 |
6e0b5b50bfb9202e34c2d7f4e4482cd7e006472d993e5b21337e7b5361617c36
|
Provenance
The following attestation bundles were made for bazalt-0.2.0-cp311-cp311-win_amd64.whl:
Publisher:
build.yml on SzamockiP/bazalt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bazalt-0.2.0-cp311-cp311-win_amd64.whl -
Subject digest:
6e228a21afe2ce715b4702282c827c8e28a5b720590ebfe348dd9c90fc4cd04c - Sigstore transparency entry: 2165214420
- Sigstore integration time:
-
Permalink:
SzamockiP/bazalt@86150eee0023172582105b7ac9bbd70a4e9e0f5d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/SzamockiP
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@86150eee0023172582105b7ac9bbd70a4e9e0f5d -
Trigger Event:
release
-
Statement type:
File details
Details for the file bazalt-0.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: bazalt-0.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 4.1 MB
- Tags: CPython 3.11, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fd3571dbca26c6fdb7fd8e09507cf515b1966692e0ce03af444550f5b24f572
|
|
| MD5 |
adba4a30033805abd2d5b079a917c3b2
|
|
| BLAKE2b-256 |
5d716917ff285630117042346c73536f32594584a0a24ac92d2fe10da138cf5e
|
Provenance
The following attestation bundles were made for bazalt-0.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
build.yml on SzamockiP/bazalt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bazalt-0.2.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
9fd3571dbca26c6fdb7fd8e09507cf515b1966692e0ce03af444550f5b24f572 - Sigstore transparency entry: 2165214597
- Sigstore integration time:
-
Permalink:
SzamockiP/bazalt@86150eee0023172582105b7ac9bbd70a4e9e0f5d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/SzamockiP
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@86150eee0023172582105b7ac9bbd70a4e9e0f5d -
Trigger Event:
release
-
Statement type:
File details
Details for the file bazalt-0.2.0-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: bazalt-0.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae3cbc006efc3b0358b387919b1ecf3585e24caaa512f80121997f0e44469e51
|
|
| MD5 |
9b90390ff3fd52b1b6b5f5d2197bea8c
|
|
| BLAKE2b-256 |
5c3ae8d5e8c151435c3c4c08333fba5c75e42a8bf597843844feb20cbaf295cf
|
Provenance
The following attestation bundles were made for bazalt-0.2.0-cp310-cp310-win_amd64.whl:
Publisher:
build.yml on SzamockiP/bazalt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bazalt-0.2.0-cp310-cp310-win_amd64.whl -
Subject digest:
ae3cbc006efc3b0358b387919b1ecf3585e24caaa512f80121997f0e44469e51 - Sigstore transparency entry: 2165214465
- Sigstore integration time:
-
Permalink:
SzamockiP/bazalt@86150eee0023172582105b7ac9bbd70a4e9e0f5d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/SzamockiP
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@86150eee0023172582105b7ac9bbd70a4e9e0f5d -
Trigger Event:
release
-
Statement type:
File details
Details for the file bazalt-0.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.
File metadata
- Download URL: bazalt-0.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
- Upload date:
- Size: 4.1 MB
- Tags: CPython 3.10, manylinux: glibc 2.27+ x86-64, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c846de23f0b6620c1d6f3ef76f9ced29f493b9f95f36fe04fb865721d8682f94
|
|
| MD5 |
acd745cdaa6993c5636a77ddca0ae12c
|
|
| BLAKE2b-256 |
303725329e854e8a37f27ecc7ff9b3a7c519042156925330a4a3cea4e88b65ad
|
Provenance
The following attestation bundles were made for bazalt-0.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:
Publisher:
build.yml on SzamockiP/bazalt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bazalt-0.2.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl -
Subject digest:
c846de23f0b6620c1d6f3ef76f9ced29f493b9f95f36fe04fb865721d8682f94 - Sigstore transparency entry: 2165214645
- Sigstore integration time:
-
Permalink:
SzamockiP/bazalt@86150eee0023172582105b7ac9bbd70a4e9e0f5d -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/SzamockiP
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@86150eee0023172582105b7ac9bbd70a4e9e0f5d -
Trigger Event:
release
-
Statement type: