mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-19 14:01:08 +01:00
API update with naming, formats, and extra fields
This commit is contained in:
1 parent
75201773a7
commit
6a1dcb9565
15 files changed
+308
-311
No files matched your search
@@ -49,7 +49,7 @@ int main() {
|
||||
.power_preference = WGPUPowerPreference_LowPower,
|
||||
});
|
||||
|
||||
WGPUDeviceId device = wgpu_adapter_create_device(adapter,
|
||||
WGPUDeviceId device = wgpu_adapter_request_device(adapter,
|
||||
&(WGPUDeviceDescriptor){
|
||||
.extensions =
|
||||
{
|
||||
@@ -102,7 +102,7 @@ int main() {
|
||||
.entry_point = "main",
|
||||
},
|
||||
.fragment_stage =
|
||||
(WGPUPipelineStageDescriptor){
|
||||
&(WGPUPipelineStageDescriptor){
|
||||
.module = fragment_shader,
|
||||
.entry_point = "main",
|
||||
},
|
||||
@@ -118,24 +118,24 @@ int main() {
|
||||
.color_states =
|
||||
&(WGPUColorStateDescriptor){
|
||||
.format = WGPUTextureFormat_Bgra8Unorm,
|
||||
.alpha =
|
||||
.alpha_blend =
|
||||
(WGPUBlendDescriptor){
|
||||
.src_factor = WGPUBlendFactor_One,
|
||||
.dst_factor = WGPUBlendFactor_Zero,
|
||||
.operation = WGPUBlendOperation_Add,
|
||||
},
|
||||
.color =
|
||||
.color_blend =
|
||||
(WGPUBlendDescriptor){
|
||||
.src_factor = WGPUBlendFactor_One,
|
||||
.dst_factor = WGPUBlendFactor_Zero,
|
||||
.operation = WGPUBlendOperation_Add,
|
||||
},
|
||||
.write_mask = WGPUColorWriteFlags_ALL,
|
||||
.write_mask = WGPUColorWrite_ALL,
|
||||
},
|
||||
.color_states_length = 1,
|
||||
.depth_stencil_state = NULL,
|
||||
.vertex_buffer_state =
|
||||
(WGPUVertexBufferStateDescriptor){
|
||||
.vertex_input =
|
||||
(WGPUVertexInputDescriptor){
|
||||
.index_format = WGPUIndexFormat_Uint16,
|
||||
.vertex_buffers = NULL,
|
||||
.vertex_buffers_count = 0,
|
||||
@@ -194,7 +194,7 @@ int main() {
|
||||
|
||||
WGPUSwapChainId swap_chain = wgpu_device_create_swap_chain(device, surface,
|
||||
&(WGPUSwapChainDescriptor){
|
||||
.usage = WGPUTextureUsageFlags_OUTPUT_ATTACHMENT,
|
||||
.usage = WGPUTextureUsage_OUTPUT_ATTACHMENT,
|
||||
.format = WGPUTextureFormat_Bgra8Unorm,
|
||||
.width = prev_width,
|
||||
.height = prev_height,
|
||||
|
||||
@@ -38,8 +38,13 @@ typedef struct {
|
||||
bool anisotropic_filtering;
|
||||
} WGPUExtensions;
|
||||
|
||||
typedef struct {
|
||||
uint32_t max_bind_groups;
|
||||
} WGPULimits;
|
||||
|
||||
typedef struct {
|
||||
WGPUExtensions extensions;
|
||||
WGPULimits limits;
|
||||
} WGPUDeviceDescriptor;
|
||||
|
||||
typedef struct {
|
||||
|
||||
+84
-94
@@ -15,7 +15,6 @@ typedef enum {
|
||||
WGPUAddressMode_ClampToEdge = 0,
|
||||
WGPUAddressMode_Repeat = 1,
|
||||
WGPUAddressMode_MirrorRepeat = 2,
|
||||
WGPUAddressMode_ClampToBorderColor = 3,
|
||||
} WGPUAddressMode;
|
||||
|
||||
typedef enum {
|
||||
@@ -25,6 +24,7 @@ typedef enum {
|
||||
WGPUBindingType_StorageBuffer = 3,
|
||||
WGPUBindingType_UniformBufferDynamic = 4,
|
||||
WGPUBindingType_StorageBufferDynamic = 5,
|
||||
WGPUBindingType_StorageTexture = 10,
|
||||
} WGPUBindingType;
|
||||
|
||||
typedef enum {
|
||||
@@ -51,12 +51,6 @@ typedef enum {
|
||||
WGPUBlendOperation_Max = 4,
|
||||
} WGPUBlendOperation;
|
||||
|
||||
typedef enum {
|
||||
WGPUBorderColor_TransparentBlack = 0,
|
||||
WGPUBorderColor_OpaqueBlack = 1,
|
||||
WGPUBorderColor_OpaqueWhite = 2,
|
||||
} WGPUBorderColor;
|
||||
|
||||
typedef enum {
|
||||
WGPUBufferMapAsyncStatus_Success,
|
||||
WGPUBufferMapAsyncStatus_Error,
|
||||
@@ -202,42 +196,23 @@ typedef enum {
|
||||
} WGPUTextureViewDimension;
|
||||
|
||||
typedef enum {
|
||||
WGPUVertexFormat_Uchar = 0,
|
||||
WGPUVertexFormat_Uchar2 = 1,
|
||||
WGPUVertexFormat_Uchar3 = 2,
|
||||
WGPUVertexFormat_Uchar4 = 3,
|
||||
WGPUVertexFormat_Char = 4,
|
||||
WGPUVertexFormat_Char2 = 5,
|
||||
WGPUVertexFormat_Char3 = 6,
|
||||
WGPUVertexFormat_Char4 = 7,
|
||||
WGPUVertexFormat_UcharNorm = 8,
|
||||
WGPUVertexFormat_Uchar2Norm = 9,
|
||||
WGPUVertexFormat_Uchar3Norm = 10,
|
||||
WGPUVertexFormat_Uchar4Norm = 11,
|
||||
WGPUVertexFormat_Uchar4NormBgra = 12,
|
||||
WGPUVertexFormat_CharNorm = 13,
|
||||
WGPUVertexFormat_Char2Norm = 14,
|
||||
WGPUVertexFormat_Char3Norm = 15,
|
||||
WGPUVertexFormat_Char4Norm = 16,
|
||||
WGPUVertexFormat_Ushort = 17,
|
||||
WGPUVertexFormat_Ushort2 = 18,
|
||||
WGPUVertexFormat_Ushort3 = 19,
|
||||
WGPUVertexFormat_Ushort4 = 20,
|
||||
WGPUVertexFormat_Short = 21,
|
||||
WGPUVertexFormat_Short2 = 22,
|
||||
WGPUVertexFormat_Short3 = 23,
|
||||
WGPUVertexFormat_Short4 = 24,
|
||||
WGPUVertexFormat_UshortNorm = 25,
|
||||
WGPUVertexFormat_Ushort2Norm = 26,
|
||||
WGPUVertexFormat_Ushort3Norm = 27,
|
||||
WGPUVertexFormat_Ushort4Norm = 28,
|
||||
WGPUVertexFormat_ShortNorm = 29,
|
||||
WGPUVertexFormat_Short2Norm = 30,
|
||||
WGPUVertexFormat_Short3Norm = 31,
|
||||
WGPUVertexFormat_Short4Norm = 32,
|
||||
WGPUVertexFormat_Half = 33,
|
||||
WGPUVertexFormat_Half2 = 34,
|
||||
WGPUVertexFormat_Half3 = 35,
|
||||
WGPUVertexFormat_Half4 = 36,
|
||||
WGPUVertexFormat_Float = 37,
|
||||
WGPUVertexFormat_Float2 = 38,
|
||||
@@ -272,14 +247,21 @@ typedef struct {
|
||||
bool anisotropic_filtering;
|
||||
} WGPUExtensions;
|
||||
|
||||
typedef struct {
|
||||
uint32_t max_bind_groups;
|
||||
} WGPULimits;
|
||||
|
||||
typedef struct {
|
||||
WGPUExtensions extensions;
|
||||
WGPULimits limits;
|
||||
} WGPUDeviceDescriptor;
|
||||
|
||||
typedef WGPUId WGPUBindGroupId;
|
||||
|
||||
typedef WGPUId WGPUBufferId;
|
||||
|
||||
typedef uint64_t WGPUBufferAddress;
|
||||
|
||||
typedef void (*WGPUBufferMapReadCallback)(WGPUBufferMapAsyncStatus status, const uint8_t *data, uint8_t *userdata);
|
||||
|
||||
typedef void (*WGPUBufferMapWriteCallback)(WGPUBufferMapAsyncStatus status, uint8_t *data, uint8_t *userdata);
|
||||
@@ -288,7 +270,7 @@ typedef WGPUId WGPUCommandBufferId;
|
||||
|
||||
typedef struct {
|
||||
WGPUBufferId buffer;
|
||||
uint32_t offset;
|
||||
WGPUBufferAddress offset;
|
||||
uint32_t row_pitch;
|
||||
uint32_t image_height;
|
||||
} WGPUBufferCopyView;
|
||||
@@ -300,11 +282,12 @@ typedef struct {
|
||||
float y;
|
||||
float z;
|
||||
} WGPUOrigin3d;
|
||||
#define WGPUOrigin3d_ZERO (WGPUOrigin3d){ .x = 0, .y = 0, .z = 0 }
|
||||
|
||||
typedef struct {
|
||||
WGPUTextureId texture;
|
||||
uint32_t level;
|
||||
uint32_t slice;
|
||||
uint32_t mip_level;
|
||||
uint32_t array_layer;
|
||||
WGPUOrigin3d origin;
|
||||
} WGPUTextureCopyView;
|
||||
|
||||
@@ -337,6 +320,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
WGPUTextureViewId attachment;
|
||||
const WGPUTextureViewId *resolve_target;
|
||||
WGPULoadOp load_op;
|
||||
WGPUStoreOp store_op;
|
||||
WGPUColor clear_color;
|
||||
@@ -366,8 +350,8 @@ typedef WGPUId WGPUBindGroupLayoutId;
|
||||
|
||||
typedef struct {
|
||||
WGPUBufferId buffer;
|
||||
uint32_t offset;
|
||||
uint32_t size;
|
||||
WGPUBufferAddress offset;
|
||||
WGPUBufferAddress size;
|
||||
} WGPUBufferBinding;
|
||||
|
||||
typedef WGPUId WGPUSamplerId;
|
||||
@@ -402,22 +386,23 @@ typedef struct {
|
||||
typedef struct {
|
||||
uint32_t binding;
|
||||
WGPUBindingResource resource;
|
||||
} WGPUBinding;
|
||||
} WGPUBindGroupBinding;
|
||||
|
||||
typedef struct {
|
||||
WGPUBindGroupLayoutId layout;
|
||||
const WGPUBinding *bindings;
|
||||
const WGPUBindGroupBinding *bindings;
|
||||
uintptr_t bindings_length;
|
||||
} WGPUBindGroupDescriptor;
|
||||
|
||||
typedef uint32_t WGPUShaderStageFlags;
|
||||
#define WGPUShaderStageFlags_VERTEX 1
|
||||
#define WGPUShaderStageFlags_FRAGMENT 2
|
||||
#define WGPUShaderStageFlags_COMPUTE 4
|
||||
typedef uint32_t WGPUShaderStage;
|
||||
#define WGPUShaderStage_NONE 0
|
||||
#define WGPUShaderStage_VERTEX 1
|
||||
#define WGPUShaderStage_FRAGMENT 2
|
||||
#define WGPUShaderStage_COMPUTE 4
|
||||
|
||||
typedef struct {
|
||||
uint32_t binding;
|
||||
WGPUShaderStageFlags visibility;
|
||||
WGPUShaderStage visibility;
|
||||
WGPUBindingType ty;
|
||||
} WGPUBindGroupLayoutBinding;
|
||||
|
||||
@@ -426,21 +411,21 @@ typedef struct {
|
||||
uintptr_t bindings_length;
|
||||
} WGPUBindGroupLayoutDescriptor;
|
||||
|
||||
typedef uint32_t WGPUBufferUsageFlags;
|
||||
#define WGPUBufferUsageFlags_MAP_READ 1
|
||||
#define WGPUBufferUsageFlags_MAP_WRITE 2
|
||||
#define WGPUBufferUsageFlags_TRANSFER_SRC 4
|
||||
#define WGPUBufferUsageFlags_TRANSFER_DST 8
|
||||
#define WGPUBufferUsageFlags_INDEX 16
|
||||
#define WGPUBufferUsageFlags_VERTEX 32
|
||||
#define WGPUBufferUsageFlags_UNIFORM 64
|
||||
#define WGPUBufferUsageFlags_STORAGE 128
|
||||
#define WGPUBufferUsageFlags_NONE 0
|
||||
#define WGPUBufferUsageFlags_WRITE_ALL 2 + 8 + 128
|
||||
typedef uint32_t WGPUBufferUsage;
|
||||
#define WGPUBufferUsage_MAP_READ 1
|
||||
#define WGPUBufferUsage_MAP_WRITE 2
|
||||
#define WGPUBufferUsage_TRANSFER_SRC 4
|
||||
#define WGPUBufferUsage_TRANSFER_DST 8
|
||||
#define WGPUBufferUsage_INDEX 16
|
||||
#define WGPUBufferUsage_VERTEX 32
|
||||
#define WGPUBufferUsage_UNIFORM 64
|
||||
#define WGPUBufferUsage_STORAGE 128
|
||||
#define WGPUBufferUsage_NONE 0
|
||||
#define WGPUBufferUsage_WRITE_ALL 2 + 8 + 128
|
||||
|
||||
typedef struct {
|
||||
uint32_t size;
|
||||
WGPUBufferUsageFlags usage;
|
||||
WGPUBufferAddress size;
|
||||
WGPUBufferUsage usage;
|
||||
} WGPUBufferDescriptor;
|
||||
|
||||
typedef struct {
|
||||
@@ -451,9 +436,11 @@ typedef WGPUId WGPUPipelineLayoutId;
|
||||
|
||||
typedef WGPUId WGPUShaderModuleId;
|
||||
|
||||
typedef const char *WGPURawString;
|
||||
|
||||
typedef struct {
|
||||
WGPUShaderModuleId module;
|
||||
const char *entry_point;
|
||||
WGPURawString entry_point;
|
||||
} WGPUPipelineStageDescriptor;
|
||||
|
||||
typedef struct {
|
||||
@@ -482,19 +469,19 @@ typedef struct {
|
||||
WGPUBlendOperation operation;
|
||||
} WGPUBlendDescriptor;
|
||||
|
||||
typedef uint32_t WGPUColorWriteFlags;
|
||||
#define WGPUColorWriteFlags_RED 1
|
||||
#define WGPUColorWriteFlags_GREEN 2
|
||||
#define WGPUColorWriteFlags_BLUE 4
|
||||
#define WGPUColorWriteFlags_ALPHA 8
|
||||
#define WGPUColorWriteFlags_COLOR 7
|
||||
#define WGPUColorWriteFlags_ALL 15
|
||||
typedef uint32_t WGPUColorWrite;
|
||||
#define WGPUColorWrite_RED 1
|
||||
#define WGPUColorWrite_GREEN 2
|
||||
#define WGPUColorWrite_BLUE 4
|
||||
#define WGPUColorWrite_ALPHA 8
|
||||
#define WGPUColorWrite_COLOR 7
|
||||
#define WGPUColorWrite_ALL 15
|
||||
|
||||
typedef struct {
|
||||
WGPUTextureFormat format;
|
||||
WGPUBlendDescriptor alpha;
|
||||
WGPUBlendDescriptor color;
|
||||
WGPUColorWriteFlags write_mask;
|
||||
WGPUBlendDescriptor alpha_blend;
|
||||
WGPUBlendDescriptor color_blend;
|
||||
WGPUColorWrite write_mask;
|
||||
} WGPUColorStateDescriptor;
|
||||
|
||||
typedef struct {
|
||||
@@ -514,16 +501,16 @@ typedef struct {
|
||||
uint32_t stencil_write_mask;
|
||||
} WGPUDepthStencilStateDescriptor;
|
||||
|
||||
typedef uint32_t WGPUShaderAttributeIndex;
|
||||
typedef uint32_t WGPUShaderLocation;
|
||||
|
||||
typedef struct {
|
||||
uint32_t offset;
|
||||
WGPUBufferAddress offset;
|
||||
WGPUVertexFormat format;
|
||||
WGPUShaderAttributeIndex attribute_index;
|
||||
WGPUShaderLocation shader_location;
|
||||
} WGPUVertexAttributeDescriptor;
|
||||
|
||||
typedef struct {
|
||||
uint32_t stride;
|
||||
WGPUBufferAddress stride;
|
||||
WGPUInputStepMode step_mode;
|
||||
const WGPUVertexAttributeDescriptor *attributes;
|
||||
uintptr_t attributes_count;
|
||||
@@ -533,33 +520,31 @@ typedef struct {
|
||||
WGPUIndexFormat index_format;
|
||||
const WGPUVertexBufferDescriptor *vertex_buffers;
|
||||
uintptr_t vertex_buffers_count;
|
||||
} WGPUVertexBufferStateDescriptor;
|
||||
} WGPUVertexInputDescriptor;
|
||||
|
||||
typedef struct {
|
||||
WGPUPipelineLayoutId layout;
|
||||
WGPUPipelineStageDescriptor vertex_stage;
|
||||
WGPUPipelineStageDescriptor fragment_stage;
|
||||
const 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;
|
||||
WGPUVertexInputDescriptor vertex_input;
|
||||
uint32_t sample_count;
|
||||
} WGPURenderPipelineDescriptor;
|
||||
|
||||
typedef struct {
|
||||
WGPUAddressMode r_address_mode;
|
||||
WGPUAddressMode s_address_mode;
|
||||
WGPUAddressMode t_address_mode;
|
||||
WGPUAddressMode address_mode_u;
|
||||
WGPUAddressMode address_mode_v;
|
||||
WGPUAddressMode address_mode_w;
|
||||
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 {
|
||||
@@ -575,18 +560,18 @@ typedef WGPUId WGPUSurfaceId;
|
||||
|
||||
typedef WGPUSurfaceId WGPUSwapChainId;
|
||||
|
||||
typedef uint32_t WGPUTextureUsageFlags;
|
||||
#define WGPUTextureUsageFlags_TRANSFER_SRC 1
|
||||
#define WGPUTextureUsageFlags_TRANSFER_DST 2
|
||||
#define WGPUTextureUsageFlags_SAMPLED 4
|
||||
#define WGPUTextureUsageFlags_STORAGE 8
|
||||
#define WGPUTextureUsageFlags_OUTPUT_ATTACHMENT 16
|
||||
#define WGPUTextureUsageFlags_NONE 0
|
||||
#define WGPUTextureUsageFlags_WRITE_ALL 2 + 8 + 16
|
||||
#define WGPUTextureUsageFlags_UNINITIALIZED 65535
|
||||
typedef uint32_t WGPUTextureUsage;
|
||||
#define WGPUTextureUsage_TRANSFER_SRC 1
|
||||
#define WGPUTextureUsage_TRANSFER_DST 2
|
||||
#define WGPUTextureUsage_SAMPLED 4
|
||||
#define WGPUTextureUsage_STORAGE 8
|
||||
#define WGPUTextureUsage_OUTPUT_ATTACHMENT 16
|
||||
#define WGPUTextureUsage_NONE 0
|
||||
#define WGPUTextureUsage_WRITE_ALL 2 + 8 + 16
|
||||
#define WGPUTextureUsage_UNINITIALIZED 65535
|
||||
|
||||
typedef struct {
|
||||
WGPUTextureUsageFlags usage;
|
||||
WGPUTextureUsage usage;
|
||||
WGPUTextureFormat format;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
@@ -594,10 +579,12 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
WGPUExtent3d size;
|
||||
uint32_t array_size;
|
||||
uint32_t array_layer_count;
|
||||
uint32_t mip_level_count;
|
||||
uint32_t sample_count;
|
||||
WGPUTextureDimension dimension;
|
||||
WGPUTextureFormat format;
|
||||
WGPUTextureUsageFlags usage;
|
||||
WGPUTextureUsage usage;
|
||||
} WGPUTextureDescriptor;
|
||||
|
||||
typedef WGPUDeviceId WGPUQueueId;
|
||||
@@ -631,7 +618,8 @@ typedef struct {
|
||||
|
||||
|
||||
#if defined(WGPU_LOCAL)
|
||||
WGPUDeviceId wgpu_adapter_create_device(WGPUAdapterId adapter_id, const WGPUDeviceDescriptor *desc);
|
||||
WGPUDeviceId wgpu_adapter_request_device(WGPUAdapterId adapter_id,
|
||||
const WGPUDeviceDescriptor *desc);
|
||||
#endif
|
||||
|
||||
void wgpu_bind_group_destroy(WGPUBindGroupId bind_group_id);
|
||||
@@ -639,14 +627,14 @@ void wgpu_bind_group_destroy(WGPUBindGroupId bind_group_id);
|
||||
void wgpu_buffer_destroy(WGPUBufferId buffer_id);
|
||||
|
||||
void wgpu_buffer_map_read_async(WGPUBufferId buffer_id,
|
||||
uint32_t start,
|
||||
uint32_t size,
|
||||
WGPUBufferAddress start,
|
||||
WGPUBufferAddress size,
|
||||
WGPUBufferMapReadCallback callback,
|
||||
uint8_t *userdata);
|
||||
|
||||
void wgpu_buffer_map_write_async(WGPUBufferId buffer_id,
|
||||
uint32_t start,
|
||||
uint32_t size,
|
||||
WGPUBufferAddress start,
|
||||
WGPUBufferAddress size,
|
||||
WGPUBufferMapWriteCallback callback,
|
||||
uint8_t *userdata);
|
||||
|
||||
@@ -654,10 +642,10 @@ void wgpu_buffer_unmap(WGPUBufferId buffer_id);
|
||||
|
||||
void wgpu_command_buffer_copy_buffer_to_buffer(WGPUCommandBufferId command_buffer_id,
|
||||
WGPUBufferId src,
|
||||
uint32_t src_offset,
|
||||
WGPUBufferAddress src_offset,
|
||||
WGPUBufferId dst,
|
||||
uint32_t dst_offset,
|
||||
uint32_t size);
|
||||
WGPUBufferAddress dst_offset,
|
||||
WGPUBufferAddress size);
|
||||
|
||||
void wgpu_command_buffer_copy_buffer_to_texture(WGPUCommandBufferId command_buffer_id,
|
||||
const WGPUBufferCopyView *source,
|
||||
@@ -827,6 +815,8 @@ void wgpu_render_pass_set_scissor_rect(WGPURenderPassId pass_id,
|
||||
uint32_t w,
|
||||
uint32_t h);
|
||||
|
||||
void wgpu_render_pass_set_stencil_reference(WGPURenderPassId pass_id, uint32_t value);
|
||||
|
||||
void wgpu_render_pass_set_vertex_buffers(WGPURenderPassId pass_id,
|
||||
const WGPUBufferId *buffer_ptr,
|
||||
const uint32_t *offset_ptr,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::{track::TrackerSet, BindGroupLayoutId, BufferId, LifeGuard, SamplerId, TextureViewId};
|
||||
use crate::{track::TrackerSet, BindGroupLayoutId, BufferId, LifeGuard, SamplerId, TextureViewId, BufferAddress};
|
||||
|
||||
use arrayvec::ArrayVec;
|
||||
use bitflags::bitflags;
|
||||
@@ -7,7 +7,8 @@ pub const MAX_BIND_GROUPS: usize = 4;
|
||||
|
||||
bitflags! {
|
||||
#[repr(transparent)]
|
||||
pub struct ShaderStageFlags: u32 {
|
||||
pub struct ShaderStage: u32 {
|
||||
const NONE = 0;
|
||||
const VERTEX = 1;
|
||||
const FRAGMENT = 2;
|
||||
const COMPUTE = 4;
|
||||
@@ -23,13 +24,14 @@ pub enum BindingType {
|
||||
StorageBuffer = 3,
|
||||
UniformBufferDynamic = 4,
|
||||
StorageBufferDynamic = 5,
|
||||
StorageTexture = 10,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Debug, Hash)]
|
||||
pub struct BindGroupLayoutBinding {
|
||||
pub binding: u32,
|
||||
pub visibility: ShaderStageFlags,
|
||||
pub visibility: ShaderStage,
|
||||
pub ty: BindingType,
|
||||
}
|
||||
|
||||
@@ -59,8 +61,8 @@ pub struct PipelineLayout<B: hal::Backend> {
|
||||
#[repr(C)]
|
||||
pub struct BufferBinding {
|
||||
pub buffer: BufferId,
|
||||
pub offset: u32,
|
||||
pub size: u32,
|
||||
pub offset: BufferAddress,
|
||||
pub size: BufferAddress,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
@@ -71,7 +73,7 @@ pub enum BindingResource {
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct Binding {
|
||||
pub struct BindGroupBinding {
|
||||
pub binding: u32,
|
||||
pub resource: BindingResource,
|
||||
}
|
||||
@@ -79,7 +81,7 @@ pub struct Binding {
|
||||
#[repr(C)]
|
||||
pub struct BindGroupDescriptor {
|
||||
pub layout: BindGroupLayoutId,
|
||||
pub bindings: *const Binding,
|
||||
pub bindings: *const BindGroupBinding,
|
||||
pub bindings_length: usize,
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ use crate::{
|
||||
Stored,
|
||||
TextureHandle,
|
||||
TextureId,
|
||||
TextureUsageFlags,
|
||||
TextureUsage,
|
||||
TextureViewId,
|
||||
};
|
||||
#[cfg(feature = "local")]
|
||||
@@ -62,6 +62,7 @@ pub enum StoreOp {
|
||||
#[repr(C)]
|
||||
pub struct RenderPassColorAttachmentDescriptor<T> {
|
||||
pub attachment: T,
|
||||
pub resolve_target: *const TextureViewId,
|
||||
pub load_op: LoadOp,
|
||||
pub store_op: StoreOp,
|
||||
pub clear_color: Color,
|
||||
@@ -202,7 +203,7 @@ pub fn command_encoder_begin_render_pass(
|
||||
let query = trackers.textures.query(
|
||||
view.texture_id.value,
|
||||
&view.texture_id.ref_count,
|
||||
TextureUsageFlags::empty(),
|
||||
TextureUsage::empty(),
|
||||
);
|
||||
let (_, layout) = conv::map_texture_state(
|
||||
query.usage,
|
||||
@@ -243,7 +244,7 @@ pub fn command_encoder_begin_render_pass(
|
||||
let query = trackers.textures.query(
|
||||
view.texture_id.value,
|
||||
&view.texture_id.ref_count,
|
||||
TextureUsageFlags::empty(),
|
||||
TextureUsage::empty(),
|
||||
);
|
||||
let (_, layout) = conv::map_texture_state(query.usage, hal::format::Aspects::COLOR);
|
||||
hal::pass::Attachment {
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::{
|
||||
device::RenderPassContext,
|
||||
hub::HUB,
|
||||
pipeline::{IndexFormat, PipelineFlags},
|
||||
resource::BufferUsageFlags,
|
||||
resource::BufferUsage,
|
||||
track::{Stitch, TrackerSet},
|
||||
BindGroupId,
|
||||
BufferId,
|
||||
@@ -131,7 +131,7 @@ pub extern "C" fn wgpu_render_pass_set_index_buffer(
|
||||
let buffer = pass
|
||||
.trackers
|
||||
.buffers
|
||||
.get_with_extended_usage(&*buffer_guard, buffer_id, BufferUsageFlags::INDEX)
|
||||
.get_with_extended_usage(&*buffer_guard, buffer_id, BufferUsage::INDEX)
|
||||
.unwrap();
|
||||
|
||||
let view = hal::buffer::IndexBufferView {
|
||||
@@ -163,7 +163,7 @@ pub extern "C" fn wgpu_render_pass_set_vertex_buffers(
|
||||
for &id in buffers {
|
||||
pass.trackers
|
||||
.buffers
|
||||
.get_with_extended_usage(&*buffer_guard, id, BufferUsageFlags::VERTEX)
|
||||
.get_with_extended_usage(&*buffer_guard, id, BufferUsage::VERTEX)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ pub extern "C" fn wgpu_render_pass_set_pipeline(
|
||||
let buffer = pass
|
||||
.trackers
|
||||
.buffers
|
||||
.get_with_extended_usage(&*buffer_guard, buffer_id, BufferUsageFlags::INDEX)
|
||||
.get_with_extended_usage(&*buffer_guard, buffer_id, BufferUsage::INDEX)
|
||||
.unwrap();
|
||||
|
||||
let view = hal::buffer::IndexBufferView {
|
||||
@@ -355,6 +355,19 @@ pub extern "C" fn wgpu_render_pass_set_blend_color(pass_id: RenderPassId, color:
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_set_stencil_reference(pass_id: RenderPassId, value: u32) {
|
||||
let mut pass_guard = HUB.render_passes.write();
|
||||
let pass = &mut pass_guard[pass_id];
|
||||
|
||||
//TODO
|
||||
//pass.blend_color_status = BlendColorStatus::Set;
|
||||
|
||||
unsafe {
|
||||
pass.raw.set_stencil_reference(hal::pso::Face::all(), value);
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_render_pass_set_scissor_rect(
|
||||
pass_id: RenderPassId,
|
||||
|
||||
@@ -4,13 +4,14 @@ use crate::{
|
||||
hub::HUB,
|
||||
resource::TexturePlacement,
|
||||
swap_chain::SwapChainLink,
|
||||
BufferAddress,
|
||||
BufferId,
|
||||
BufferUsageFlags,
|
||||
BufferUsage,
|
||||
CommandBufferId,
|
||||
Extent3d,
|
||||
Origin3d,
|
||||
TextureId,
|
||||
TextureUsageFlags,
|
||||
TextureUsage,
|
||||
};
|
||||
|
||||
use copyless::VecHelper as _;
|
||||
@@ -23,7 +24,7 @@ const BITS_PER_BYTE: u32 = 8;
|
||||
#[repr(C)]
|
||||
pub struct BufferCopyView {
|
||||
pub buffer: BufferId,
|
||||
pub offset: u32,
|
||||
pub offset: BufferAddress,
|
||||
pub row_pitch: u32,
|
||||
pub image_height: u32,
|
||||
}
|
||||
@@ -31,20 +32,19 @@ pub struct BufferCopyView {
|
||||
#[repr(C)]
|
||||
pub struct TextureCopyView {
|
||||
pub texture: TextureId,
|
||||
pub level: u32,
|
||||
pub slice: u32,
|
||||
pub mip_level: u32,
|
||||
pub array_layer: u32,
|
||||
pub origin: Origin3d,
|
||||
//TODO: pub aspect: TextureAspect,
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_command_buffer_copy_buffer_to_buffer(
|
||||
command_buffer_id: CommandBufferId,
|
||||
src: BufferId,
|
||||
src_offset: u32,
|
||||
src_offset: BufferAddress,
|
||||
dst: BufferId,
|
||||
dst_offset: u32,
|
||||
size: u32,
|
||||
dst_offset: BufferAddress,
|
||||
size: BufferAddress,
|
||||
) {
|
||||
let mut cmb_guard = HUB.command_buffers.write();
|
||||
let cmb = &mut cmb_guard[command_buffer_id];
|
||||
@@ -53,7 +53,7 @@ pub extern "C" fn wgpu_command_buffer_copy_buffer_to_buffer(
|
||||
let (src_buffer, src_usage) = cmb
|
||||
.trackers
|
||||
.buffers
|
||||
.get_with_replaced_usage(&*buffer_guard, src, BufferUsageFlags::TRANSFER_SRC)
|
||||
.get_with_replaced_usage(&*buffer_guard, src, BufferUsage::TRANSFER_SRC)
|
||||
.unwrap();
|
||||
let src_barrier = src_usage.map(|old| hal::memory::Barrier::Buffer {
|
||||
states: conv::map_buffer_state(old)..hal::buffer::Access::TRANSFER_READ,
|
||||
@@ -65,7 +65,7 @@ pub extern "C" fn wgpu_command_buffer_copy_buffer_to_buffer(
|
||||
let (dst_buffer, dst_usage) = cmb
|
||||
.trackers
|
||||
.buffers
|
||||
.get_with_replaced_usage(&*buffer_guard, dst, BufferUsageFlags::TRANSFER_DST)
|
||||
.get_with_replaced_usage(&*buffer_guard, dst, BufferUsage::TRANSFER_DST)
|
||||
.unwrap();
|
||||
let dst_barrier = dst_usage.map(|old| hal::memory::Barrier::Buffer {
|
||||
states: conv::map_buffer_state(old)..hal::buffer::Access::TRANSFER_WRITE,
|
||||
@@ -75,9 +75,9 @@ pub extern "C" fn wgpu_command_buffer_copy_buffer_to_buffer(
|
||||
});
|
||||
|
||||
let region = hal::command::BufferCopy {
|
||||
src: src_offset as hal::buffer::Offset,
|
||||
dst: dst_offset as hal::buffer::Offset,
|
||||
size: size as hal::buffer::Offset,
|
||||
src: src_offset,
|
||||
dst: dst_offset,
|
||||
size,
|
||||
};
|
||||
let cmb_raw = cmb.raw.last_mut().unwrap();
|
||||
unsafe {
|
||||
@@ -108,7 +108,7 @@ pub extern "C" fn wgpu_command_buffer_copy_buffer_to_texture(
|
||||
.get_with_replaced_usage(
|
||||
&*buffer_guard,
|
||||
source.buffer,
|
||||
BufferUsageFlags::TRANSFER_SRC,
|
||||
BufferUsage::TRANSFER_SRC,
|
||||
)
|
||||
.unwrap();
|
||||
let src_barrier = src_usage.map(|old| hal::memory::Barrier::Buffer {
|
||||
@@ -124,11 +124,11 @@ pub extern "C" fn wgpu_command_buffer_copy_buffer_to_texture(
|
||||
.get_with_replaced_usage(
|
||||
&*texture_guard,
|
||||
destination.texture,
|
||||
TextureUsageFlags::TRANSFER_DST,
|
||||
TextureUsage::TRANSFER_DST,
|
||||
)
|
||||
.unwrap();
|
||||
let aspects = dst_texture.full_range.aspects;
|
||||
let dst_texture_state = conv::map_texture_state(TextureUsageFlags::TRANSFER_DST, aspects);
|
||||
let dst_texture_state = conv::map_texture_state(TextureUsage::TRANSFER_DST, aspects);
|
||||
let dst_barrier = dst_usage.map(|old| hal::memory::Barrier::Image {
|
||||
states: conv::map_texture_state(old, aspects)..dst_texture_state,
|
||||
target: &dst_texture.raw,
|
||||
@@ -151,13 +151,13 @@ pub extern "C" fn wgpu_command_buffer_copy_buffer_to_texture(
|
||||
let buffer_width = source.row_pitch / bytes_per_texel;
|
||||
assert_eq!(source.row_pitch % bytes_per_texel, 0);
|
||||
let region = hal::command::BufferImageCopy {
|
||||
buffer_offset: source.offset as hal::buffer::Offset,
|
||||
buffer_offset: source.offset,
|
||||
buffer_width,
|
||||
buffer_height: source.image_height,
|
||||
image_layers: hal::image::SubresourceLayers {
|
||||
aspects, //TODO
|
||||
level: destination.level as hal::image::Level,
|
||||
layers: destination.slice as u16..destination.slice as u16 + 1,
|
||||
level: destination.mip_level as hal::image::Level,
|
||||
layers: destination.array_layer as u16 .. destination.array_layer as u16 + 1,
|
||||
},
|
||||
image_offset: conv::map_origin(destination.origin),
|
||||
image_extent: conv::map_extent(copy_size),
|
||||
@@ -197,11 +197,11 @@ pub extern "C" fn wgpu_command_buffer_copy_texture_to_buffer(
|
||||
.get_with_replaced_usage(
|
||||
&*texture_guard,
|
||||
source.texture,
|
||||
TextureUsageFlags::TRANSFER_SRC,
|
||||
TextureUsage::TRANSFER_SRC,
|
||||
)
|
||||
.unwrap();
|
||||
let aspects = src_texture.full_range.aspects;
|
||||
let src_texture_state = conv::map_texture_state(TextureUsageFlags::TRANSFER_SRC, aspects);
|
||||
let src_texture_state = conv::map_texture_state(TextureUsage::TRANSFER_SRC, aspects);
|
||||
let src_barrier = src_usage.map(|old| hal::memory::Barrier::Image {
|
||||
states: conv::map_texture_state(old, aspects)..src_texture_state,
|
||||
target: &src_texture.raw,
|
||||
@@ -220,7 +220,7 @@ pub extern "C" fn wgpu_command_buffer_copy_texture_to_buffer(
|
||||
.get_with_replaced_usage(
|
||||
&*buffer_guard,
|
||||
destination.buffer,
|
||||
BufferUsageFlags::TRANSFER_DST,
|
||||
BufferUsage::TRANSFER_DST,
|
||||
)
|
||||
.unwrap();
|
||||
let dst_barrier = dst_usage.map(|old| hal::memory::Barrier::Buffer {
|
||||
@@ -237,13 +237,13 @@ pub extern "C" fn wgpu_command_buffer_copy_texture_to_buffer(
|
||||
let buffer_width = destination.row_pitch / bytes_per_texel;
|
||||
assert_eq!(destination.row_pitch % bytes_per_texel, 0);
|
||||
let region = hal::command::BufferImageCopy {
|
||||
buffer_offset: destination.offset as hal::buffer::Offset,
|
||||
buffer_offset: destination.offset,
|
||||
buffer_width,
|
||||
buffer_height: destination.image_height,
|
||||
image_layers: hal::image::SubresourceLayers {
|
||||
aspects, //TODO
|
||||
level: source.level as hal::image::Level,
|
||||
layers: source.slice as u16..source.slice as u16 + 1,
|
||||
level: source.mip_level as hal::image::Level,
|
||||
layers: source.array_layer as u16 .. source.array_layer as u16 + 1,
|
||||
},
|
||||
image_offset: conv::map_origin(source.origin),
|
||||
image_extent: conv::map_extent(copy_size),
|
||||
@@ -282,7 +282,7 @@ pub extern "C" fn wgpu_command_buffer_copy_texture_to_texture(
|
||||
.get_with_replaced_usage(
|
||||
&*texture_guard,
|
||||
source.texture,
|
||||
TextureUsageFlags::TRANSFER_SRC,
|
||||
TextureUsage::TRANSFER_SRC,
|
||||
)
|
||||
.unwrap();
|
||||
let (dst_texture, dst_usage) = cmb
|
||||
@@ -291,13 +291,13 @@ pub extern "C" fn wgpu_command_buffer_copy_texture_to_texture(
|
||||
.get_with_replaced_usage(
|
||||
&*texture_guard,
|
||||
destination.texture,
|
||||
TextureUsageFlags::TRANSFER_DST,
|
||||
TextureUsage::TRANSFER_DST,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let aspects = src_texture.full_range.aspects & dst_texture.full_range.aspects;
|
||||
let src_texture_state = conv::map_texture_state(TextureUsageFlags::TRANSFER_SRC, aspects);
|
||||
let dst_texture_state = conv::map_texture_state(TextureUsageFlags::TRANSFER_DST, aspects);
|
||||
let src_texture_state = conv::map_texture_state(TextureUsage::TRANSFER_SRC, aspects);
|
||||
let dst_texture_state = conv::map_texture_state(TextureUsage::TRANSFER_DST, aspects);
|
||||
|
||||
let src_barrier = src_usage.map(|old| hal::memory::Barrier::Image {
|
||||
states: conv::map_texture_state(old, aspects)..src_texture_state,
|
||||
@@ -323,14 +323,14 @@ pub extern "C" fn wgpu_command_buffer_copy_texture_to_texture(
|
||||
let region = hal::command::ImageCopy {
|
||||
src_subresource: hal::image::SubresourceLayers {
|
||||
aspects,
|
||||
level: source.level as hal::image::Level,
|
||||
layers: source.slice as u16..source.slice as u16 + 1,
|
||||
level: source.mip_level as hal::image::Level,
|
||||
layers: source.array_layer as u16 .. source.array_layer as u16 + 1,
|
||||
},
|
||||
src_offset: conv::map_origin(source.origin),
|
||||
dst_subresource: hal::image::SubresourceLayers {
|
||||
aspects,
|
||||
level: destination.level as hal::image::Level,
|
||||
layers: destination.slice as u16..destination.slice as u16 + 1,
|
||||
level: destination.mip_level as hal::image::Level,
|
||||
layers: destination.array_layer as u16 .. destination.array_layer as u16 + 1,
|
||||
},
|
||||
dst_offset: conv::map_origin(destination.origin),
|
||||
extent: conv::map_extent(copy_size),
|
||||
|
||||
+25
-44
@@ -1,9 +1,9 @@
|
||||
use crate::{binding_model, command, pipeline, resource, Color, Extent3d, Origin3d};
|
||||
|
||||
pub fn map_buffer_usage(
|
||||
usage: resource::BufferUsageFlags,
|
||||
usage: resource::BufferUsage,
|
||||
) -> (hal::buffer::Usage, hal::memory::Properties) {
|
||||
use crate::resource::BufferUsageFlags as W;
|
||||
use crate::resource::BufferUsage as W;
|
||||
use hal::buffer::Usage as U;
|
||||
use hal::memory::Properties as P;
|
||||
|
||||
@@ -39,10 +39,10 @@ pub fn map_buffer_usage(
|
||||
}
|
||||
|
||||
pub fn map_texture_usage(
|
||||
usage: resource::TextureUsageFlags,
|
||||
usage: resource::TextureUsage,
|
||||
aspects: hal::format::Aspects,
|
||||
) -> hal::image::Usage {
|
||||
use crate::resource::TextureUsageFlags as W;
|
||||
use crate::resource::TextureUsage as W;
|
||||
use hal::image::Usage as U;
|
||||
|
||||
let mut value = U::empty();
|
||||
@@ -65,7 +65,7 @@ pub fn map_texture_usage(
|
||||
value |= U::COLOR_ATTACHMENT;
|
||||
}
|
||||
}
|
||||
// Note: TextureUsageFlags::Present does not need to be handled explicitly
|
||||
// Note: TextureUsage::Present does not need to be handled explicitly
|
||||
// TODO: HAL Transient Attachment, HAL Input Attachment
|
||||
value
|
||||
}
|
||||
@@ -77,6 +77,7 @@ pub fn map_binding_type(binding_ty: binding_model::BindingType) -> hal::pso::Des
|
||||
UniformBuffer => H::UniformBuffer,
|
||||
Sampler => H::Sampler,
|
||||
SampledTexture => H::SampledImage,
|
||||
StorageTexture => H::StorageImage,
|
||||
StorageBuffer => H::StorageBuffer,
|
||||
UniformBufferDynamic => H::UniformBufferDynamic,
|
||||
StorageBufferDynamic => H::StorageBufferDynamic,
|
||||
@@ -84,19 +85,19 @@ pub fn map_binding_type(binding_ty: binding_model::BindingType) -> hal::pso::Des
|
||||
}
|
||||
|
||||
pub fn map_shader_stage_flags(
|
||||
shader_stage_flags: binding_model::ShaderStageFlags,
|
||||
shader_stage_flags: binding_model::ShaderStage,
|
||||
) -> hal::pso::ShaderStageFlags {
|
||||
use crate::binding_model::ShaderStageFlags as F;
|
||||
use crate::binding_model::ShaderStage as Ss;
|
||||
use hal::pso::ShaderStageFlags as H;
|
||||
|
||||
let mut value = H::empty();
|
||||
if shader_stage_flags.contains(F::VERTEX) {
|
||||
if shader_stage_flags.contains(Ss::VERTEX) {
|
||||
value |= H::VERTEX;
|
||||
}
|
||||
if shader_stage_flags.contains(F::FRAGMENT) {
|
||||
if shader_stage_flags.contains(Ss::FRAGMENT) {
|
||||
value |= H::FRAGMENT;
|
||||
}
|
||||
if shader_stage_flags.contains(F::COMPUTE) {
|
||||
if shader_stage_flags.contains(Ss::COMPUTE) {
|
||||
value |= H::COMPUTE;
|
||||
}
|
||||
value
|
||||
@@ -134,12 +135,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_blend != pipeline::BlendDescriptor::REPLACE
|
||||
|| desc.alpha_blend != 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_blend),
|
||||
alpha: map_blend_descriptor(&desc.alpha_blend),
|
||||
}
|
||||
} else {
|
||||
hal::pso::BlendState::Off
|
||||
@@ -147,21 +148,21 @@ pub fn map_color_state_descriptor(
|
||||
hal::pso::ColorBlendDesc(map_color_write_flags(color_mask), blend_state)
|
||||
}
|
||||
|
||||
fn map_color_write_flags(flags: pipeline::ColorWriteFlags) -> hal::pso::ColorMask {
|
||||
use crate::pipeline::ColorWriteFlags as F;
|
||||
fn map_color_write_flags(flags: pipeline::ColorWrite) -> hal::pso::ColorMask {
|
||||
use crate::pipeline::ColorWrite as Cw;
|
||||
use hal::pso::ColorMask as H;
|
||||
|
||||
let mut value = H::empty();
|
||||
if flags.contains(F::RED) {
|
||||
if flags.contains(Cw::RED) {
|
||||
value |= H::RED;
|
||||
}
|
||||
if flags.contains(F::GREEN) {
|
||||
if flags.contains(Cw::GREEN) {
|
||||
value |= H::GREEN;
|
||||
}
|
||||
if flags.contains(F::BLUE) {
|
||||
if flags.contains(Cw::BLUE) {
|
||||
value |= H::BLUE;
|
||||
}
|
||||
if flags.contains(F::ALPHA) {
|
||||
if flags.contains(Cw::ALPHA) {
|
||||
value |= H::ALPHA;
|
||||
}
|
||||
value
|
||||
@@ -367,42 +368,23 @@ pub fn map_vertex_format(vertex_format: pipeline::VertexFormat) -> hal::format::
|
||||
use crate::pipeline::VertexFormat::*;
|
||||
use hal::format::Format as H;
|
||||
match vertex_format {
|
||||
Uchar => H::R8Uint,
|
||||
Uchar2 => H::Rg8Uint,
|
||||
Uchar3 => H::Rgb8Uint,
|
||||
Uchar4 => H::Rgba8Uint,
|
||||
Char => H::R8Sint,
|
||||
Char2 => H::Rg8Sint,
|
||||
Char3 => H::Rgb8Sint,
|
||||
Char4 => H::Rgba8Sint,
|
||||
UcharNorm => H::R8Unorm,
|
||||
Uchar2Norm => H::Rg8Unorm,
|
||||
Uchar3Norm => H::Rgb8Unorm,
|
||||
Uchar4Norm => H::Rgba8Unorm,
|
||||
Uchar4NormBgra => H::Bgra8Unorm,
|
||||
CharNorm => H::R8Snorm,
|
||||
Char2Norm => H::Rg8Snorm,
|
||||
Char3Norm => H::Rgb8Snorm,
|
||||
Char4Norm => H::Rgba8Snorm,
|
||||
Ushort => H::R16Uint,
|
||||
Ushort2 => H::Rg16Uint,
|
||||
Ushort3 => H::Rgb16Uint,
|
||||
Ushort4 => H::Rgba16Uint,
|
||||
Short => H::R16Sint,
|
||||
Short2 => H::Rg16Sint,
|
||||
Short3 => H::Rgb16Sint,
|
||||
Short4 => H::Rgba16Sint,
|
||||
UshortNorm => H::R16Unorm,
|
||||
Ushort2Norm => H::Rg16Unorm,
|
||||
Ushort3Norm => H::Rgb16Unorm,
|
||||
Ushort4Norm => H::Rgba16Unorm,
|
||||
ShortNorm => H::R16Snorm,
|
||||
Short2Norm => H::Rg16Snorm,
|
||||
Short3Norm => H::Rgb16Snorm,
|
||||
Short4Norm => H::Rgba16Snorm,
|
||||
Half => H::R16Sfloat,
|
||||
Half2 => H::Rg16Sfloat,
|
||||
Half3 => H::Rgb16Sfloat,
|
||||
Half4 => H::Rgba16Sfloat,
|
||||
Float => H::R32Sfloat,
|
||||
Float2 => H::Rg32Sfloat,
|
||||
@@ -486,8 +468,8 @@ pub fn map_texture_aspect_flags(aspect: resource::TextureAspectFlags) -> hal::fo
|
||||
flags
|
||||
}
|
||||
|
||||
pub fn map_buffer_state(usage: resource::BufferUsageFlags) -> hal::buffer::State {
|
||||
use crate::resource::BufferUsageFlags as W;
|
||||
pub fn map_buffer_state(usage: resource::BufferUsage) -> hal::buffer::State {
|
||||
use crate::resource::BufferUsage as W;
|
||||
use hal::buffer::Access as A;
|
||||
|
||||
let mut access = A::empty();
|
||||
@@ -514,10 +496,10 @@ pub fn map_buffer_state(usage: resource::BufferUsageFlags) -> hal::buffer::State
|
||||
}
|
||||
|
||||
pub fn map_texture_state(
|
||||
usage: resource::TextureUsageFlags,
|
||||
usage: resource::TextureUsage,
|
||||
aspects: hal::format::Aspects,
|
||||
) -> hal::image::State {
|
||||
use crate::resource::TextureUsageFlags as W;
|
||||
use crate::resource::TextureUsage as W;
|
||||
use hal::image::{Access as A, Layout as L};
|
||||
|
||||
let is_color = aspects.contains(hal::format::Aspects::COLOR);
|
||||
@@ -589,7 +571,6 @@ pub fn map_wrap(address: resource::AddressMode) -> hal::image::WrapMode {
|
||||
Am::ClampToEdge => W::Clamp,
|
||||
Am::Repeat => W::Tile,
|
||||
Am::MirrorRepeat => W::Mirror,
|
||||
Am::ClampToBorderColor => W::Border,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+50
-50
@@ -9,6 +9,7 @@ use crate::{
|
||||
track::{DummyUsage, Stitch, TrackPermit, TrackerSet, Tracktion},
|
||||
AdapterId,
|
||||
BindGroupId,
|
||||
BufferAddress,
|
||||
BufferId,
|
||||
BufferMapAsyncStatus,
|
||||
BufferMapOperation,
|
||||
@@ -375,7 +376,7 @@ fn map_buffer(
|
||||
raw: &<back::Backend as hal::Backend>::Device,
|
||||
limits: &hal::Limits,
|
||||
buffer: &mut resource::Buffer<back::Backend>,
|
||||
original_range: &std::ops::Range<u64>,
|
||||
original_range: &std::ops::Range<BufferAddress>,
|
||||
kind: HostMap,
|
||||
) -> BufferMapResult {
|
||||
// gfx-rs requires mapping and flushing/invalidation ranges to be done at `non_coherent_atom_size`
|
||||
@@ -572,7 +573,7 @@ pub fn device_create_buffer(
|
||||
let device = &device_guard[device_id];
|
||||
let (usage, memory_properties) = conv::map_buffer_usage(desc.usage);
|
||||
|
||||
let mut buffer = unsafe { device.raw.create_buffer(desc.size as u64, usage).unwrap() };
|
||||
let mut buffer = unsafe { device.raw.create_buffer(desc.size, usage).unwrap() };
|
||||
let requirements = unsafe { device.raw.get_buffer_requirements(&buffer) };
|
||||
let device_type = device
|
||||
.mem_props
|
||||
@@ -622,7 +623,7 @@ pub fn device_track_buffer(
|
||||
device_id: DeviceId,
|
||||
buffer_id: BufferId,
|
||||
ref_count: RefCount,
|
||||
flags: resource::BufferUsageFlags,
|
||||
flags: resource::BufferUsage,
|
||||
) {
|
||||
let query = HUB.devices.read()[device_id]
|
||||
.trackers
|
||||
@@ -645,7 +646,7 @@ pub extern "C" fn wgpu_device_create_buffer(
|
||||
device_id,
|
||||
id,
|
||||
ref_count,
|
||||
resource::BufferUsageFlags::empty(),
|
||||
resource::BufferUsage::empty(),
|
||||
);
|
||||
id
|
||||
}
|
||||
@@ -658,13 +659,13 @@ pub extern "C" fn wgpu_device_create_buffer_mapped(
|
||||
mapped_ptr_out: *mut *mut u8,
|
||||
) -> BufferId {
|
||||
let mut desc = desc.clone();
|
||||
desc.usage |= resource::BufferUsageFlags::MAP_WRITE;
|
||||
desc.usage |= resource::BufferUsage::MAP_WRITE;
|
||||
let mut buffer = device_create_buffer(device_id, &desc);
|
||||
|
||||
{
|
||||
let device_guard = HUB.devices.read();
|
||||
let device = &device_guard[device_id];
|
||||
let range = 0..desc.size as u64;
|
||||
let range = 0..desc.size;
|
||||
|
||||
match map_buffer(
|
||||
&device.raw,
|
||||
@@ -691,7 +692,7 @@ pub extern "C" fn wgpu_device_create_buffer_mapped(
|
||||
device_id,
|
||||
id,
|
||||
ref_count,
|
||||
resource::BufferUsageFlags::MAP_WRITE,
|
||||
resource::BufferUsage::MAP_WRITE,
|
||||
);
|
||||
id
|
||||
}
|
||||
@@ -714,7 +715,7 @@ pub fn device_create_texture(
|
||||
device_id: DeviceId,
|
||||
desc: &resource::TextureDescriptor,
|
||||
) -> resource::Texture<back::Backend> {
|
||||
let kind = conv::map_texture_dimension_size(desc.dimension, desc.size, desc.array_size);
|
||||
let kind = conv::map_texture_dimension_size(desc.dimension, desc.size, desc.array_layer_count);
|
||||
let format = conv::map_texture_format(desc.format);
|
||||
let aspects = format.surface_desc().aspects;
|
||||
let usage = conv::map_texture_usage(desc.usage, aspects);
|
||||
@@ -724,9 +725,9 @@ pub fn device_create_texture(
|
||||
let mut image = unsafe {
|
||||
device.raw.create_image(
|
||||
kind,
|
||||
1, // TODO: mips
|
||||
desc.mip_level_count as hal::image::Level,
|
||||
format,
|
||||
hal::image::Tiling::Optimal, // TODO: linear
|
||||
hal::image::Tiling::Optimal,
|
||||
usage,
|
||||
hal::image::ViewCapabilities::empty(), // TODO: format, 2d array, cube
|
||||
)
|
||||
@@ -771,8 +772,8 @@ pub fn device_create_texture(
|
||||
format: desc.format,
|
||||
full_range: hal::image::SubresourceRange {
|
||||
aspects,
|
||||
levels: 0..1, //TODO: mips
|
||||
layers: 0..desc.array_size as u16,
|
||||
levels: 0..desc.mip_level_count as hal::image::Level,
|
||||
layers: 0..desc.array_layer_count as hal::image::Layer,
|
||||
},
|
||||
placement: resource::TexturePlacement::Memory(memory),
|
||||
life_guard: LifeGuard::new(),
|
||||
@@ -787,7 +788,7 @@ pub fn device_track_texture(device_id: DeviceId, texture_id: TextureId, ref_coun
|
||||
.query(
|
||||
texture_id,
|
||||
&ref_count,
|
||||
resource::TextureUsageFlags::UNINITIALIZED,
|
||||
resource::TextureUsage::UNINITIALIZED,
|
||||
);
|
||||
assert!(query.initialized);
|
||||
}
|
||||
@@ -935,9 +936,9 @@ pub fn device_create_sampler(
|
||||
mag_filter: conv::map_filter(desc.mag_filter),
|
||||
mip_filter: conv::map_filter(desc.mipmap_filter),
|
||||
wrap_mode: (
|
||||
conv::map_wrap(desc.r_address_mode),
|
||||
conv::map_wrap(desc.s_address_mode),
|
||||
conv::map_wrap(desc.t_address_mode),
|
||||
conv::map_wrap(desc.address_mode_u),
|
||||
conv::map_wrap(desc.address_mode_v),
|
||||
conv::map_wrap(desc.address_mode_w),
|
||||
),
|
||||
lod_bias: 0.0.into(),
|
||||
lod_range: desc.lod_min_clamp.into()..desc.lod_max_clamp.into(),
|
||||
@@ -946,11 +947,7 @@ pub fn device_create_sampler(
|
||||
} else {
|
||||
Some(conv::map_compare_function(desc.compare_function))
|
||||
},
|
||||
border: hal::image::PackedColor(match desc.border_color {
|
||||
resource::BorderColor::TransparentBlack => 0x00000000,
|
||||
resource::BorderColor::OpaqueBlack => 0x000000FF,
|
||||
resource::BorderColor::OpaqueWhite => 0xFFFFFFFF,
|
||||
}),
|
||||
border: hal::image::PackedColor(0),
|
||||
anisotropic: hal::image::Anisotropic::Off, //TODO
|
||||
};
|
||||
let raw = unsafe { device.raw.create_sampler(info).unwrap() };
|
||||
@@ -1081,7 +1078,7 @@ pub fn device_create_bind_group(
|
||||
.get_with_extended_usage(
|
||||
&*buffer_guard,
|
||||
bb.buffer,
|
||||
resource::BufferUsageFlags::UNIFORM,
|
||||
resource::BufferUsage::UNIFORM,
|
||||
)
|
||||
.unwrap();
|
||||
let alignment = match decl.ty {
|
||||
@@ -1094,7 +1091,8 @@ pub fn device_create_bind_group(
|
||||
device.limits.min_storage_buffer_offset_alignment
|
||||
}
|
||||
binding_model::BindingType::Sampler
|
||||
| binding_model::BindingType::SampledTexture => {
|
||||
| binding_model::BindingType::SampledTexture
|
||||
| binding_model::BindingType::StorageTexture => {
|
||||
panic!("Mismatched buffer binding for {:?}", decl)
|
||||
}
|
||||
};
|
||||
@@ -1104,7 +1102,7 @@ pub fn device_create_bind_group(
|
||||
"Misaligned buffer offset {}",
|
||||
bb.offset
|
||||
);
|
||||
let range = Some(bb.offset as u64)..Some((bb.offset + bb.size) as u64);
|
||||
let range = Some(bb.offset)..Some(bb.offset + bb.size);
|
||||
hal::pso::Descriptor::Buffer(&buffer.raw, range)
|
||||
}
|
||||
binding_model::BindingResource::Sampler(id) => {
|
||||
@@ -1120,7 +1118,7 @@ pub fn device_create_bind_group(
|
||||
.transit(
|
||||
view.texture_id.value,
|
||||
&view.texture_id.ref_count,
|
||||
resource::TextureUsageFlags::SAMPLED,
|
||||
resource::TextureUsage::SAMPLED,
|
||||
TrackPermit::EXTEND,
|
||||
)
|
||||
.unwrap();
|
||||
@@ -1449,28 +1447,29 @@ pub fn device_create_render_pipeline(
|
||||
module: &shader_module_guard[desc.vertex_stage.module].raw,
|
||||
specialization: hal::pso::Specialization::EMPTY,
|
||||
};
|
||||
let fragment = hal::pso::EntryPoint::<back::Backend> {
|
||||
entry: unsafe { ffi::CStr::from_ptr(desc.fragment_stage.entry_point) }
|
||||
.to_str()
|
||||
.to_owned()
|
||||
.unwrap(), // TODO
|
||||
module: &shader_module_guard[desc.fragment_stage.module].raw,
|
||||
specialization: hal::pso::Specialization::EMPTY,
|
||||
};
|
||||
let fragment = unsafe { desc.fragment_stage.as_ref() }
|
||||
.map(|stage| hal::pso::EntryPoint::<back::Backend> {
|
||||
entry: unsafe { ffi::CStr::from_ptr(stage.entry_point) }
|
||||
.to_str()
|
||||
.to_owned()
|
||||
.unwrap(), // TODO
|
||||
module: &shader_module_guard[stage.module].raw,
|
||||
specialization: hal::pso::Specialization::EMPTY,
|
||||
});
|
||||
|
||||
let shaders = hal::pso::GraphicsShaderSet {
|
||||
vertex,
|
||||
hull: None,
|
||||
domain: None,
|
||||
geometry: None,
|
||||
fragment: Some(fragment),
|
||||
fragment,
|
||||
};
|
||||
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,
|
||||
desc.vertex_input.vertex_buffers,
|
||||
desc.vertex_input.vertex_buffers_count,
|
||||
)
|
||||
};
|
||||
let mut vertex_buffers = Vec::with_capacity(desc_vbs.len());
|
||||
@@ -1481,7 +1480,7 @@ pub fn device_create_render_pipeline(
|
||||
}
|
||||
vertex_buffers.alloc().init(hal::pso::VertexBufferDesc {
|
||||
binding: i as u32,
|
||||
stride: vb_state.stride,
|
||||
stride: vb_state.stride as u32,
|
||||
rate: match vb_state.step_mode {
|
||||
pipeline::InputStepMode::Vertex => hal::pso::VertexInputRate::Vertex,
|
||||
pipeline::InputStepMode::Instance => hal::pso::VertexInputRate::Instance(1),
|
||||
@@ -1490,12 +1489,13 @@ pub fn device_create_render_pipeline(
|
||||
let desc_atts =
|
||||
unsafe { slice::from_raw_parts(vb_state.attributes, vb_state.attributes_count) };
|
||||
for attribute in desc_atts {
|
||||
assert_eq!(0, attribute.offset >> 32);
|
||||
attributes.alloc().init(hal::pso::AttributeDesc {
|
||||
location: attribute.attribute_index,
|
||||
location: attribute.shader_location,
|
||||
binding: i as u32,
|
||||
element: hal::pso::Element {
|
||||
format: conv::map_vertex_format(attribute.format),
|
||||
offset: attribute.offset,
|
||||
offset: attribute.offset as u32,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -1570,7 +1570,7 @@ pub fn device_create_render_pipeline(
|
||||
let mut flags = pipeline::PipelineFlags::empty();
|
||||
if color_states
|
||||
.iter()
|
||||
.any(|state| state.color.uses_color() | state.alpha.uses_color())
|
||||
.any(|state| state.color_blend.uses_color() | state.alpha_blend.uses_color())
|
||||
{
|
||||
flags |= pipeline::PipelineFlags::BLEND_COLOR;
|
||||
}
|
||||
@@ -1580,7 +1580,7 @@ pub fn device_create_render_pipeline(
|
||||
layout_id: desc.layout,
|
||||
pass_context,
|
||||
flags,
|
||||
index_format: desc.vertex_buffer_state.index_format,
|
||||
index_format: desc.vertex_input.index_format,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1806,7 +1806,7 @@ pub fn swap_chain_populate_textures(
|
||||
trackers.textures.query(
|
||||
texture_id.value,
|
||||
&texture_id.ref_count,
|
||||
resource::TextureUsageFlags::UNINITIALIZED,
|
||||
resource::TextureUsage::UNINITIALIZED,
|
||||
);
|
||||
|
||||
let view = resource::TextureView {
|
||||
@@ -1872,8 +1872,8 @@ pub type BufferMapWriteCallback =
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_buffer_map_read_async(
|
||||
buffer_id: BufferId,
|
||||
start: u32,
|
||||
size: u32,
|
||||
start: BufferAddress,
|
||||
size: BufferAddress,
|
||||
callback: BufferMapReadCallback,
|
||||
userdata: *mut u8,
|
||||
) {
|
||||
@@ -1887,7 +1887,7 @@ pub extern "C" fn wgpu_buffer_map_read_async(
|
||||
return;
|
||||
}
|
||||
|
||||
let range = start as u64..(start + size) as u64;
|
||||
let range = start .. start + size;
|
||||
buffer.pending_map_operation = Some(BufferMapOperation::Read(range, callback, userdata));
|
||||
(buffer.device_id.value, buffer.life_guard.ref_count.clone())
|
||||
};
|
||||
@@ -1895,7 +1895,7 @@ pub extern "C" fn wgpu_buffer_map_read_async(
|
||||
let device_guard = HUB.devices.read();
|
||||
let device = &device_guard[device_id];
|
||||
|
||||
let usage = resource::BufferUsageFlags::MAP_READ;
|
||||
let usage = resource::BufferUsage::MAP_READ;
|
||||
match device
|
||||
.trackers
|
||||
.lock()
|
||||
@@ -1915,8 +1915,8 @@ pub extern "C" fn wgpu_buffer_map_read_async(
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_buffer_map_write_async(
|
||||
buffer_id: BufferId,
|
||||
start: u32,
|
||||
size: u32,
|
||||
start: BufferAddress,
|
||||
size: BufferAddress,
|
||||
callback: BufferMapWriteCallback,
|
||||
userdata: *mut u8,
|
||||
) {
|
||||
@@ -1930,7 +1930,7 @@ pub extern "C" fn wgpu_buffer_map_write_async(
|
||||
return;
|
||||
}
|
||||
|
||||
let range = start as u64..(start + size) as u64;
|
||||
let range = start .. start + size;
|
||||
buffer.pending_map_operation = Some(BufferMapOperation::Write(range, callback, userdata));
|
||||
(buffer.device_id.value, buffer.life_guard.ref_count.clone())
|
||||
};
|
||||
@@ -1938,7 +1938,7 @@ pub extern "C" fn wgpu_buffer_map_write_async(
|
||||
let device_guard = HUB.devices.read();
|
||||
let device = &device_guard[device_id];
|
||||
|
||||
let usage = resource::BufferUsageFlags::MAP_WRITE;
|
||||
let usage = resource::BufferUsage::MAP_WRITE;
|
||||
match device
|
||||
.trackers
|
||||
.lock()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::{hub::HUB, AdapterHandle, AdapterId, DeviceHandle, InstanceId, SurfaceHandle};
|
||||
use crate::{binding_model::MAX_BIND_GROUPS, hub::HUB, AdapterHandle, AdapterId, DeviceHandle, InstanceId, SurfaceHandle};
|
||||
#[cfg(feature = "local")]
|
||||
use crate::{DeviceId, SurfaceId};
|
||||
|
||||
@@ -26,17 +26,33 @@ pub struct AdapterDescriptor {
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Default)]
|
||||
#[cfg_attr(feature = "remote", derive(Clone, Serialize, Deserialize))]
|
||||
pub struct Extensions {
|
||||
pub anisotropic_filtering: bool,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "remote", derive(Clone, Serialize, Deserialize))]
|
||||
pub struct Limits {
|
||||
pub max_bind_groups: u32,
|
||||
}
|
||||
|
||||
impl Default for Limits {
|
||||
fn default() -> Self {
|
||||
Limits {
|
||||
max_bind_groups: MAX_BIND_GROUPS as u32,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "remote", derive(Clone, Serialize, Deserialize))]
|
||||
pub struct DeviceDescriptor {
|
||||
pub extensions: Extensions,
|
||||
pub limits: Limits,
|
||||
}
|
||||
|
||||
pub fn create_instance() -> ::back::Instance {
|
||||
@@ -186,7 +202,7 @@ pub fn adapter_create_device(adapter_id: AdapterId, _desc: &DeviceDescriptor) ->
|
||||
|
||||
#[cfg(feature = "local")]
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wgpu_adapter_create_device(
|
||||
pub extern "C" fn wgpu_adapter_request_device(
|
||||
adapter_id: AdapterId,
|
||||
desc: &DeviceDescriptor,
|
||||
) -> DeviceId {
|
||||
|
||||
+16
-2
@@ -40,14 +40,20 @@ pub use self::swap_chain::*;
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use std::ptr;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::{
|
||||
os::raw::c_char,
|
||||
ptr,
|
||||
sync::atomic::{AtomicUsize, Ordering},
|
||||
};
|
||||
|
||||
|
||||
type SubmissionIndex = usize;
|
||||
pub(crate) type Index = u32;
|
||||
pub(crate) type Epoch = u32;
|
||||
|
||||
pub type BufferAddress = u64;
|
||||
pub type RawString = *const c_char;
|
||||
|
||||
//TODO: make it private. Currently used for swapchain creation impl.
|
||||
#[derive(Debug)]
|
||||
pub struct RefCount(ptr::NonNull<AtomicUsize>);
|
||||
@@ -156,6 +162,14 @@ pub struct Origin3d {
|
||||
pub z: f32,
|
||||
}
|
||||
|
||||
impl Origin3d {
|
||||
pub const ZERO: Self = Origin3d {
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
z: 0.0,
|
||||
};
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Extent3d {
|
||||
|
||||
+13
-32
@@ -1,8 +1,8 @@
|
||||
use crate::{device::RenderPassContext, resource, ByteArray, PipelineLayoutId, ShaderModuleId};
|
||||
use crate::{device::RenderPassContext, resource, BufferAddress, ByteArray, PipelineLayoutId, ShaderModuleId, RawString};
|
||||
|
||||
use bitflags::bitflags;
|
||||
|
||||
pub type ShaderAttributeIndex = u32;
|
||||
pub type ShaderLocation = u32;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
@@ -34,7 +34,7 @@ pub enum BlendOperation {
|
||||
|
||||
bitflags! {
|
||||
#[repr(transparent)]
|
||||
pub struct ColorWriteFlags: u32 {
|
||||
pub struct ColorWrite: u32 {
|
||||
const RED = 1;
|
||||
const GREEN = 2;
|
||||
const BLUE = 4;
|
||||
@@ -74,9 +74,9 @@ impl BlendDescriptor {
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ColorStateDescriptor {
|
||||
pub format: resource::TextureFormat,
|
||||
pub alpha: BlendDescriptor,
|
||||
pub color: BlendDescriptor,
|
||||
pub write_mask: ColorWriteFlags,
|
||||
pub alpha_blend: BlendDescriptor,
|
||||
pub color_blend: BlendDescriptor,
|
||||
pub write_mask: ColorWrite,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
@@ -132,42 +132,23 @@ pub enum IndexFormat {
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub enum VertexFormat {
|
||||
Uchar = 0,
|
||||
Uchar2 = 1,
|
||||
Uchar3 = 2,
|
||||
Uchar4 = 3,
|
||||
Char = 4,
|
||||
Char2 = 5,
|
||||
Char3 = 6,
|
||||
Char4 = 7,
|
||||
UcharNorm = 8,
|
||||
Uchar2Norm = 9,
|
||||
Uchar3Norm = 10,
|
||||
Uchar4Norm = 11,
|
||||
Uchar4NormBgra = 12,
|
||||
CharNorm = 13,
|
||||
Char2Norm = 14,
|
||||
Char3Norm = 15,
|
||||
Char4Norm = 16,
|
||||
Ushort = 17,
|
||||
Ushort2 = 18,
|
||||
Ushort3 = 19,
|
||||
Ushort4 = 20,
|
||||
Short = 21,
|
||||
Short2 = 22,
|
||||
Short3 = 23,
|
||||
Short4 = 24,
|
||||
UshortNorm = 25,
|
||||
Ushort2Norm = 26,
|
||||
Ushort3Norm = 27,
|
||||
Ushort4Norm = 28,
|
||||
ShortNorm = 29,
|
||||
Short2Norm = 30,
|
||||
Short3Norm = 31,
|
||||
Short4Norm = 32,
|
||||
Half = 33,
|
||||
Half2 = 34,
|
||||
Half3 = 35,
|
||||
Half4 = 36,
|
||||
Float = 37,
|
||||
Float2 = 38,
|
||||
@@ -193,21 +174,21 @@ pub enum InputStepMode {
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct VertexAttributeDescriptor {
|
||||
pub offset: u32,
|
||||
pub offset: BufferAddress,
|
||||
pub format: VertexFormat,
|
||||
pub attribute_index: ShaderAttributeIndex,
|
||||
pub shader_location: ShaderLocation,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct VertexBufferDescriptor {
|
||||
pub stride: u32,
|
||||
pub stride: BufferAddress,
|
||||
pub step_mode: InputStepMode,
|
||||
pub attributes: *const VertexAttributeDescriptor,
|
||||
pub attributes_count: usize,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct VertexBufferStateDescriptor {
|
||||
pub struct VertexInputDescriptor {
|
||||
pub index_format: IndexFormat,
|
||||
pub vertex_buffers: *const VertexBufferDescriptor,
|
||||
pub vertex_buffers_count: usize,
|
||||
@@ -221,7 +202,7 @@ pub struct ShaderModuleDescriptor {
|
||||
#[repr(C)]
|
||||
pub struct PipelineStageDescriptor {
|
||||
pub module: ShaderModuleId,
|
||||
pub entry_point: *const ::std::os::raw::c_char,
|
||||
pub entry_point: RawString,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
@@ -274,13 +255,13 @@ pub struct RasterizationStateDescriptor {
|
||||
pub struct RenderPipelineDescriptor {
|
||||
pub layout: PipelineLayoutId,
|
||||
pub vertex_stage: PipelineStageDescriptor,
|
||||
pub fragment_stage: PipelineStageDescriptor,
|
||||
pub fragment_stage: *const PipelineStageDescriptor,
|
||||
pub primitive_topology: PrimitiveTopology,
|
||||
pub rasterization_state: RasterizationStateDescriptor,
|
||||
pub color_states: *const ColorStateDescriptor,
|
||||
pub color_states_length: usize,
|
||||
pub depth_stencil_state: *const DepthStencilStateDescriptor,
|
||||
pub vertex_buffer_state: VertexBufferStateDescriptor,
|
||||
pub vertex_input: VertexInputDescriptor,
|
||||
pub sample_count: u32,
|
||||
}
|
||||
|
||||
|
||||
+12
-20
@@ -1,5 +1,6 @@
|
||||
use crate::{
|
||||
swap_chain::{SwapChainLink, SwapImageEpoch},
|
||||
BufferAddress,
|
||||
BufferMapReadCallback,
|
||||
BufferMapWriteCallback,
|
||||
DeviceId,
|
||||
@@ -18,7 +19,7 @@ use std::borrow::Borrow;
|
||||
|
||||
bitflags! {
|
||||
#[repr(transparent)]
|
||||
pub struct BufferUsageFlags: u32 {
|
||||
pub struct BufferUsage: u32 {
|
||||
const MAP_READ = 1;
|
||||
const MAP_WRITE = 2;
|
||||
const TRANSFER_SRC = 4;
|
||||
@@ -35,8 +36,8 @@ bitflags! {
|
||||
#[repr(C)]
|
||||
#[derive(Clone)]
|
||||
pub struct BufferDescriptor {
|
||||
pub size: u32,
|
||||
pub usage: BufferUsageFlags,
|
||||
pub size: BufferAddress,
|
||||
pub usage: BufferUsage,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
@@ -151,7 +152,7 @@ pub enum TextureFormat {
|
||||
|
||||
bitflags! {
|
||||
#[repr(transparent)]
|
||||
pub struct TextureUsageFlags: u32 {
|
||||
pub struct TextureUsage: u32 {
|
||||
const TRANSFER_SRC = 1;
|
||||
const TRANSFER_DST = 2;
|
||||
const SAMPLED = 4;
|
||||
@@ -166,10 +167,12 @@ bitflags! {
|
||||
#[repr(C)]
|
||||
pub struct TextureDescriptor {
|
||||
pub size: Extent3d,
|
||||
pub array_size: u32,
|
||||
pub array_layer_count: u32,
|
||||
pub mip_level_count: u32,
|
||||
pub sample_count: u32,
|
||||
pub dimension: TextureDimension,
|
||||
pub format: TextureFormat,
|
||||
pub usage: TextureUsageFlags,
|
||||
pub usage: TextureUsage,
|
||||
}
|
||||
|
||||
pub(crate) enum TexturePlacement<B: hal::Backend> {
|
||||
@@ -255,7 +258,6 @@ pub enum AddressMode {
|
||||
ClampToEdge = 0,
|
||||
Repeat = 1,
|
||||
MirrorRepeat = 2,
|
||||
ClampToBorderColor = 3,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
@@ -278,27 +280,17 @@ pub enum CompareFunction {
|
||||
Always = 7,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)]
|
||||
pub enum BorderColor {
|
||||
TransparentBlack = 0,
|
||||
OpaqueBlack = 1,
|
||||
OpaqueWhite = 2,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SamplerDescriptor {
|
||||
pub r_address_mode: AddressMode,
|
||||
pub s_address_mode: AddressMode,
|
||||
pub t_address_mode: AddressMode,
|
||||
pub address_mode_u: AddressMode,
|
||||
pub address_mode_v: AddressMode,
|
||||
pub address_mode_w: AddressMode,
|
||||
pub mag_filter: FilterMode,
|
||||
pub min_filter: FilterMode,
|
||||
pub mipmap_filter: FilterMode,
|
||||
pub lod_min_clamp: f32,
|
||||
pub lod_max_clamp: f32,
|
||||
pub max_anisotropy: u32,
|
||||
pub compare_function: CompareFunction,
|
||||
pub border_color: BorderColor,
|
||||
}
|
||||
|
||||
pub struct Sampler<B: hal::Backend> {
|
||||
|
||||
@@ -78,7 +78,7 @@ pub struct SwapChain<B: hal::Backend> {
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct SwapChainDescriptor {
|
||||
pub usage: resource::TextureUsageFlags,
|
||||
pub usage: resource::TextureUsage,
|
||||
pub format: resource::TextureFormat,
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
@@ -92,7 +92,9 @@ impl SwapChainDescriptor {
|
||||
height: self.height,
|
||||
depth: 1,
|
||||
},
|
||||
array_size: 1,
|
||||
mip_level_count: 1,
|
||||
array_layer_count: 1,
|
||||
sample_count: 1,
|
||||
dimension: resource::TextureDimension::D2,
|
||||
format: self.format,
|
||||
usage: self.usage,
|
||||
@@ -220,7 +222,7 @@ pub extern "C" fn wgpu_swap_chain_present(swap_chain_id: SwapChainId) {
|
||||
.transit(
|
||||
frame.texture_id.value,
|
||||
&texture.life_guard.ref_count,
|
||||
resource::TextureUsageFlags::UNINITIALIZED,
|
||||
resource::TextureUsage::UNINITIALIZED,
|
||||
TrackPermit::REPLACE,
|
||||
)
|
||||
.unwrap()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
hub::{Storage},
|
||||
resource::{BufferUsageFlags, TextureUsageFlags},
|
||||
resource::{BufferUsage, TextureUsage},
|
||||
BufferId,
|
||||
Epoch,
|
||||
Index,
|
||||
@@ -69,14 +69,14 @@ impl BitOr for DummyUsage {
|
||||
}
|
||||
}
|
||||
|
||||
impl GenericUsage for BufferUsageFlags {
|
||||
impl GenericUsage for BufferUsage {
|
||||
fn is_exclusive(&self) -> bool {
|
||||
BufferUsageFlags::WRITE_ALL.intersects(*self)
|
||||
BufferUsage::WRITE_ALL.intersects(*self)
|
||||
}
|
||||
}
|
||||
impl GenericUsage for TextureUsageFlags {
|
||||
impl GenericUsage for TextureUsage {
|
||||
fn is_exclusive(&self) -> bool {
|
||||
TextureUsageFlags::WRITE_ALL.intersects(*self)
|
||||
TextureUsage::WRITE_ALL.intersects(*self)
|
||||
}
|
||||
}
|
||||
impl GenericUsage for DummyUsage {
|
||||
@@ -98,8 +98,8 @@ pub struct Tracker<I, U> {
|
||||
map: FastHashMap<Index, Track<U>>,
|
||||
_phantom: PhantomData<I>,
|
||||
}
|
||||
pub type BufferTracker = Tracker<BufferId, BufferUsageFlags>;
|
||||
pub type TextureTracker = Tracker<TextureId, TextureUsageFlags>;
|
||||
pub type BufferTracker = Tracker<BufferId, BufferUsage>;
|
||||
pub type TextureTracker = Tracker<TextureId, TextureUsage>;
|
||||
pub type TextureViewTracker = Tracker<TextureViewId, DummyUsage>;
|
||||
|
||||
//TODO: make this a generic parameter.
|
||||
|
||||
Reference in new issue
Block a user