mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-08 13:14:56 +00:00
wgsl: Fixes for new validation failures
Values of array and matrix can now only be indexed by a constant value. Dynamic indexing requires the value to be held in memory. See: https://github.com/gpuweb/gpuweb/issues/1782 Bug: tint:867 Change-Id: I2b9ad6e40fc8121e7aca3a71c190639b39b0b862 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/54652 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org> Auto-Submit: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
dcb82432fb
commit
36edf8d850
@@ -36,23 +36,23 @@ void init() {
|
||||
swapChainFormat = static_cast<WGPUTextureFormat>(GetPreferredSwapChainTextureFormat());
|
||||
wgpuSwapChainConfigure(swapchain, swapChainFormat, WGPUTextureUsage_RenderAttachment, 640, 480);
|
||||
|
||||
const char* vs =
|
||||
"let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(\n"
|
||||
" vec2<f32>( 0.0, 0.5),\n"
|
||||
" vec2<f32>(-0.5, -0.5),\n"
|
||||
" vec2<f32>( 0.5, -0.5)\n"
|
||||
");\n"
|
||||
"[[stage(vertex)]] fn main(\n"
|
||||
" [[builtin(vertex_index)]] VertexIndex : u32\n"
|
||||
") -> [[builtin(position)]] vec4<f32> {\n"
|
||||
" return vec4<f32>(pos[VertexIndex], 0.0, 1.0);\n"
|
||||
"}\n";
|
||||
const char* vs = R"(
|
||||
[[stage(vertex)]] fn main(
|
||||
[[builtin(vertex_index)]] VertexIndex : u32
|
||||
) -> [[builtin(position)]] vec4<f32> {
|
||||
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
||||
vec2<f32>( 0.0, 0.5),
|
||||
vec2<f32>(-0.5, -0.5),
|
||||
vec2<f32>( 0.5, -0.5)
|
||||
);
|
||||
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
|
||||
})";
|
||||
WGPUShaderModule vsModule = utils::CreateShaderModule(device, vs).Release();
|
||||
|
||||
const char* fs =
|
||||
"[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {\n"
|
||||
" return vec4<f32>(1.0, 0.0, 0.0, 1.0);\n"
|
||||
"}\n";
|
||||
const char* fs = R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
})";
|
||||
WGPUShaderModule fsModule = utils::CreateShaderModule(device, fs).Release();
|
||||
|
||||
{
|
||||
|
||||
@@ -313,13 +313,13 @@ int main(int argc, const char* argv[]) {
|
||||
// The hacky pipeline to render a triangle.
|
||||
utils::ComboRenderPipelineDescriptor pipelineDesc;
|
||||
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
|
||||
let pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
||||
vec2<f32>( 0.0, 0.5),
|
||||
vec2<f32>(-0.5, -0.5),
|
||||
vec2<f32>( 0.5, -0.5)
|
||||
);
|
||||
[[stage(vertex)]] fn main([[builtin(vertex_index)]] VertexIndex : u32)
|
||||
-> [[builtin(position)]] vec4<f32> {
|
||||
var pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
||||
vec2<f32>( 0.0, 0.5),
|
||||
vec2<f32>(-0.5, -0.5),
|
||||
vec2<f32>( 0.5, -0.5)
|
||||
);
|
||||
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
|
||||
})");
|
||||
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
|
||||
Reference in New Issue
Block a user