gpu: implement Limits and conversion

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2022-03-07 23:08:54 -07:00 committed by Stephen Gutekanst
parent 39ab0105a9
commit 4d97c52353
3 changed files with 60 additions and 39 deletions

View file

@ -1,37 +1,27 @@
// TODO: docs // TODO: docs
max_texture_dimension_1d: u32,
// TODO: max_texture_dimension_2d: u32,
// typedef struct WGPUSupportedLimits { max_texture_dimension_3d: u32,
// WGPUChainedStructOut * nextInChain; max_texture_array_layers: u32,
// WGPULimits limits; max_bind_groups: u32,
// } WGPUSupportedLimits; max_dynamic_uniform_buffers_per_pipeline_layout: u32,
max_dynamic_storage_buffers_per_pipeline_layout: u32,
// TODO: max_sampled_textures_per_shader_stage: u32,
// typedef struct WGPULimits { max_samplers_per_shader_stage: u32,
// uint32_t maxTextureDimension1D; max_storage_buffers_per_shader_stage: u32,
// uint32_t maxTextureDimension2D; max_storage_textures_per_shader_stage: u32,
// uint32_t maxTextureDimension3D; max_uniform_buffers_per_shader_stage: u32,
// uint32_t maxTextureArrayLayers; max_uniform_buffer_binding_size: u64,
// uint32_t maxBindGroups; max_storage_buffer_binding_size: u64,
// uint32_t maxDynamicUniformBuffersPerPipelineLayout; min_uniform_buffer_offset_alignment: u32,
// uint32_t maxDynamicStorageBuffersPerPipelineLayout; min_storage_buffer_offset_alignment: u32,
// uint32_t maxSampledTexturesPerShaderStage; max_vertex_buffers: u32,
// uint32_t maxSamplersPerShaderStage; max_vertex_attributes: u32,
// uint32_t maxStorageBuffersPerShaderStage; max_vertex_buffer_array_stride: u32,
// uint32_t maxStorageTexturesPerShaderStage; max_inter_stage_shader_components: u32,
// uint32_t maxUniformBuffersPerShaderStage; max_compute_workgroup_storage_size: u32,
// uint64_t maxUniformBufferBindingSize; max_compute_invocations_per_workgroup: u32,
// uint64_t maxStorageBufferBindingSize; max_compute_workgroup_size_x: u32,
// uint32_t minUniformBufferOffsetAlignment; max_compute_workgroup_size_y: u32,
// uint32_t minStorageBufferOffsetAlignment; max_compute_workgroup_size_z: u32,
// uint32_t maxVertexBuffers; max_compute_workgroups_per_dimension: u32,
// uint32_t maxVertexAttributes;
// uint32_t maxVertexBufferArrayStride;
// uint32_t maxInterStageShaderComponents;
// uint32_t maxComputeWorkgroupStorageSize;
// uint32_t maxComputeInvocationsPerWorkgroup;
// uint32_t maxComputeWorkgroupSizeX;
// uint32_t maxComputeWorkgroupSizeY;
// uint32_t maxComputeWorkgroupSizeZ;
// uint32_t maxComputeWorkgroupsPerDimension;
// } WGPULimits;

View file

@ -300,10 +300,36 @@ const device_vtable = Device.VTable{
}).release, }).release,
}; };
// TODO: maybe make Limits an extern struct that can be cast?
fn convertLimits(l: Limits) c.WGPULimits { fn convertLimits(l: Limits) c.WGPULimits {
// TODO: implement! return .{
_ = l; .maxTextureDimension1D = l.max_texture_dimension_1d,
return std.mem.zeroes(c.WGPULimits); .maxTextureDimension2D = l.max_texture_dimension_2d,
.maxTextureDimension3D = l.max_texture_dimension_3d,
.maxTextureArrayLayers = l.max_texture_array_layers,
.maxBindGroups = l.max_bind_groups,
.maxDynamicUniformBuffersPerPipelineLayout = l.max_dynamic_uniform_buffers_per_pipeline_layout,
.maxDynamicStorageBuffersPerPipelineLayout = l.max_dynamic_storage_buffers_per_pipeline_layout,
.maxSampledTexturesPerShaderStage = l.max_sampled_textures_per_shader_stage,
.maxSamplersPerShaderStage = l.max_samplers_per_shader_stage,
.maxStorageBuffersPerShaderStage = l.max_storage_buffers_per_shader_stage,
.maxStorageTexturesPerShaderStage = l.max_storage_textures_per_shader_stage,
.maxUniformBuffersPerShaderStage = l.max_uniform_buffers_per_shader_stage,
.maxUniformBufferBindingSize = l.max_uniform_buffer_binding_size,
.maxStorageBufferBindingSize = l.max_storage_buffer_binding_size,
.minUniformBufferOffsetAlignment = l.min_uniform_buffer_offset_alignment,
.minStorageBufferOffsetAlignment = l.min_storage_buffer_offset_alignment,
.maxVertexBuffers = l.max_vertex_buffers,
.maxVertexAttributes = l.max_vertex_attributes,
.maxVertexBufferArrayStride = l.max_vertex_buffer_array_stride,
.maxInterStageShaderComponents = l.max_inter_stage_shader_components,
.maxComputeWorkgroupStorageSize = l.max_compute_workgroup_storage_size,
.maxComputeInvocationsPerWorkgroup = l.max_compute_invocations_per_workgroup,
.maxComputeWorkgroupSizeX = l.max_compute_workgroup_size_x,
.maxComputeWorkgroupSizeY = l.max_compute_workgroup_size_y,
.maxComputeWorkgroupSizeZ = l.max_compute_workgroup_size_z,
.maxComputeWorkgroupsPerDimension = l.max_compute_workgroups_per_dimension,
};
} }
test "syntax" { test "syntax" {

View file

@ -994,6 +994,11 @@ typedef struct WGPUComputePipelineDescriptor {
WGPUProgrammableStageDescriptor compute; WGPUProgrammableStageDescriptor compute;
} WGPUComputePipelineDescriptor; } WGPUComputePipelineDescriptor;
typedef struct WGPUSupportedLimits {
WGPUChainedStructOut * nextInChain;
WGPULimits limits;
} WGPUSupportedLimits;
typedef struct WGPUDeviceProperties { typedef struct WGPUDeviceProperties {
uint32_t deviceID; uint32_t deviceID;
uint32_t vendorID; uint32_t vendorID;