-
Notifications
You must be signed in to change notification settings - Fork 37
Graphics api overview
Tempest::VulkanApi - represents Vulkan 1.0
Tempest::DirectX12Api - represents Directx12
Tempest::Device - represents a graphics device
// create any vulkan device, with validation layer on top
Tempest::VulkanApi api{ApiFlags::Validation};
Tempest::Device device(api);// list all directx devices
Tempest::DirectX12Api api;
for(auto& dev:api.devices())
Log:i(dev.name);Tempest::VertexBuffer<T> - vertex buffer of type T. T must have defined vertex declaration
struct Vertex {
float x,y;
};
namespace Tempest {
template<>
inline VertexBufferDecl vertexBufferDecl<Vertex>() { // vertex declaration: one vec2 value
return {Decl::float2};
}
}
Tempest::VertexBuffer<Vertex> vbo = ...Tempest::IndexBuffer<T> - index buffer of type T; T can be uint16_t or uint32_t. Immutable.
Tempest::StorageBuffer<T> - storage buffer of type T. Used in compute shader. Can be updated from CPU and GPU.
Tempest::UniformBuffer<T> - aligned uniform buffer of type T. Can be updated from CPU side.
Matrix4x4 data1[8];
Tempest::UniformBuffer<Tempest::Matrix4x4> ubo = device.ubo<Matrix4x4>(data1,8); // allocated buffer with 8 elements
// each element in ubo will have automatic padding, based on backend-api:
// in DirectX, for example: padding = 192 bytes, min alignment = 256, sizeof(Matrix4x4)=64,
...
Matrix4x4 data2[8];
ubo.update(data2,0,8); // update all elementsTempest::Uniforms - set of uniform variables to be passed into shader pipeline.
Tempest::RenderPipeline - rendering pipeline. Represents shaders, input assembly and render-state baked together in one object.
Tempest::ComputePipeline - represents pipeline for a compute shader.
Tempest::CommandBuffer - list of commands to be submitted to gpu.
Tempest::FrameBuffer - set of output images and zbuffer.
Tempest::RenderPass - hint for framebuffer management.
auto tex = device.attachment(TextureFormat::RGBA8,128,128);
auto fbo = device.frameBuffer(tex);
auto rp = device.pass(FboMode(FboMode::PreserveOut,Color(0.f,0.f,1.f))); // clear to blue color at start, preserve output
auto cmd = device.commandBuffer();
{
auto enc = cmd.startEncoding(device); // start recording commands
enc.setFramebuffer(fbo,rp);
...
} // command buffer is ready to use