mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-23 23:34:29 +00:00
Check for the block decorator in the validator
This commit is contained in:
parent
c803240587
commit
a5184fba49
@ -40,6 +40,8 @@ pub enum GlobalVariableError {
|
||||
InvalidUsage,
|
||||
#[error("Type isn't compatible with the storage class")]
|
||||
InvalidType,
|
||||
#[error("Structure doesn't have a block decoration, can't be host-shared")]
|
||||
MissingBlockDecoration,
|
||||
#[error("Interpolation is not valid")]
|
||||
InvalidInterpolation,
|
||||
#[error("Storage access {seen:?} exceed the allowed {allowed:?}")]
|
||||
@ -222,6 +224,22 @@ impl crate::GlobalVariable {
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::TypeInner {
|
||||
fn check_block(&self) -> Result<(), GlobalVariableError> {
|
||||
match *self {
|
||||
Self::Struct {
|
||||
block: true,
|
||||
members: _,
|
||||
} => Ok(()),
|
||||
Self::Struct {
|
||||
block: false,
|
||||
members: _,
|
||||
} => Err(GlobalVariableError::MissingBlockDecoration),
|
||||
_ => Err(GlobalVariableError::InvalidType),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn storage_usage(access: crate::StorageAccess) -> crate::GlobalUse {
|
||||
let mut storage_usage = crate::GlobalUse::empty();
|
||||
if access.contains(crate::StorageAccess::LOAD) {
|
||||
@ -388,10 +406,14 @@ impl Validator {
|
||||
}
|
||||
crate::StorageClass::Storage => {
|
||||
var.check_resource()?;
|
||||
let ty = &types[var.ty];
|
||||
ty.inner.check_block()?;
|
||||
crate::StorageAccess::all()
|
||||
}
|
||||
crate::StorageClass::Uniform => {
|
||||
var.check_resource()?;
|
||||
let ty = &types[var.ty];
|
||||
ty.inner.check_block()?;
|
||||
crate::StorageAccess::empty()
|
||||
}
|
||||
crate::StorageClass::Handle => {
|
||||
|
@ -1,6 +1,7 @@
|
||||
[[builtin(global_invocation_id)]]
|
||||
var global_id: vec3<u32>;
|
||||
|
||||
[[block]]
|
||||
struct PrimeIndices {
|
||||
data: array<u32>;
|
||||
}; // this is used as both input and output for convenience
|
||||
|
@ -3,7 +3,7 @@ var<out> out_position: vec4<f32>;
|
||||
[[location(0)]] var<out> out_uv: vec3<f32>;
|
||||
[[builtin(vertex_index)]] var<in> in_vertex_index: u32;
|
||||
|
||||
//[[block]]
|
||||
[[block]]
|
||||
struct Data {
|
||||
proj_inv: mat4x4<f32>;
|
||||
view: mat4x4<f32>;
|
||||
|
@ -13,7 +13,12 @@ struct Data {
|
||||
};
|
||||
|
||||
out vec3 _location_0_vs;
|
||||
uniform Data _group_0_binding_0;
|
||||
uniform Data_block_0 {
|
||||
|
||||
mat4x4 proj_inv;
|
||||
|
||||
mat4x4 view;
|
||||
} _group_0_binding_0;
|
||||
|
||||
void main() {
|
||||
int tmp1_;
|
||||
|
@ -13,7 +13,12 @@ OpEntryPoint Vertex %11 "vs_main" %157 %44 %15
|
||||
OpEntryPoint Fragment %168 "fs_main" %180 %170
|
||||
OpExecutionMode %168 OriginUpperLeft
|
||||
OpDecorate %15 BuiltIn VertexIndex
|
||||
OpDecorate %26 Block
|
||||
OpMemberDecorate %26 0 Offset 0
|
||||
OpMemberDecorate %26 0 MatrixStride 16
|
||||
OpDecorate %27 ColMajor
|
||||
OpMemberDecorate %26 1 Offset 64
|
||||
OpMemberDecorate %26 1 MatrixStride 16
|
||||
OpDecorate %25 DescriptorSet 0
|
||||
OpDecorate %25 Binding 0
|
||||
OpDecorate %44 Location 0
|
||||
|
Loading…
Reference in New Issue
Block a user