mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 00:03:29 +00:00
Renamed the impl methods, switched structure argumetns from references to contained items
This commit is contained in:
parent
2e21285434
commit
00e0347b8c
@ -40,14 +40,14 @@ fn main() {
|
||||
cull_mode: wgpu::CullMode::None,
|
||||
depth_bias: 0,
|
||||
depth_bias_slope_scale: 0.0,
|
||||
depth_bias_clamp: 16.0,
|
||||
depth_bias_clamp: wgpu::MAX_DEPTH_BIAS_CLAMP,
|
||||
},
|
||||
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
|
||||
color_states: &[
|
||||
wgpu::ColorStateDescriptor {
|
||||
format: wgpu::TextureFormat::B8g8r8a8Unorm,
|
||||
color: &wgpu::BlendDescriptor::REPLACE,
|
||||
alpha: &wgpu::BlendDescriptor::REPLACE,
|
||||
color: wgpu::BlendDescriptor::REPLACE,
|
||||
alpha: wgpu::BlendDescriptor::REPLACE,
|
||||
write_mask: wgpu::ColorWriteFlags::ALL,
|
||||
},
|
||||
],
|
||||
|
@ -252,14 +252,14 @@ impl framework::Example for Cube {
|
||||
cull_mode: wgpu::CullMode::Back,
|
||||
depth_bias: 0,
|
||||
depth_bias_slope_scale: 0.0,
|
||||
depth_bias_clamp: 16.0,
|
||||
depth_bias_clamp: wgpu::MAX_DEPTH_BIAS_CLAMP,
|
||||
},
|
||||
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
|
||||
color_states: &[
|
||||
wgpu::ColorStateDescriptor {
|
||||
format: sc_desc.format,
|
||||
color: &wgpu::BlendDescriptor::REPLACE,
|
||||
alpha: &wgpu::BlendDescriptor::REPLACE,
|
||||
color: wgpu::BlendDescriptor::REPLACE,
|
||||
alpha: wgpu::BlendDescriptor::REPLACE,
|
||||
write_mask: wgpu::ColorWriteFlags::ALL,
|
||||
},
|
||||
],
|
||||
|
@ -36,6 +36,7 @@ fn main() {
|
||||
.with_crate(source_dir)
|
||||
.with_config(config)
|
||||
.with_parse_expand(&["wgpu-native"])
|
||||
.with_parse_expand_features(&["local"])
|
||||
.generate()
|
||||
.unwrap()
|
||||
.write_to_file(crate_dir.join("wgpu.h"));
|
||||
|
@ -11,6 +11,164 @@
|
||||
|
||||
#define WGPUBITS_PER_BYTE 8
|
||||
|
||||
#define WGPUMAX_DEPTH_BIAS_CLAMP 16
|
||||
|
||||
typedef enum {
|
||||
WGPUAddressMode_ClampToEdge = 0,
|
||||
WGPUAddressMode_Repeat = 1,
|
||||
WGPUAddressMode_MirrorRepeat = 2,
|
||||
WGPUAddressMode_ClampToBorderColor = 3,
|
||||
} WGPUAddressMode;
|
||||
|
||||
typedef enum {
|
||||
WGPUBindingType_UniformBuffer = 0,
|
||||
WGPUBindingType_Sampler = 1,
|
||||
WGPUBindingType_SampledTexture = 2,
|
||||
WGPUBindingType_StorageBuffer = 3,
|
||||
} WGPUBindingType;
|
||||
|
||||
typedef enum {
|
||||
WGPUBlendFactor_Zero = 0,
|
||||
WGPUBlendFactor_One = 1,
|
||||
WGPUBlendFactor_SrcColor = 2,
|
||||
WGPUBlendFactor_OneMinusSrcColor = 3,
|
||||
WGPUBlendFactor_SrcAlpha = 4,
|
||||
WGPUBlendFactor_OneMinusSrcAlpha = 5,
|
||||
WGPUBlendFactor_DstColor = 6,
|
||||
WGPUBlendFactor_OneMinusDstColor = 7,
|
||||
WGPUBlendFactor_DstAlpha = 8,
|
||||
WGPUBlendFactor_OneMinusDstAlpha = 9,
|
||||
WGPUBlendFactor_SrcAlphaSaturated = 10,
|
||||
WGPUBlendFactor_BlendColor = 11,
|
||||
WGPUBlendFactor_OneMinusBlendColor = 12,
|
||||
} WGPUBlendFactor;
|
||||
|
||||
typedef enum {
|
||||
WGPUBlendOperation_Add = 0,
|
||||
WGPUBlendOperation_Subtract = 1,
|
||||
WGPUBlendOperation_ReverseSubtract = 2,
|
||||
WGPUBlendOperation_Min = 3,
|
||||
WGPUBlendOperation_Max = 4,
|
||||
} WGPUBlendOperation;
|
||||
|
||||
typedef enum {
|
||||
WGPUBorderColor_TransparentBlack = 0,
|
||||
WGPUBorderColor_OpaqueBlack = 1,
|
||||
WGPUBorderColor_OpaqueWhite = 2,
|
||||
} WGPUBorderColor;
|
||||
|
||||
typedef enum {
|
||||
WGPUCompareFunction_Never = 0,
|
||||
WGPUCompareFunction_Less = 1,
|
||||
WGPUCompareFunction_Equal = 2,
|
||||
WGPUCompareFunction_LessEqual = 3,
|
||||
WGPUCompareFunction_Greater = 4,
|
||||
WGPUCompareFunction_NotEqual = 5,
|
||||
WGPUCompareFunction_GreaterEqual = 6,
|
||||
WGPUCompareFunction_Always = 7,
|
||||
} WGPUCompareFunction;
|
||||
|
||||
typedef enum {
|
||||
WGPUCullMode_None = 0,
|
||||
WGPUCullMode_Front = 1,
|
||||
WGPUCullMode_Back = 2,
|
||||
} WGPUCullMode;
|
||||
|
||||
typedef enum {
|
||||
WGPUFilterMode_Nearest = 0,
|
||||
WGPUFilterMode_Linear = 1,
|
||||
} WGPUFilterMode;
|
||||
|
||||
typedef enum {
|
||||
WGPUFrontFace_Ccw = 0,
|
||||
WGPUFrontFace_Cw = 1,
|
||||
} WGPUFrontFace;
|
||||
|
||||
typedef enum {
|
||||
WGPUIndexFormat_Uint16 = 0,
|
||||
WGPUIndexFormat_Uint32 = 1,
|
||||
} WGPUIndexFormat;
|
||||
|
||||
typedef enum {
|
||||
WGPUInputStepMode_Vertex = 0,
|
||||
WGPUInputStepMode_Instance = 1,
|
||||
} WGPUInputStepMode;
|
||||
|
||||
typedef enum {
|
||||
WGPULoadOp_Clear = 0,
|
||||
WGPULoadOp_Load = 1,
|
||||
} WGPULoadOp;
|
||||
|
||||
typedef enum {
|
||||
WGPUPowerPreference_Default = 0,
|
||||
WGPUPowerPreference_LowPower = 1,
|
||||
WGPUPowerPreference_HighPerformance = 2,
|
||||
} WGPUPowerPreference;
|
||||
|
||||
typedef enum {
|
||||
WGPUPrimitiveTopology_PointList = 0,
|
||||
WGPUPrimitiveTopology_LineList = 1,
|
||||
WGPUPrimitiveTopology_LineStrip = 2,
|
||||
WGPUPrimitiveTopology_TriangleList = 3,
|
||||
WGPUPrimitiveTopology_TriangleStrip = 4,
|
||||
} WGPUPrimitiveTopology;
|
||||
|
||||
typedef enum {
|
||||
WGPUStencilOperation_Keep = 0,
|
||||
WGPUStencilOperation_Zero = 1,
|
||||
WGPUStencilOperation_Replace = 2,
|
||||
WGPUStencilOperation_Invert = 3,
|
||||
WGPUStencilOperation_IncrementClamp = 4,
|
||||
WGPUStencilOperation_DecrementClamp = 5,
|
||||
WGPUStencilOperation_IncrementWrap = 6,
|
||||
WGPUStencilOperation_DecrementWrap = 7,
|
||||
} WGPUStencilOperation;
|
||||
|
||||
typedef enum {
|
||||
WGPUStoreOp_Store = 0,
|
||||
} WGPUStoreOp;
|
||||
|
||||
typedef enum {
|
||||
WGPUTextureDimension_D1,
|
||||
WGPUTextureDimension_D2,
|
||||
WGPUTextureDimension_D3,
|
||||
} WGPUTextureDimension;
|
||||
|
||||
typedef enum {
|
||||
WGPUTextureFormat_R8g8b8a8Unorm = 0,
|
||||
WGPUTextureFormat_R8g8b8a8Uint = 1,
|
||||
WGPUTextureFormat_B8g8r8a8Unorm = 2,
|
||||
WGPUTextureFormat_D32FloatS8Uint = 3,
|
||||
} WGPUTextureFormat;
|
||||
|
||||
typedef enum {
|
||||
WGPUTextureViewDimension_D1,
|
||||
WGPUTextureViewDimension_D2,
|
||||
WGPUTextureViewDimension_D2Array,
|
||||
WGPUTextureViewDimension_Cube,
|
||||
WGPUTextureViewDimension_CubeArray,
|
||||
WGPUTextureViewDimension_D3,
|
||||
} WGPUTextureViewDimension;
|
||||
|
||||
typedef enum {
|
||||
WGPUVertexFormat_FloatR32G32B32A32 = 0,
|
||||
WGPUVertexFormat_FloatR32G32B32 = 1,
|
||||
WGPUVertexFormat_FloatR32G32 = 2,
|
||||
WGPUVertexFormat_FloatR32 = 3,
|
||||
} WGPUVertexFormat;
|
||||
|
||||
typedef WGPUId WGPUDeviceId;
|
||||
|
||||
typedef WGPUId WGPUAdapterId;
|
||||
|
||||
typedef struct {
|
||||
bool anisotropic_filtering;
|
||||
} WGPUExtensions;
|
||||
|
||||
typedef struct {
|
||||
WGPUExtensions extensions;
|
||||
} WGPUDeviceDescriptor;
|
||||
|
||||
typedef WGPUId WGPUBufferId;
|
||||
|
||||
typedef WGPUId WGPUCommandBufferId;
|
||||
@ -43,30 +201,283 @@ typedef struct {
|
||||
uint32_t depth;
|
||||
} WGPUExtent3d;
|
||||
|
||||
typedef WGPUId WGPUComputePassId;
|
||||
|
||||
typedef WGPUCommandBufferId WGPUCommandEncoderId;
|
||||
|
||||
typedef WGPUId WGPUComputePassId;
|
||||
typedef WGPUId WGPURenderPassId;
|
||||
|
||||
typedef WGPUId WGPUTextureViewId;
|
||||
|
||||
typedef struct {
|
||||
float r;
|
||||
float g;
|
||||
float b;
|
||||
float a;
|
||||
} WGPUColor;
|
||||
|
||||
typedef struct {
|
||||
WGPUTextureViewId attachment;
|
||||
WGPULoadOp load_op;
|
||||
WGPUStoreOp store_op;
|
||||
WGPUColor clear_color;
|
||||
} WGPURenderPassColorAttachmentDescriptor_TextureViewId;
|
||||
|
||||
typedef struct {
|
||||
WGPUTextureViewId attachment;
|
||||
WGPULoadOp depth_load_op;
|
||||
WGPUStoreOp depth_store_op;
|
||||
float clear_depth;
|
||||
WGPULoadOp stencil_load_op;
|
||||
WGPUStoreOp stencil_store_op;
|
||||
uint32_t clear_stencil;
|
||||
} WGPURenderPassDepthStencilAttachmentDescriptor_TextureViewId;
|
||||
|
||||
typedef struct {
|
||||
const WGPURenderPassColorAttachmentDescriptor_TextureViewId *color_attachments;
|
||||
uintptr_t color_attachments_length;
|
||||
const WGPURenderPassDepthStencilAttachmentDescriptor_TextureViewId *depth_stencil_attachment;
|
||||
} WGPURenderPassDescriptor;
|
||||
|
||||
typedef WGPUId WGPUBindGroupId;
|
||||
|
||||
typedef WGPUId WGPUComputePipelineId;
|
||||
|
||||
typedef WGPUId WGPUDeviceId;
|
||||
typedef WGPUId WGPUInstanceId;
|
||||
|
||||
typedef WGPUDeviceId WGPUQueueId;
|
||||
typedef WGPUId WGPUBindGroupLayoutId;
|
||||
|
||||
typedef WGPUId WGPURenderPassId;
|
||||
typedef struct {
|
||||
WGPUBufferId buffer;
|
||||
uint32_t offset;
|
||||
uint32_t size;
|
||||
} WGPUBufferBinding;
|
||||
|
||||
typedef WGPUId WGPUSamplerId;
|
||||
|
||||
typedef enum {
|
||||
WGPUBindingResource_Buffer,
|
||||
WGPUBindingResource_Sampler,
|
||||
WGPUBindingResource_TextureView,
|
||||
} WGPUBindingResource_Tag;
|
||||
|
||||
typedef struct {
|
||||
WGPUBufferBinding _0;
|
||||
} WGPUBindingResource_WGPUBuffer_Body;
|
||||
|
||||
typedef struct {
|
||||
WGPUSamplerId _0;
|
||||
} WGPUBindingResource_WGPUSampler_Body;
|
||||
|
||||
typedef struct {
|
||||
WGPUTextureViewId _0;
|
||||
} WGPUBindingResource_WGPUTextureView_Body;
|
||||
|
||||
typedef struct {
|
||||
WGPUBindingResource_Tag tag;
|
||||
union {
|
||||
WGPUBindingResource_WGPUBuffer_Body buffer;
|
||||
WGPUBindingResource_WGPUSampler_Body sampler;
|
||||
WGPUBindingResource_WGPUTextureView_Body texture_view;
|
||||
};
|
||||
} WGPUBindingResource;
|
||||
|
||||
typedef struct {
|
||||
uint32_t binding;
|
||||
WGPUBindingResource resource;
|
||||
} WGPUBinding;
|
||||
|
||||
typedef struct {
|
||||
WGPUBindGroupLayoutId layout;
|
||||
const WGPUBinding *bindings;
|
||||
uintptr_t bindings_length;
|
||||
} WGPUBindGroupDescriptor;
|
||||
|
||||
typedef uint32_t WGPUShaderStageFlags;
|
||||
|
||||
typedef struct {
|
||||
uint32_t binding;
|
||||
WGPUShaderStageFlags visibility;
|
||||
WGPUBindingType ty;
|
||||
} WGPUBindGroupLayoutBinding;
|
||||
|
||||
typedef struct {
|
||||
const WGPUBindGroupLayoutBinding *bindings;
|
||||
uintptr_t bindings_length;
|
||||
} WGPUBindGroupLayoutDescriptor;
|
||||
|
||||
typedef uint32_t WGPUBufferUsageFlags;
|
||||
|
||||
typedef struct {
|
||||
uint32_t size;
|
||||
WGPUBufferUsageFlags usage;
|
||||
} WGPUBufferDescriptor;
|
||||
|
||||
typedef struct {
|
||||
uint32_t todo;
|
||||
} WGPUCommandEncoderDescriptor;
|
||||
|
||||
typedef WGPUId WGPUPipelineLayoutId;
|
||||
|
||||
typedef WGPUId WGPUShaderModuleId;
|
||||
|
||||
typedef struct {
|
||||
WGPUShaderModuleId module;
|
||||
const char *entry_point;
|
||||
} WGPUPipelineStageDescriptor;
|
||||
|
||||
typedef struct {
|
||||
WGPUPipelineLayoutId layout;
|
||||
WGPUPipelineStageDescriptor compute_stage;
|
||||
} WGPUComputePipelineDescriptor;
|
||||
|
||||
typedef struct {
|
||||
const WGPUBindGroupLayoutId *bind_group_layouts;
|
||||
uintptr_t bind_group_layouts_length;
|
||||
} WGPUPipelineLayoutDescriptor;
|
||||
|
||||
typedef WGPUId WGPURenderPipelineId;
|
||||
|
||||
typedef WGPUId WGPUTextureViewId;
|
||||
typedef struct {
|
||||
WGPUFrontFace front_face;
|
||||
WGPUCullMode cull_mode;
|
||||
int32_t depth_bias;
|
||||
float depth_bias_slope_scale;
|
||||
float depth_bias_clamp;
|
||||
} WGPURasterizationStateDescriptor;
|
||||
|
||||
typedef struct {
|
||||
WGPUBlendFactor src_factor;
|
||||
WGPUBlendFactor dst_factor;
|
||||
WGPUBlendOperation operation;
|
||||
} WGPUBlendDescriptor;
|
||||
|
||||
typedef uint32_t WGPUColorWriteFlags;
|
||||
|
||||
typedef struct {
|
||||
WGPUTextureFormat format;
|
||||
WGPUBlendDescriptor alpha;
|
||||
WGPUBlendDescriptor color;
|
||||
WGPUColorWriteFlags write_mask;
|
||||
} WGPUColorStateDescriptor;
|
||||
|
||||
typedef struct {
|
||||
WGPUCompareFunction compare;
|
||||
WGPUStencilOperation fail_op;
|
||||
WGPUStencilOperation depth_fail_op;
|
||||
WGPUStencilOperation pass_op;
|
||||
} WGPUStencilStateFaceDescriptor;
|
||||
|
||||
typedef struct {
|
||||
WGPUTextureFormat format;
|
||||
bool depth_write_enabled;
|
||||
WGPUCompareFunction depth_compare;
|
||||
WGPUStencilStateFaceDescriptor stencil_front;
|
||||
WGPUStencilStateFaceDescriptor stencil_back;
|
||||
uint32_t stencil_read_mask;
|
||||
uint32_t stencil_write_mask;
|
||||
} WGPUDepthStencilStateDescriptor;
|
||||
|
||||
typedef uint32_t WGPUShaderAttributeIndex;
|
||||
|
||||
typedef struct {
|
||||
uint32_t offset;
|
||||
WGPUVertexFormat format;
|
||||
WGPUShaderAttributeIndex attribute_index;
|
||||
} WGPUVertexAttributeDescriptor;
|
||||
|
||||
typedef struct {
|
||||
uint32_t stride;
|
||||
WGPUInputStepMode step_mode;
|
||||
const WGPUVertexAttributeDescriptor *attributes;
|
||||
uintptr_t attributes_count;
|
||||
} WGPUVertexBufferDescriptor;
|
||||
|
||||
typedef struct {
|
||||
WGPUIndexFormat index_format;
|
||||
const WGPUVertexBufferDescriptor *vertex_buffers;
|
||||
uintptr_t vertex_buffers_count;
|
||||
} WGPUVertexBufferStateDescriptor;
|
||||
|
||||
typedef struct {
|
||||
WGPUPipelineLayoutId layout;
|
||||
WGPUPipelineStageDescriptor vertex_stage;
|
||||
WGPUPipelineStageDescriptor fragment_stage;
|
||||
WGPUPrimitiveTopology primitive_topology;
|
||||
WGPURasterizationStateDescriptor rasterization_state;
|
||||
const WGPUColorStateDescriptor *color_states;
|
||||
uintptr_t color_states_length;
|
||||
const WGPUDepthStencilStateDescriptor *depth_stencil_state;
|
||||
WGPUVertexBufferStateDescriptor vertex_buffer_state;
|
||||
uint32_t sample_count;
|
||||
} WGPURenderPipelineDescriptor;
|
||||
|
||||
typedef struct {
|
||||
WGPUAddressMode r_address_mode;
|
||||
WGPUAddressMode s_address_mode;
|
||||
WGPUAddressMode t_address_mode;
|
||||
WGPUFilterMode mag_filter;
|
||||
WGPUFilterMode min_filter;
|
||||
WGPUFilterMode mipmap_filter;
|
||||
float lod_min_clamp;
|
||||
float lod_max_clamp;
|
||||
uint32_t max_anisotropy;
|
||||
WGPUCompareFunction compare_function;
|
||||
WGPUBorderColor border_color;
|
||||
} WGPUSamplerDescriptor;
|
||||
|
||||
typedef struct {
|
||||
const uint8_t *bytes;
|
||||
uintptr_t length;
|
||||
} WGPUByteArray;
|
||||
|
||||
typedef struct {
|
||||
WGPUByteArray code;
|
||||
} WGPUShaderModuleDescriptor;
|
||||
|
||||
typedef WGPUId WGPUSwapChainId;
|
||||
|
||||
typedef WGPUId WGPUSurfaceId;
|
||||
|
||||
typedef uint32_t WGPUTextureUsageFlags;
|
||||
|
||||
typedef struct {
|
||||
WGPUTextureUsageFlags usage;
|
||||
WGPUTextureFormat format;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
} WGPUSwapChainDescriptor;
|
||||
|
||||
typedef struct {
|
||||
WGPUExtent3d size;
|
||||
uint32_t array_size;
|
||||
WGPUTextureDimension dimension;
|
||||
WGPUTextureFormat format;
|
||||
WGPUTextureUsageFlags usage;
|
||||
} WGPUTextureDescriptor;
|
||||
|
||||
typedef WGPUDeviceId WGPUQueueId;
|
||||
|
||||
typedef struct {
|
||||
WGPUPowerPreference power_preference;
|
||||
} WGPUAdapterDescriptor;
|
||||
|
||||
typedef struct {
|
||||
WGPUTextureId texture_id;
|
||||
WGPUTextureViewId view_id;
|
||||
} WGPUSwapChainOutput;
|
||||
|
||||
typedef WGPUId WGPUSwapChainId;
|
||||
typedef uint32_t WGPUTextureAspectFlags;
|
||||
|
||||
typedef struct {
|
||||
WGPUTextureFormat format;
|
||||
WGPUTextureViewDimension dimension;
|
||||
WGPUTextureAspectFlags aspect;
|
||||
uint32_t base_mip_level;
|
||||
uint32_t level_count;
|
||||
uint32_t base_array_layer;
|
||||
uint32_t array_count;
|
||||
} WGPUTextureViewDescriptor;
|
||||
|
||||
#define WGPUBufferUsageFlags_INDEX 16
|
||||
|
||||
@ -140,6 +551,8 @@ typedef WGPUId WGPUSwapChainId;
|
||||
|
||||
#define WGPUTrackPermit_REPLACE (WGPUTrackPermit){ .bits = 2 }
|
||||
|
||||
WGPUDeviceId wgpu_adapter_create_device(WGPUAdapterId adapter_id, const WGPUDeviceDescriptor *desc);
|
||||
|
||||
void wgpu_buffer_destroy(WGPUBufferId buffer_id);
|
||||
|
||||
void wgpu_buffer_set_sub_data(WGPUBufferId buffer_id,
|
||||
@ -169,6 +582,11 @@ void wgpu_command_buffer_copy_texture_to_texture(WGPUCommandBufferId command_buf
|
||||
const WGPUTextureCopyView *destination,
|
||||
WGPUExtent3d copy_size);
|
||||
|
||||
WGPUComputePassId wgpu_command_encoder_begin_compute_pass(WGPUCommandEncoderId command_encoder_id);
|
||||
|
||||
WGPURenderPassId wgpu_command_encoder_begin_render_pass(WGPUCommandEncoderId command_encoder_id,
|
||||
WGPURenderPassDescriptor desc);
|
||||
|
||||
WGPUCommandBufferId wgpu_command_encoder_finish(WGPUCommandEncoderId command_encoder_id);
|
||||
|
||||
void wgpu_compute_pass_dispatch(WGPUComputePassId pass_id, uint32_t x, uint32_t y, uint32_t z);
|
||||
@ -181,8 +599,58 @@ void wgpu_compute_pass_set_bind_group(WGPUComputePassId pass_id,
|
||||
|
||||
void wgpu_compute_pass_set_pipeline(WGPUComputePassId pass_id, WGPUComputePipelineId pipeline_id);
|
||||
|
||||
WGPUInstanceId wgpu_create_instance(void);
|
||||
|
||||
WGPUBindGroupId wgpu_device_create_bind_group(WGPUDeviceId device_id,
|
||||
const WGPUBindGroupDescriptor *desc);
|
||||
|
||||
WGPUBindGroupLayoutId wgpu_device_create_bind_group_layout(WGPUDeviceId device_id,
|
||||
const WGPUBindGroupLayoutDescriptor *desc);
|
||||
|
||||
WGPUBufferId wgpu_device_create_buffer(WGPUDeviceId device_id, const WGPUBufferDescriptor *desc);
|
||||
|
||||
WGPUCommandEncoderId wgpu_device_create_command_encoder(WGPUDeviceId device_id,
|
||||
const WGPUCommandEncoderDescriptor *desc);
|
||||
|
||||
WGPUComputePipelineId wgpu_device_create_compute_pipeline(WGPUDeviceId device_id,
|
||||
const WGPUComputePipelineDescriptor *desc);
|
||||
|
||||
WGPUPipelineLayoutId wgpu_device_create_pipeline_layout(WGPUDeviceId device_id,
|
||||
const WGPUPipelineLayoutDescriptor *desc);
|
||||
|
||||
WGPURenderPipelineId wgpu_device_create_render_pipeline(WGPUDeviceId device_id,
|
||||
const WGPURenderPipelineDescriptor *desc);
|
||||
|
||||
WGPUSamplerId wgpu_device_create_sampler(WGPUDeviceId device_id, const WGPUSamplerDescriptor *desc);
|
||||
|
||||
WGPUShaderModuleId wgpu_device_create_shader_module(WGPUDeviceId device_id,
|
||||
const WGPUShaderModuleDescriptor *desc);
|
||||
|
||||
WGPUSwapChainId wgpu_device_create_swap_chain(WGPUDeviceId device_id,
|
||||
WGPUSurfaceId surface_id,
|
||||
const WGPUSwapChainDescriptor *desc);
|
||||
|
||||
WGPUTextureId wgpu_device_create_texture(WGPUDeviceId device_id, const WGPUTextureDescriptor *desc);
|
||||
|
||||
WGPUQueueId wgpu_device_get_queue(WGPUDeviceId device_id);
|
||||
|
||||
WGPUSurfaceId wgpu_instance_create_surface_from_macos_layer(WGPUInstanceId instance_id,
|
||||
void *layer);
|
||||
|
||||
WGPUSurfaceId wgpu_instance_create_surface_from_windows_hwnd(WGPUInstanceId instance_id,
|
||||
void *hinstance,
|
||||
void *hwnd);
|
||||
|
||||
WGPUSurfaceId wgpu_instance_create_surface_from_winit(WGPUInstanceId instance_id,
|
||||
const WGPUWindow *window);
|
||||
|
||||
WGPUSurfaceId wgpu_instance_create_surface_from_xlib(WGPUInstanceId instance_id,
|
||||
const void **display,
|
||||
uint64_t window);
|
||||
|
||||
WGPUAdapterId wgpu_instance_get_adapter(WGPUInstanceId instance_id,
|
||||
const WGPUAdapterDescriptor *desc);
|
||||
|
||||
void wgpu_queue_submit(WGPUQueueId queue_id,
|
||||
const WGPUCommandBufferId *command_buffer_ptr,
|
||||
uintptr_t command_buffer_count);
|
||||
@ -221,6 +689,11 @@ WGPUSwapChainOutput wgpu_swap_chain_get_next_texture(WGPUSwapChainId swap_chain_
|
||||
|
||||
void wgpu_swap_chain_present(WGPUSwapChainId swap_chain_id);
|
||||
|
||||
WGPUTextureViewId wgpu_texture_create_default_view(WGPUTextureId texture_id);
|
||||
|
||||
WGPUTextureViewId wgpu_texture_create_view(WGPUTextureId texture_id,
|
||||
const WGPUTextureViewDescriptor *desc);
|
||||
|
||||
void wgpu_texture_destroy(WGPUTextureId texture_id);
|
||||
|
||||
void wgpu_texture_view_destroy(WGPUTextureViewId _texture_view_id);
|
||||
|
@ -106,12 +106,9 @@ impl CommandBufferHandle {
|
||||
let b = buffer_guard.get(id);
|
||||
trace!("transit {:?} {:?}", id, transit);
|
||||
hal::memory::Barrier::Buffer {
|
||||
states: conv::map_buffer_state(transit.start)..conv::map_buffer_state(transit.end),
|
||||
states: conv::map_buffer_state(transit.start) .. conv::map_buffer_state(transit.end),
|
||||
target: &b.raw,
|
||||
range: Range {
|
||||
start: None,
|
||||
end: None,
|
||||
},
|
||||
range: None .. None,
|
||||
families: None,
|
||||
}
|
||||
});
|
||||
@ -157,7 +154,7 @@ pub extern "C" fn wgpu_command_encoder_finish(
|
||||
command_encoder_id
|
||||
}
|
||||
|
||||
pub fn wgpu_command_encoder_begin_render_pass_impl(
|
||||
pub fn command_encoder_begin_render_pass(
|
||||
command_encoder_id: CommandEncoderId,
|
||||
desc: RenderPassDescriptor,
|
||||
) -> RenderPass<Backend> {
|
||||
@ -367,11 +364,11 @@ pub extern "C" fn wgpu_command_encoder_begin_render_pass(
|
||||
command_encoder_id: CommandEncoderId,
|
||||
desc: RenderPassDescriptor,
|
||||
) -> RenderPassId {
|
||||
let pass = wgpu_command_encoder_begin_render_pass_impl(command_encoder_id, desc);
|
||||
let pass = command_encoder_begin_render_pass(command_encoder_id, desc);
|
||||
HUB.render_passes.register(pass)
|
||||
}
|
||||
|
||||
pub fn wgpu_command_encoder_begin_compute_pass_impl(
|
||||
pub fn command_encoder_begin_compute_pass(
|
||||
command_encoder_id: CommandEncoderId,
|
||||
) -> ComputePass<Backend> {
|
||||
let mut cmb_guard = HUB.command_buffers.write();
|
||||
@ -391,6 +388,6 @@ pub fn wgpu_command_encoder_begin_compute_pass_impl(
|
||||
pub extern "C" fn wgpu_command_encoder_begin_compute_pass(
|
||||
command_encoder_id: CommandEncoderId,
|
||||
) -> ComputePassId {
|
||||
let pass = wgpu_command_encoder_begin_compute_pass_impl(command_encoder_id);
|
||||
let pass = command_encoder_begin_compute_pass(command_encoder_id);
|
||||
HUB.compute_passes.register(pass)
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
use crate::{
|
||||
binding_model, command, pipeline, resource, Color,
|
||||
Extent3d, Origin3d,
|
||||
MAX_DEPTH_BIAS_CLAMP,
|
||||
};
|
||||
|
||||
|
||||
@ -136,12 +137,12 @@ pub fn map_color_state_descriptor(
|
||||
desc: &pipeline::ColorStateDescriptor,
|
||||
) -> hal::pso::ColorBlendDesc {
|
||||
let color_mask = desc.write_mask;
|
||||
let blend_state = if *desc.color != pipeline::BlendDescriptor::REPLACE ||
|
||||
*desc.alpha != pipeline::BlendDescriptor::REPLACE
|
||||
let blend_state = if desc.color != pipeline::BlendDescriptor::REPLACE ||
|
||||
desc.alpha != pipeline::BlendDescriptor::REPLACE
|
||||
{
|
||||
hal::pso::BlendState::On {
|
||||
color: map_blend_descriptor(desc.color),
|
||||
alpha: map_blend_descriptor(desc.alpha),
|
||||
color: map_blend_descriptor(&desc.color),
|
||||
alpha: map_blend_descriptor(&desc.alpha),
|
||||
}
|
||||
} else {
|
||||
hal::pso::BlendState::Off
|
||||
@ -224,12 +225,12 @@ pub fn map_depth_stencil_state_descriptor(
|
||||
},
|
||||
depth_bounds: false, // TODO
|
||||
stencil: if desc.stencil_read_mask != !0 || desc.stencil_write_mask != !0 ||
|
||||
*desc.stencil_front != pipeline::StencilStateFaceDescriptor::IGNORE ||
|
||||
*desc.stencil_back != pipeline::StencilStateFaceDescriptor::IGNORE
|
||||
desc.stencil_front != pipeline::StencilStateFaceDescriptor::IGNORE ||
|
||||
desc.stencil_back != pipeline::StencilStateFaceDescriptor::IGNORE
|
||||
{
|
||||
hal::pso::StencilTest::On {
|
||||
front: map_stencil_face(desc.stencil_front, desc.stencil_read_mask, desc.stencil_write_mask),
|
||||
back: map_stencil_face(desc.stencil_back, desc.stencil_read_mask, desc.stencil_write_mask),
|
||||
front: map_stencil_face(&desc.stencil_front, desc.stencil_read_mask, desc.stencil_write_mask),
|
||||
back: map_stencil_face(&desc.stencil_back, desc.stencil_read_mask, desc.stencil_write_mask),
|
||||
}
|
||||
} else {
|
||||
hal::pso::StencilTest::Off
|
||||
@ -484,7 +485,7 @@ pub fn map_rasterization_state_descriptor(
|
||||
pipeline::FrontFace::Ccw => hal::pso::FrontFace::CounterClockwise,
|
||||
pipeline::FrontFace::Cw => hal::pso::FrontFace::Clockwise,
|
||||
},
|
||||
depth_bias: if desc.depth_bias != 0 || desc.depth_bias_slope_scale != 0.0 || desc.depth_bias_clamp < 16.0 {
|
||||
depth_bias: if desc.depth_bias != 0 || desc.depth_bias_slope_scale != 0.0 || desc.depth_bias_clamp < MAX_DEPTH_BIAS_CLAMP {
|
||||
Some(hal::pso::State::Static(hal::pso::DepthBias {
|
||||
const_factor: desc.depth_bias as f32,
|
||||
slope_factor: desc.depth_bias_slope_scale,
|
||||
|
@ -276,7 +276,7 @@ pub struct ShaderModule<B: hal::Backend> {
|
||||
}
|
||||
|
||||
|
||||
pub fn wgpu_device_create_buffer_impl(
|
||||
pub fn device_create_buffer(
|
||||
device_id: DeviceId,
|
||||
desc: &resource::BufferDescriptor,
|
||||
) -> resource::Buffer<back::Backend> {
|
||||
@ -326,7 +326,7 @@ pub fn wgpu_device_create_buffer_impl(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn wgpu_device_track_buffer(
|
||||
pub fn device_track_buffer(
|
||||
device_id: DeviceId,
|
||||
buffer_id: BufferId,
|
||||
ref_count: RefCount,
|
||||
@ -349,10 +349,10 @@ pub extern "C" fn wgpu_device_create_buffer(
|
||||
device_id: DeviceId,
|
||||
desc: &resource::BufferDescriptor,
|
||||
) -> BufferId {
|
||||
let buffer = wgpu_device_create_buffer_impl(device_id, desc);
|
||||
let buffer = device_create_buffer(device_id, desc);
|
||||
let ref_count = buffer.life_guard.ref_count.clone();
|
||||
let id = HUB.buffers.register(buffer);
|
||||
wgpu_device_track_buffer(device_id, id, ref_count);
|
||||
device_track_buffer(device_id, id, ref_count);
|
||||
id
|
||||
}
|
||||
|
||||
@ -369,7 +369,7 @@ pub extern "C" fn wgpu_buffer_destroy(buffer_id: BufferId) {
|
||||
}
|
||||
|
||||
|
||||
pub fn wgpu_device_create_texture_impl(
|
||||
pub fn device_create_texture(
|
||||
device_id: DeviceId,
|
||||
desc: &resource::TextureDescriptor,
|
||||
) -> resource::Texture<back::Backend> {
|
||||
@ -438,7 +438,7 @@ pub fn wgpu_device_create_texture_impl(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn wgpu_device_track_texture(
|
||||
pub fn device_track_texture(
|
||||
device_id: DeviceId,
|
||||
texture_id: TextureId,
|
||||
ref_count: RefCount,
|
||||
@ -461,14 +461,14 @@ pub extern "C" fn wgpu_device_create_texture(
|
||||
device_id: DeviceId,
|
||||
desc: &resource::TextureDescriptor,
|
||||
) -> TextureId {
|
||||
let texture = wgpu_device_create_texture_impl(device_id, desc);
|
||||
let texture = device_create_texture(device_id, desc);
|
||||
let ref_count = texture.life_guard.ref_count.clone();
|
||||
let id = HUB.textures.register(texture);
|
||||
wgpu_device_track_texture(device_id, id, ref_count);
|
||||
device_track_texture(device_id, id, ref_count);
|
||||
id
|
||||
}
|
||||
|
||||
pub fn wgpu_texture_create_view_impl(
|
||||
pub fn texture_create_view(
|
||||
texture_id: TextureId,
|
||||
desc: &resource::TextureViewDescriptor,
|
||||
) -> resource::TextureView<back::Backend> {
|
||||
@ -514,11 +514,11 @@ pub extern "C" fn wgpu_texture_create_view(
|
||||
texture_id: TextureId,
|
||||
desc: &resource::TextureViewDescriptor,
|
||||
) -> TextureViewId {
|
||||
let view = wgpu_texture_create_view_impl(texture_id, desc);
|
||||
let view = texture_create_view(texture_id, desc);
|
||||
HUB.texture_views.register(view)
|
||||
}
|
||||
|
||||
pub fn wgpu_texture_create_default_view_impl(
|
||||
pub fn texture_create_default_view(
|
||||
texture_id: TextureId
|
||||
) -> resource::TextureView<back::Backend> {
|
||||
let texture_guard = HUB.textures.read();
|
||||
@ -562,7 +562,7 @@ pub fn wgpu_texture_create_default_view_impl(
|
||||
#[cfg(feature = "local")]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_texture_create_default_view(texture_id: TextureId) -> TextureViewId {
|
||||
let view = wgpu_texture_create_default_view_impl(texture_id);
|
||||
let view = texture_create_default_view(texture_id);
|
||||
HUB.texture_views.register(view)
|
||||
}
|
||||
|
||||
@ -584,7 +584,7 @@ pub extern "C" fn wgpu_texture_view_destroy(_texture_view_id: TextureViewId) {
|
||||
}
|
||||
|
||||
|
||||
pub fn wgpu_device_create_sampler_impl(
|
||||
pub fn device_create_sampler(
|
||||
device_id: DeviceId, desc: &resource::SamplerDescriptor
|
||||
) -> resource::Sampler<back::Backend> {
|
||||
let device_guard = HUB.devices.read();
|
||||
@ -629,12 +629,12 @@ pub fn wgpu_device_create_sampler_impl(
|
||||
pub extern "C" fn wgpu_device_create_sampler(
|
||||
device_id: DeviceId, desc: &resource::SamplerDescriptor
|
||||
) -> SamplerId {
|
||||
let sampler = wgpu_device_create_sampler_impl(device_id, desc);
|
||||
let sampler = device_create_sampler(device_id, desc);
|
||||
HUB.samplers.register(sampler)
|
||||
}
|
||||
|
||||
|
||||
pub fn wgpu_device_create_bind_group_layout_impl(
|
||||
pub fn device_create_bind_group_layout(
|
||||
device_id: DeviceId,
|
||||
desc: &binding_model::BindGroupLayoutDescriptor,
|
||||
) -> binding_model::BindGroupLayout<back::Backend> {
|
||||
@ -671,11 +671,11 @@ pub extern "C" fn wgpu_device_create_bind_group_layout(
|
||||
device_id: DeviceId,
|
||||
desc: &binding_model::BindGroupLayoutDescriptor,
|
||||
) -> BindGroupLayoutId {
|
||||
let layout = wgpu_device_create_bind_group_layout_impl(device_id, desc);
|
||||
let layout = device_create_bind_group_layout(device_id, desc);
|
||||
HUB.bind_group_layouts.register(layout)
|
||||
}
|
||||
|
||||
pub fn wgpu_device_create_pipeline_layout_impl(
|
||||
pub fn device_create_pipeline_layout(
|
||||
device_id: DeviceId,
|
||||
desc: &binding_model::PipelineLayoutDescriptor,
|
||||
) -> binding_model::PipelineLayout<back::Backend> {
|
||||
@ -713,11 +713,11 @@ pub extern "C" fn wgpu_device_create_pipeline_layout(
|
||||
device_id: DeviceId,
|
||||
desc: &binding_model::PipelineLayoutDescriptor,
|
||||
) -> PipelineLayoutId {
|
||||
let layout = wgpu_device_create_pipeline_layout_impl(device_id, desc);
|
||||
let layout = device_create_pipeline_layout(device_id, desc);
|
||||
HUB.pipeline_layouts.register(layout)
|
||||
}
|
||||
|
||||
pub fn wgpu_device_create_bind_group_impl(
|
||||
pub fn device_create_bind_group(
|
||||
device_id: DeviceId,
|
||||
desc: &binding_model::BindGroupDescriptor,
|
||||
) -> binding_model::BindGroup<back::Backend> {
|
||||
@ -802,12 +802,12 @@ pub extern "C" fn wgpu_device_create_bind_group(
|
||||
device_id: DeviceId,
|
||||
desc: &binding_model::BindGroupDescriptor,
|
||||
) -> BindGroupId {
|
||||
let bind_group = wgpu_device_create_bind_group_impl(device_id, desc);
|
||||
let bind_group = device_create_bind_group(device_id, desc);
|
||||
HUB.bind_groups.register(bind_group)
|
||||
}
|
||||
|
||||
|
||||
pub fn wgpu_device_create_shader_module_impl(
|
||||
pub fn device_create_shader_module(
|
||||
device_id: DeviceId,
|
||||
desc: &pipeline::ShaderModuleDescriptor,
|
||||
) -> ShaderModule<back::Backend> {
|
||||
@ -830,11 +830,11 @@ pub extern "C" fn wgpu_device_create_shader_module(
|
||||
device_id: DeviceId,
|
||||
desc: &pipeline::ShaderModuleDescriptor,
|
||||
) -> ShaderModuleId {
|
||||
let module = wgpu_device_create_shader_module_impl(device_id, desc);
|
||||
let module = device_create_shader_module(device_id, desc);
|
||||
HUB.shader_modules.register(module)
|
||||
}
|
||||
|
||||
pub fn wgpu_device_create_command_encoder_impl(
|
||||
pub fn device_create_command_encoder(
|
||||
device_id: DeviceId,
|
||||
_desc: &command::CommandEncoderDescriptor,
|
||||
) -> command::CommandBuffer<back::Backend> {
|
||||
@ -861,7 +861,7 @@ pub extern "C" fn wgpu_device_create_command_encoder(
|
||||
device_id: DeviceId,
|
||||
desc: &command::CommandEncoderDescriptor,
|
||||
) -> CommandEncoderId {
|
||||
let cmb = wgpu_device_create_command_encoder_impl(device_id, desc);
|
||||
let cmb = device_create_command_encoder(device_id, desc);
|
||||
HUB.command_buffers.register(cmb)
|
||||
}
|
||||
|
||||
@ -1003,7 +1003,7 @@ pub extern "C" fn wgpu_queue_submit(
|
||||
}
|
||||
|
||||
|
||||
pub fn wgpu_device_create_render_pipeline_impl(
|
||||
pub fn device_create_render_pipeline(
|
||||
device_id: DeviceId,
|
||||
desc: &pipeline::RenderPipelineDescriptor,
|
||||
) -> pipeline::RenderPipeline<back::Backend> {
|
||||
@ -1019,6 +1019,9 @@ pub fn wgpu_device_create_render_pipeline_impl(
|
||||
desc.color_states_length,
|
||||
)
|
||||
};
|
||||
let depth_stencil_state = unsafe {
|
||||
desc.depth_stencil_state.as_ref()
|
||||
};
|
||||
|
||||
let rp_key = {
|
||||
let color_keys = color_states.iter().map(|at| hal::pass::Attachment {
|
||||
@ -1028,7 +1031,7 @@ pub fn wgpu_device_create_render_pipeline_impl(
|
||||
stencil_ops: hal::pass::AttachmentOps::DONT_CARE,
|
||||
layouts: hal::image::Layout::General..hal::image::Layout::General,
|
||||
});
|
||||
let depth_stencil_key = desc.depth_stencil_state.map(|at| hal::pass::Attachment {
|
||||
let depth_stencil_key = depth_stencil_state.map(|at| hal::pass::Attachment {
|
||||
format: Some(conv::map_texture_format(at.format)),
|
||||
samples: desc.sample_count as u8,
|
||||
ops: hal::pass::AttachmentOps::PRESERVE,
|
||||
@ -1057,7 +1060,7 @@ pub fn wgpu_device_create_render_pipeline_impl(
|
||||
|
||||
let subpass = hal::pass::SubpassDesc {
|
||||
colors: &color_ids[..desc.color_states_length],
|
||||
depth_stencil: desc.depth_stencil_state.map(|_| &depth_id),
|
||||
depth_stencil: depth_stencil_state.map(|_| &depth_id),
|
||||
inputs: &[],
|
||||
resolves: &[],
|
||||
preserves: &[],
|
||||
@ -1105,7 +1108,7 @@ pub fn wgpu_device_create_render_pipeline_impl(
|
||||
geometry: None,
|
||||
fragment: Some(fragment),
|
||||
};
|
||||
let rasterizer = conv::map_rasterization_state_descriptor(desc.rasterization_state);
|
||||
let rasterizer = conv::map_rasterization_state_descriptor(&desc.rasterization_state);
|
||||
|
||||
let desc_vbs = unsafe {
|
||||
slice::from_raw_parts(desc.vertex_buffer_state.vertex_buffers, desc.vertex_buffer_state.vertex_buffers_count)
|
||||
@ -1151,7 +1154,7 @@ pub fn wgpu_device_create_render_pipeline_impl(
|
||||
.map(conv::map_color_state_descriptor)
|
||||
.collect(),
|
||||
};
|
||||
let depth_stencil = desc.depth_stencil_state
|
||||
let depth_stencil = depth_stencil_state
|
||||
.map(conv::map_depth_stencil_state_descriptor)
|
||||
.unwrap_or_default();
|
||||
|
||||
@ -1211,11 +1214,11 @@ pub extern "C" fn wgpu_device_create_render_pipeline(
|
||||
device_id: DeviceId,
|
||||
desc: &pipeline::RenderPipelineDescriptor,
|
||||
) -> RenderPipelineId {
|
||||
let pipeline = wgpu_device_create_render_pipeline_impl(device_id, desc);
|
||||
let pipeline = device_create_render_pipeline(device_id, desc);
|
||||
HUB.render_pipelines.register(pipeline)
|
||||
}
|
||||
|
||||
pub fn wgpu_device_create_compute_pipeline_impl(
|
||||
pub fn device_create_compute_pipeline(
|
||||
device_id: DeviceId,
|
||||
desc: &pipeline::ComputePipelineDescriptor,
|
||||
) -> pipeline::ComputePipeline<back::Backend> {
|
||||
@ -1269,12 +1272,12 @@ pub extern "C" fn wgpu_device_create_compute_pipeline(
|
||||
device_id: DeviceId,
|
||||
desc: &pipeline::ComputePipelineDescriptor,
|
||||
) -> ComputePipelineId {
|
||||
let pipeline = wgpu_device_create_compute_pipeline_impl(device_id, desc);
|
||||
let pipeline = device_create_compute_pipeline(device_id, desc);
|
||||
HUB.compute_pipelines.register(pipeline)
|
||||
}
|
||||
|
||||
|
||||
pub fn wgpu_device_create_swap_chain_impl(
|
||||
pub fn device_create_swap_chain(
|
||||
device_id: DeviceId,
|
||||
surface_id: SurfaceId,
|
||||
desc: &swap_chain::SwapChainDescriptor,
|
||||
@ -1369,7 +1372,7 @@ pub fn wgpu_device_create_swap_chain_impl(
|
||||
}
|
||||
|
||||
#[cfg(feature = "local")]
|
||||
pub fn wgpu_swap_chain_populate_textures(
|
||||
fn swap_chain_populate_textures(
|
||||
swap_chain_id: SwapChainId,
|
||||
textures: Vec<resource::Texture<back::Backend>>,
|
||||
) {
|
||||
@ -1436,9 +1439,9 @@ pub extern "C" fn wgpu_device_create_swap_chain(
|
||||
surface_id: SurfaceId,
|
||||
desc: &swap_chain::SwapChainDescriptor,
|
||||
) -> SwapChainId {
|
||||
let (swap_chain, textures) = wgpu_device_create_swap_chain_impl(device_id, surface_id, desc);
|
||||
let (swap_chain, textures) = device_create_swap_chain(device_id, surface_id, desc);
|
||||
let id = HUB.swap_chains.register(swap_chain);
|
||||
wgpu_swap_chain_populate_textures(id, textures);
|
||||
swap_chain_populate_textures(id, textures);
|
||||
id
|
||||
}
|
||||
|
||||
|
@ -33,14 +33,14 @@ pub struct DeviceDescriptor {
|
||||
pub extensions: Extensions,
|
||||
}
|
||||
|
||||
pub fn wgpu_create_instance_impl() -> ::back::Instance {
|
||||
pub fn create_instance() -> ::back::Instance {
|
||||
::back::Instance::create("wgpu", 1)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
#[cfg(feature = "local")]
|
||||
pub extern "C" fn wgpu_create_instance() -> InstanceId {
|
||||
let inst = wgpu_create_instance_impl();
|
||||
let inst = create_instance();
|
||||
HUB.instances.register(inst)
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ pub extern "C" fn wgpu_instance_create_surface_from_winit(
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
pub fn wgpu_instance_create_surface_from_xlib_impl(
|
||||
pub fn instance_create_surface_from_xlib(
|
||||
instance_id: InstanceId,
|
||||
display: *mut *const std::ffi::c_void,
|
||||
window: u64,
|
||||
@ -86,12 +86,12 @@ pub extern "C" fn wgpu_instance_create_surface_from_xlib(
|
||||
display: *mut *const std::ffi::c_void,
|
||||
window: u64,
|
||||
) -> SurfaceId {
|
||||
let surface = wgpu_instance_create_surface_from_xlib_impl(instance_id, display, window);
|
||||
let surface = instance_create_surface_from_xlib(instance_id, display, window);
|
||||
HUB.surfaces.register(surface)
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
pub fn wgpu_instance_create_surface_from_macos_layer_impl(
|
||||
pub fn instance_create_surface_from_macos_layer(
|
||||
instance_id: InstanceId,
|
||||
layer: *mut std::ffi::c_void,
|
||||
) -> SurfaceHandle {
|
||||
@ -113,12 +113,12 @@ pub extern "C" fn wgpu_instance_create_surface_from_macos_layer(
|
||||
instance_id: InstanceId,
|
||||
layer: *mut std::ffi::c_void,
|
||||
) -> SurfaceId {
|
||||
let surface = wgpu_instance_create_surface_from_macos_layer_impl(instance_id, layer);
|
||||
let surface = instance_create_surface_from_macos_layer(instance_id, layer);
|
||||
HUB.surfaces.register(surface)
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
pub fn wgpu_instance_create_surface_from_windows_hwnd_impl(
|
||||
pub fn instance_create_surface_from_windows_hwnd(
|
||||
instance_id: InstanceId,
|
||||
hinstance: *mut std::ffi::c_void,
|
||||
hwnd: *mut std::ffi::c_void,
|
||||
@ -151,11 +151,11 @@ pub extern "C" fn wgpu_instance_create_surface_from_windows_hwnd(
|
||||
hinstance: *mut std::ffi::c_void,
|
||||
hwnd: *mut std::ffi::c_void,
|
||||
) -> SurfaceId {
|
||||
let surface = wgpu_instance_create_surface_from_windows_hwnd_impl(instance_id, hinstance, hwnd);
|
||||
let surface = instance_create_surface_from_windows_hwnd(instance_id, hinstance, hwnd);
|
||||
HUB.surfaces.register(surface)
|
||||
}
|
||||
|
||||
pub fn wgpu_instance_get_adapter_impl(
|
||||
pub fn instance_get_adapter(
|
||||
instance_id: InstanceId,
|
||||
desc: &AdapterDescriptor,
|
||||
) -> AdapterHandle {
|
||||
@ -183,11 +183,11 @@ pub extern "C" fn wgpu_instance_get_adapter(
|
||||
instance_id: InstanceId,
|
||||
desc: &AdapterDescriptor,
|
||||
) -> AdapterId {
|
||||
let adapter = wgpu_instance_get_adapter_impl(instance_id, desc);
|
||||
let adapter = instance_get_adapter(instance_id, desc);
|
||||
HUB.adapters.register(adapter)
|
||||
}
|
||||
|
||||
pub fn wgpu_adapter_create_device_impl(
|
||||
pub fn adapter_create_device(
|
||||
adapter_id: AdapterId,
|
||||
_desc: &DeviceDescriptor,
|
||||
) -> DeviceHandle {
|
||||
@ -204,6 +204,6 @@ pub extern "C" fn wgpu_adapter_create_device(
|
||||
adapter_id: AdapterId,
|
||||
desc: &DeviceDescriptor,
|
||||
) -> DeviceId {
|
||||
let device = wgpu_adapter_create_device_impl(adapter_id, desc);
|
||||
let device = adapter_create_device(adapter_id, desc);
|
||||
HUB.devices.register(device)
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ pub use self::hub::{Id, IdentityManager};
|
||||
use std::ptr;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
||||
pub const MAX_DEPTH_BIAS_CLAMP: f32 = 16.0;
|
||||
type SubmissionIndex = usize;
|
||||
|
||||
//TODO: make it private. Currently used for swapchain creation impl.
|
||||
|
@ -65,10 +65,10 @@ impl BlendDescriptor {
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ColorStateDescriptor<'a> {
|
||||
pub struct ColorStateDescriptor {
|
||||
pub format: resource::TextureFormat,
|
||||
pub alpha: &'a BlendDescriptor,
|
||||
pub color: &'a BlendDescriptor,
|
||||
pub alpha: BlendDescriptor,
|
||||
pub color: BlendDescriptor,
|
||||
pub write_mask: ColorWriteFlags,
|
||||
}
|
||||
|
||||
@ -105,12 +105,12 @@ impl StencilStateFaceDescriptor {
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct DepthStencilStateDescriptor<'a> {
|
||||
pub struct DepthStencilStateDescriptor {
|
||||
pub format: resource::TextureFormat,
|
||||
pub depth_write_enabled: bool,
|
||||
pub depth_compare: resource::CompareFunction,
|
||||
pub stencil_front: &'a StencilStateFaceDescriptor,
|
||||
pub stencil_back: &'a StencilStateFaceDescriptor,
|
||||
pub stencil_front: StencilStateFaceDescriptor,
|
||||
pub stencil_back: StencilStateFaceDescriptor,
|
||||
pub stencil_read_mask: u32,
|
||||
pub stencil_write_mask: u32,
|
||||
}
|
||||
@ -173,9 +173,9 @@ pub struct PipelineStageDescriptor {
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct ComputePipelineDescriptor<'a> {
|
||||
pub struct ComputePipelineDescriptor {
|
||||
pub layout: PipelineLayoutId,
|
||||
pub compute_stage: &'a PipelineStageDescriptor,
|
||||
pub compute_stage: PipelineStageDescriptor,
|
||||
}
|
||||
|
||||
pub struct ComputePipeline<B: hal::Backend> {
|
||||
@ -209,6 +209,7 @@ pub enum CullMode {
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct RasterizationStateDescriptor {
|
||||
pub front_face: FrontFace,
|
||||
pub cull_mode: CullMode,
|
||||
@ -218,15 +219,15 @@ pub struct RasterizationStateDescriptor {
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct RenderPipelineDescriptor<'a> {
|
||||
pub struct RenderPipelineDescriptor {
|
||||
pub layout: PipelineLayoutId,
|
||||
pub vertex_stage: &'a PipelineStageDescriptor,
|
||||
pub fragment_stage: &'a PipelineStageDescriptor,
|
||||
pub vertex_stage: PipelineStageDescriptor,
|
||||
pub fragment_stage: PipelineStageDescriptor,
|
||||
pub primitive_topology: PrimitiveTopology,
|
||||
pub rasterization_state: &'a RasterizationStateDescriptor,
|
||||
pub color_states: *const ColorStateDescriptor<'a>,
|
||||
pub rasterization_state: RasterizationStateDescriptor,
|
||||
pub color_states: *const ColorStateDescriptor,
|
||||
pub color_states_length: usize,
|
||||
pub depth_stencil_state: Option<&'a DepthStencilStateDescriptor<'a>>,
|
||||
pub depth_stencil_state: *const DepthStencilStateDescriptor,
|
||||
pub vertex_buffer_state: VertexBufferStateDescriptor,
|
||||
pub sample_count: u32,
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ use std::ptr;
|
||||
|
||||
pub use wgn::winit;
|
||||
pub use wgn::{
|
||||
MAX_DEPTH_BIAS_CLAMP,
|
||||
AdapterDescriptor, BindGroupLayoutBinding, BindingType,
|
||||
BlendDescriptor, BlendOperation, BlendFactor, ColorWriteFlags,
|
||||
RasterizationStateDescriptor, CullMode, FrontFace,
|
||||
@ -154,8 +155,8 @@ pub struct RenderPipelineDescriptor<'a> {
|
||||
pub fragment_stage: PipelineStageDescriptor<'a>,
|
||||
pub rasterization_state: RasterizationStateDescriptor,
|
||||
pub primitive_topology: PrimitiveTopology,
|
||||
pub color_states: &'a [ColorStateDescriptor<'a>],
|
||||
pub depth_stencil_state: Option<DepthStencilStateDescriptor<'a>>,
|
||||
pub color_states: &'a [ColorStateDescriptor],
|
||||
pub depth_stencil_state: Option<DepthStencilStateDescriptor>,
|
||||
pub index_format: IndexFormat,
|
||||
pub vertex_buffers: &'a [VertexBufferDescriptor<'a>],
|
||||
pub sample_count: u32,
|
||||
@ -355,19 +356,21 @@ impl Device {
|
||||
self.id,
|
||||
&wgn::RenderPipelineDescriptor {
|
||||
layout: desc.layout.id,
|
||||
vertex_stage: &wgn::PipelineStageDescriptor {
|
||||
vertex_stage: wgn::PipelineStageDescriptor {
|
||||
module: desc.vertex_stage.module.id,
|
||||
entry_point: vertex_entry_point.as_ptr(),
|
||||
},
|
||||
fragment_stage: &wgn::PipelineStageDescriptor {
|
||||
fragment_stage: wgn::PipelineStageDescriptor {
|
||||
module: desc.fragment_stage.module.id,
|
||||
entry_point: fragment_entry_point.as_ptr(),
|
||||
},
|
||||
rasterization_state: &desc.rasterization_state,
|
||||
rasterization_state: desc.rasterization_state.clone(),
|
||||
primitive_topology: desc.primitive_topology,
|
||||
color_states: temp_color_states.as_ptr(),
|
||||
color_states_length: temp_color_states.len(),
|
||||
depth_stencil_state: desc.depth_stencil_state.as_ref(),
|
||||
depth_stencil_state: desc.depth_stencil_state
|
||||
.as_ref()
|
||||
.map_or(ptr::null(), |p| p as *const _),
|
||||
vertex_buffer_state: wgn::VertexBufferStateDescriptor {
|
||||
index_format: desc.index_format,
|
||||
vertex_buffers: temp_vertex_buffers.as_ptr(),
|
||||
@ -387,7 +390,7 @@ impl Device {
|
||||
self.id,
|
||||
&wgn::ComputePipelineDescriptor {
|
||||
layout: desc.layout.id,
|
||||
compute_stage: &wgn::PipelineStageDescriptor {
|
||||
compute_stage: wgn::PipelineStageDescriptor {
|
||||
module: desc.compute_stage.module.id,
|
||||
entry_point: entry_point.as_ptr(),
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user