From 156d5bd0f78b809df5b4c5b09bdb0815979e5e00 Mon Sep 17 00:00:00 2001 From: SarahM0 Date: Tue, 25 Jun 2019 16:07:14 -0400 Subject: [PATCH 01/11] initial commit --- src/dawn/engine_dawn.cc | 23 ++++++++++++++++------- src/dawn/engine_dawn.h | 3 +++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/dawn/engine_dawn.cc b/src/dawn/engine_dawn.cc index 68d6a829b..8c2345008 100644 --- a/src/dawn/engine_dawn.cc +++ b/src/dawn/engine_dawn.cc @@ -300,7 +300,8 @@ ::dawn::Buffer CreateBufferFromData(const ::dawn::Device& device, descriptor.usage = usage | ::dawn::BufferUsageBit::TransferDst; ::dawn::Buffer buffer = device.CreateBuffer(&descriptor); - buffer.SetSubData(0, size, reinterpret_cast(data)); + if (data != nullptr) + buffer.SetSubData(0, size, reinterpret_cast(data)); return buffer; } @@ -932,8 +933,13 @@ Result EngineDawn::DoPatchParameterVertices( return Result("Dawn:DoPatch not implemented"); } -Result EngineDawn::DoBuffer(const BufferCommand*) { - return Result("Dawn:DoBuffer not implemented"); +Result EngineDawn::DoBuffer(const BufferCommand* command) { + ::dawn::Buffer* buffer = buffer_map_[command->GetBinding()]; + buffer->SetSubData( + command->GetOffset(), command->GetBuffer()->GetSizeInBytes(), + reinterpret_cast(command->GetValues().data())); + // return Result("Dawn:DoBuffer not implemented"); + return {}; } Result EngineDawn::AttachBuffersAndTextures( @@ -1052,11 +1058,13 @@ Result EngineDawn::AttachBuffersAndTextures( } } - ::dawn::Buffer buffer = + buffers_.emplace_back( CreateBufferFromData(*device_, buf_info.buffer->ValuePtr()->data(), buf_info.buffer->GetSizeInBytes(), bufferUsage | ::dawn::BufferUsageBit::TransferSrc | - ::dawn::BufferUsageBit::TransferDst); + ::dawn::BufferUsageBit::TransferDst)); + + buffer_map_[buf_info.binding] = &buffers_.back(); ::dawn::BindGroupLayoutBinding bglb; bglb.binding = buf_info.binding; @@ -1064,8 +1072,9 @@ Result EngineDawn::AttachBuffersAndTextures( bglb.type = bindingType; bindings.push_back(bglb); - BindingInitializationHelper tempBinding = BindingInitializationHelper( - buf_info.binding, buffer, 0, buf_info.buffer->GetSizeInBytes()); + BindingInitializationHelper tempBinding = + BindingInitializationHelper(buf_info.binding, buffers_.back(), 0, + buf_info.buffer->GetSizeInBytes()); bindingInitalizerHelper.push_back(tempBinding); } diff --git a/src/dawn/engine_dawn.h b/src/dawn/engine_dawn.h index b6e736ac7..521ecf758 100644 --- a/src/dawn/engine_dawn.h +++ b/src/dawn/engine_dawn.h @@ -89,6 +89,9 @@ class EngineDawn : public Engine { // Mapping from the generic engine's Pipeline object to our own Dawn-specific // pipelines. std::unordered_map pipeline_map_; + + std::unordered_map buffer_map_; + std::vector<::dawn::Buffer> buffers_; }; } // namespace dawn From d72da4c3af95c20ca9aecd19a40ca3a8e5ceeccd Mon Sep 17 00:00:00 2001 From: SarahM0 Date: Wed, 26 Jun 2019 10:22:30 -0400 Subject: [PATCH 02/11] set amber buffer --- src/dawn/engine_dawn.cc | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/dawn/engine_dawn.cc b/src/dawn/engine_dawn.cc index 8c2345008..4bb149563 100644 --- a/src/dawn/engine_dawn.cc +++ b/src/dawn/engine_dawn.cc @@ -289,7 +289,7 @@ MapResult MapTextureToHostBuffer(const RenderPipelineInfo& render_pipeline, return map; } -// creates a dawn buffer for TransferDst +// creates a dawn buffer of |size| bytes with TransferDst and the given usage // copied from Dawn utils source code ::dawn::Buffer CreateBufferFromData(const ::dawn::Device& device, const void* data, @@ -934,11 +934,21 @@ Result EngineDawn::DoPatchParameterVertices( } Result EngineDawn::DoBuffer(const BufferCommand* command) { - ::dawn::Buffer* buffer = buffer_map_[command->GetBinding()]; - buffer->SetSubData( - command->GetOffset(), command->GetBuffer()->GetSizeInBytes(), - reinterpret_cast(command->GetValues().data())); - // return Result("Dawn:DoBuffer not implemented"); + Result result; + + // TODO(SarahM0): Make this work for compute pipeline + RenderPipelineInfo* render_pipeline = GetRenderPipeline(command); + if (!render_pipeline) + return Result("DoBuffer invoked on invalid or missing render pipeline"); + if (!command->IsSSBO() && !command->IsUniform()) + return Result("DoBUfer not supported buffer type"); + + Buffer* amber_buffer = command->GetBuffer(); + amber_buffer->SetDataWithOffset(command->GetValues(), command->GetOffset()); + + ::dawn::Buffer* dawn_buffer = buffer_map_[command->GetBinding()]; + dawn_buffer->SetSubData(command->GetOffset(), amber_buffer->GetSizeInBytes(), + amber_buffer->ValuePtr()->data()); return {}; } From 8934f85e54d21ec62efba02c7f7669dad2556fac Mon Sep 17 00:00:00 2001 From: SarahM0 Date: Wed, 26 Jun 2019 16:52:39 -0400 Subject: [PATCH 03/11] adding if conditions --- src/dawn/engine_dawn.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/dawn/engine_dawn.cc b/src/dawn/engine_dawn.cc index 4bb149563..c6c937756 100644 --- a/src/dawn/engine_dawn.cc +++ b/src/dawn/engine_dawn.cc @@ -941,14 +941,20 @@ Result EngineDawn::DoBuffer(const BufferCommand* command) { if (!render_pipeline) return Result("DoBuffer invoked on invalid or missing render pipeline"); if (!command->IsSSBO() && !command->IsUniform()) - return Result("DoBUfer not supported buffer type"); - - Buffer* amber_buffer = command->GetBuffer(); - amber_buffer->SetDataWithOffset(command->GetValues(), command->GetOffset()); + return Result("DoBuffer not supported buffer type"); ::dawn::Buffer* dawn_buffer = buffer_map_[command->GetBinding()]; - dawn_buffer->SetSubData(command->GetOffset(), amber_buffer->GetSizeInBytes(), - amber_buffer->ValuePtr()->data()); + if (dawn_buffer) { + Buffer* amber_buffer = command->GetBuffer(); + if (amber_buffer) { + amber_buffer->SetDataWithOffset(command->GetValues(), + command->GetOffset()); + + dawn_buffer->SetSubData(command->GetOffset(), + amber_buffer->GetSizeInBytes(), + amber_buffer->ValuePtr()->data()); + } + } return {}; } From 935bfd2db8512a943be19d22142a6013ba446693 Mon Sep 17 00:00:00 2001 From: SarahM0 Date: Thu, 4 Jul 2019 14:06:02 -0400 Subject: [PATCH 04/11] update tests --- tests/cases/draw_triangle_list.vkscript | 60 +++++++++---------- tests/cases/position_to_ssbo.amber | 3 - .../ssbo_with_graphics_pipeline.vkscript | 4 +- tests/run_tests.py | 7 +-- 4 files changed, 34 insertions(+), 40 deletions(-) diff --git a/tests/cases/draw_triangle_list.vkscript b/tests/cases/draw_triangle_list.vkscript index 356a0d79c..ee1ccab40 100644 --- a/tests/cases/draw_triangle_list.vkscript +++ b/tests/cases/draw_triangle_list.vkscript @@ -36,47 +36,47 @@ void main() { [vertex data] # position vert_color - 0/R8G8_SNORM 1/R8G8B8_UNORM + 0/R8G8_SNORM 1/R8G8B8A8_UNORM # Red for entire frame -# R8 G8 R8 G8 B8 - -128 -128 255 0 0 - 127 127 255 0 0 - -128 127 255 0 0 +# R8 G8 R8 G8 B8 A8 + -128 -128 255 0 0 0 + 127 127 255 0 0 0 + -128 127 255 0 0 0 - -128 -128 255 0 0 - 127 127 255 0 0 - 127 -128 255 0 0 + -128 -128 255 0 0 0 + 127 127 255 0 0 0 + 127 -128 255 0 0 0 # Green for half frame -# R8 G8 R8 G8 B8 - 0 -128 0 255 0 - 127 127 0 255 0 - 0 127 0 255 0 +# R8 G8 R8 G8 B8 A8 + 0 -128 0 255 0 0 + 127 127 0 255 0 0 + 0 127 0 255 0 0 - 0 -128 0 255 0 - 127 127 0 255 0 - 127 -128 0 255 0 + 0 -128 0 255 0 0 + 127 127 0 255 0 0 + 127 -128 0 255 0 0 # Blue for quarter frame -# R8 G8 R8 G8 B8 - -128 0 0 0 255 - 0 127 0 0 255 - -128 127 0 0 255 +# R8 G8 R8 G8 B8 A8 + -128 0 0 0 255 0 + 0 127 0 0 255 0 + -128 127 0 0 255 0 - -128 0 0 0 255 - 0 127 0 0 255 - 0 0 0 0 255 + -128 0 0 0 255 0 + 0 127 0 0 255 0 + 0 0 0 0 255 0 # Mixed color for quarter frame -# R8 G8 R8 G8 B8 - 0 0 127 127 127 - 127 127 127 127 127 - 0 127 127 127 127 - - 0 0 127 127 127 - 127 127 127 127 127 - 127 0 127 127 127 +# R8 G8 R8 G8 B8 A8 + 0 0 127 127 127 0 + 127 127 127 127 127 0 + 0 127 127 127 127 0 + + 0 0 127 127 127 0 + 127 127 127 127 127 0 + 127 0 127 127 127 0 [test] clear diff --git a/tests/cases/position_to_ssbo.amber b/tests/cases/position_to_ssbo.amber index 39f7aaeaf..c293bd1f3 100644 --- a/tests/cases/position_to_ssbo.amber +++ b/tests/cases/position_to_ssbo.amber @@ -13,9 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -[require] -vertexPipelineStoresAndAtomics - [vertex shader] #version 430 diff --git a/tests/cases/ssbo_with_graphics_pipeline.vkscript b/tests/cases/ssbo_with_graphics_pipeline.vkscript index bfeb8bbab..fab83d37f 100644 --- a/tests/cases/ssbo_with_graphics_pipeline.vkscript +++ b/tests/cases/ssbo_with_graphics_pipeline.vkscript @@ -12,8 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -[require] -vertexPipelineStoresAndAtomics [vertex shader] #version 430 @@ -22,7 +20,7 @@ layout(location = 0) in vec4 position; layout(location = 1) in vec4 vert_color; layout(location = 0) out vec4 frag_color; -layout(set = 0, binding = 0) buffer block1 { +layout(set = 0, binding = 0) readonly buffer block1 { vec4 add_on; }; diff --git a/tests/run_tests.py b/tests/run_tests.py index 77535ca65..577809a04 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -55,7 +55,9 @@ } SUPPRESSIONS_DAWN = [ - # not implemented in Dawn backend + # Dawn requires a fragmentStage now and in the medium term + "position_to_ssbo.amber", + # not implemented in Dawn backend "compute_accumulated_ubo_definition.amber", "compute_accumulated_ubo_definition.vkscript", "compute_mat2x2.amber", @@ -102,8 +104,6 @@ "draw_rectangles.vkscript", "draw_rectangles_once.vkscript", "draw_rectangles_without_probe.vkscript", - "draw_triangle_list.amber", - "draw_triangle_list.vkscript", "draw_triangle_list_in_r16g16b16a16_snorm_color_frame.vkscript", "draw_triangle_list_in_r16g16b16a16_uint_color_frame.vkscript", "draw_triangle_list_in_r32g32b32a32_sfloat_color_frame.vkscript", @@ -121,7 +121,6 @@ "multiple_ssbo_update_with_graphics_pipeline.vkscript", "multiple_ssbo_with_sparse_descriptor_set_in_compute_pipeline.vkscript", "multiple_ubo_update_with_graphics_pipeline.vkscript", - "position_to_ssbo.amber", "probe_no_compute_with_multiple_ssbo_commands.vkscript", "probe_no_compute_with_ssbo.vkscript", "repeat.amber", From d59c441bbb5b04449a8a734060d6f00fc1629dfa Mon Sep 17 00:00:00 2001 From: SarahM0 Date: Mon, 8 Jul 2019 17:51:03 -0400 Subject: [PATCH 05/11] add multiple descriptor set support --- src/dawn/engine_dawn.cc | 125 ++++++++++++++++++++++++--------------- src/dawn/engine_dawn.h | 3 - src/dawn/pipeline_info.h | 22 ++++++- 3 files changed, 98 insertions(+), 52 deletions(-) diff --git a/src/dawn/engine_dawn.cc b/src/dawn/engine_dawn.cc index 8f68b6e18..4e6de7972 100644 --- a/src/dawn/engine_dawn.cc +++ b/src/dawn/engine_dawn.cc @@ -44,6 +44,7 @@ static const float kLodMax = 1000.0; static const uint32_t kMaxColorAttachments = 4u; static const uint32_t kMaxVertexInputs = 16u; static const uint32_t kMaxVertexAttributes = 16u; +static const uint32_t kMaxDawnBindGroup = 4u; // This structure is a container for a few variables that are created during // CreateRenderPipelineDescriptor and CreateRenderPassDescriptor and we want to @@ -291,7 +292,7 @@ MapResult MapTextureToHostBuffer(const RenderPipelineInfo& render_pipeline, return map; } -// creates a dawn buffer of |size| bytes with TransferDst and the given usage +// Creates a dawn buffer of |size| bytes with TransferDst and the given usage // copied from Dawn utils source code ::dawn::Buffer CreateBufferFromData(const ::dawn::Device& device, const void* data, @@ -307,7 +308,7 @@ ::dawn::Buffer CreateBufferFromData(const ::dawn::Device& device, return buffer; } -// creates a default sampler descriptor. It does not set the sampling +// Creates a default sampler descriptor. It does not set the sampling // coordinates meaning it's set to default, normalized. // copied from Dawn utils source code ::dawn::SamplerDescriptor GetDefaultSamplerDescriptor() { @@ -403,15 +404,10 @@ ::dawn::BindGroupLayout MakeBindGroupLayout( // Copied from Dawn utils source code. ::dawn::PipelineLayout MakeBasicPipelineLayout( const ::dawn::Device& device, - const ::dawn::BindGroupLayout* bindGroupLayout) { + std::vector<::dawn::BindGroupLayout> bindingInitializer) { ::dawn::PipelineLayoutDescriptor descriptor; - if (bindGroupLayout) { - descriptor.bindGroupLayoutCount = 1; - descriptor.bindGroupLayouts = bindGroupLayout; - } else { - descriptor.bindGroupLayoutCount = 0; - descriptor.bindGroupLayouts = nullptr; - } + descriptor.bindGroupLayoutCount = bindingInitializer.size(); + descriptor.bindGroupLayouts = bindingInitializer.data(); return device.CreatePipelineLayout(&descriptor); } @@ -773,11 +769,8 @@ Result DawnPipelineHelper::CreateRenderPipelineDescriptor( depth_stencil_format = ::dawn::TextureFormat::D32FloatS8Uint; } - if (render_pipeline.bind_group) - renderPipelineDescriptor.layout = - MakeBasicPipelineLayout(device, &render_pipeline.bind_group_layout); - else - renderPipelineDescriptor.layout = MakeBasicPipelineLayout(device, nullptr); + renderPipelineDescriptor.layout = + MakeBasicPipelineLayout(device, render_pipeline.bind_group_layouts); renderPipelineDescriptor.primitiveTopology = ::dawn::PrimitiveTopology::TriangleList; @@ -1047,8 +1040,10 @@ Result EngineDawn::DoDrawRect(const DrawRectCommand* command) { ::dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPassDescriptor); pass.SetPipeline(pipeline); - if (render_pipeline->bind_group) { - pass.SetBindGroup(0, render_pipeline->bind_group, 0, nullptr); + for (uint32_t i = 0; i < render_pipeline->bind_groups.size(); i++) { + if (render_pipeline->bind_groups[i]) { + pass.SetBindGroup(i, render_pipeline->bind_groups[i], 0, nullptr); + } } pass.SetVertexBuffers(0, 1, &vertex_buffer, vertexBufferOffsets); pass.SetIndexBuffer(index_buffer, 0); @@ -1116,10 +1111,11 @@ Result EngineDawn::DoDrawArrays(const DrawArraysCommand* command) { ::dawn::RenderPassEncoder pass = encoder.BeginRenderPass(renderPassDescriptor); pass.SetPipeline(pipeline); - if (render_pipeline->bind_group) { - pass.SetBindGroup(0, render_pipeline->bind_group, 0, nullptr); + for (uint32_t i = 0; i < render_pipeline->bind_groups.size(); i++) { + if (render_pipeline->bind_groups[i]) { + pass.SetBindGroup(i, render_pipeline->bind_groups[i], 0, nullptr); + } } - // TODO(sarahM0): figure out what are startSlot, count and offsets for (uint32_t i = 0; i < render_pipeline->vertex_buffers.size(); i++) { pass.SetVertexBuffers(i, /* startSlot */ @@ -1169,16 +1165,21 @@ Result EngineDawn::DoBuffer(const BufferCommand* command) { if (!command->IsSSBO() && !command->IsUniform()) return Result("DoBuffer not supported buffer type"); - ::dawn::Buffer* dawn_buffer = buffer_map_[command->GetBinding()]; - if (dawn_buffer) { + if (render_pipeline->buffer_map_.find( + {command->GetDescriptorSet(), command->GetBinding()}) != + render_pipeline->buffer_map_.end()) { + auto dawn_buffer_index = + render_pipeline + ->buffer_map_[{command->GetDescriptorSet(), command->GetBinding()}]; + ::dawn::Buffer& dawn_buffer = render_pipeline->buffers_[dawn_buffer_index]; + Buffer* amber_buffer = command->GetBuffer(); if (amber_buffer) { amber_buffer->SetDataWithOffset(command->GetValues(), command->GetOffset()); - dawn_buffer->SetSubData(command->GetOffset(), - amber_buffer->GetSizeInBytes(), - amber_buffer->ValuePtr()->data()); + dawn_buffer.SetSubData(0, amber_buffer->GetSizeInBytes(), + amber_buffer->ValuePtr()->data()); } } return {}; @@ -1199,7 +1200,8 @@ Result EngineDawn::AttachBuffersAndTextures( auto* amber_format = render_pipeline->pipeline->GetColorAttachments()[0].buffer->GetFormat(); if (!amber_format) - return Result("Color attachment 0 has no format!"); + return Result( + "AttachBuffersAndTextures: Color attachment 0 has no format!"); ::dawn::TextureFormat fb_format{}; result = GetDawnTextureFormat(*amber_format, &fb_format); if (!result.IsSuccess()) @@ -1235,7 +1237,9 @@ Result EngineDawn::AttachBuffersAndTextures( if (!depth_stencil_texture_) { auto* amber_depth_stencil_format = depthBuffer->GetFormat(); if (!amber_depth_stencil_format) - return Result("The depth/stencil attachment has no format!"); + return Result( + "AttachBuffersAndTextures: The depth/stencil attachment has no " + "format!"); ::dawn::TextureFormat depth_stencil_format{}; result = GetDawnTextureFormat(*amber_depth_stencil_format, &depth_stencil_format); @@ -1270,14 +1274,19 @@ Result EngineDawn::AttachBuffersAndTextures( // Do not attach pushConstants if (render_pipeline->pipeline->GetPushConstantBuffer().buffer != nullptr) { - return Result("Dawn does not support push constants!"); + return Result( + "AttachBuffersAndTextures: Dawn does not support push constants!"); } ::dawn::ShaderStageBit kAllStages = ::dawn::ShaderStageBit::Vertex | ::dawn::ShaderStageBit::Fragment; - std::vector bindingInitalizerHelper; - std::vector<::dawn::BindGroupLayoutBinding> bindings; + std::vector> bindingInitalizerHelper( + kMaxDawnBindGroup); + std::vector> layouts_info( + kMaxDawnBindGroup); + uint32_t max_descriptor_set = 0; + // Attach storage/uniform buffers for (const auto& buf_info : render_pipeline->pipeline->GetBuffers()) { ::dawn::BufferUsageBit bufferUsage; ::dawn::BindingType bindingType; @@ -1293,38 +1302,60 @@ Result EngineDawn::AttachBuffersAndTextures( break; } default: { - return Result("Dawn: CreatePipeline - unknown buffer type: " + + return Result("AttachBuffersAndTextures: unknown buffer type: " + std::to_string(static_cast( buf_info.buffer->GetBufferType()))); break; } } - buffers_.emplace_back( + if (buf_info.descriptor_set > kMaxDawnBindGroup - 1) { + return Result( + "AttachBuffersAndTextures: Dawn has maximum of 4 bindGroups " + "(descriptor sets)"); + } + + render_pipeline->buffers_.emplace_back( CreateBufferFromData(*device_, buf_info.buffer->ValuePtr()->data(), buf_info.buffer->GetSizeInBytes(), bufferUsage | ::dawn::BufferUsageBit::TransferSrc | ::dawn::BufferUsageBit::TransferDst)); - buffer_map_[buf_info.binding] = &buffers_.back(); + render_pipeline->buffer_map_[{buf_info.descriptor_set, buf_info.binding}] = + render_pipeline->buffers_.size() - 1; + + render_pipeline->used_descriptor_set.insert(buf_info.descriptor_set); + max_descriptor_set = std::max(max_descriptor_set, buf_info.descriptor_set); - ::dawn::BindGroupLayoutBinding bglb; - bglb.binding = buf_info.binding; - bglb.visibility = kAllStages; - bglb.type = bindingType; - bindings.push_back(bglb); + ::dawn::BindGroupLayoutBinding layout_info; + layout_info.binding = buf_info.binding; + layout_info.visibility = kAllStages; + layout_info.type = bindingType; + layouts_info[buf_info.descriptor_set].push_back(layout_info); - BindingInitializationHelper tempBinding = - BindingInitializationHelper(buf_info.binding, buffers_.back(), 0, - buf_info.buffer->GetSizeInBytes()); - bindingInitalizerHelper.push_back(tempBinding); + BindingInitializationHelper tempBinding = BindingInitializationHelper( + buf_info.binding, render_pipeline->buffers_.back(), 0, + buf_info.buffer->GetSizeInBytes()); + bindingInitalizerHelper[buf_info.descriptor_set].push_back(tempBinding); } - if (bindings.size() > 0 && bindingInitalizerHelper.size() > 0) { - render_pipeline->bind_group_layout = - MakeBindGroupLayout(*device_, bindings); - render_pipeline->bind_group = MakeBindGroup( - *device_, render_pipeline->bind_group_layout, bindingInitalizerHelper); + // TODO(sarahM0): investigate if Dawn support sparse descriptor sets + if (render_pipeline->used_descriptor_set.size() - 1 != max_descriptor_set) { + return Result( + "AttachBuffersAndTextures: sparse descriptor_set is not supported"); + } + + for (uint32_t i = 0; i < kMaxDawnBindGroup; i++) { + if (layouts_info[i].size() > 0 && bindingInitalizerHelper[i].size() > 0) { + ::dawn::BindGroupLayout bindGroupLayout = + MakeBindGroupLayout(*device_, layouts_info[i]); + render_pipeline->bind_group_layouts.push_back(bindGroupLayout); + + ::dawn::BindGroup bindGroup = + MakeBindGroup(*device_, render_pipeline->bind_group_layouts[i], + bindingInitalizerHelper[i]); + render_pipeline->bind_groups.push_back(bindGroup); + } } return {}; diff --git a/src/dawn/engine_dawn.h b/src/dawn/engine_dawn.h index 521ecf758..b6e736ac7 100644 --- a/src/dawn/engine_dawn.h +++ b/src/dawn/engine_dawn.h @@ -89,9 +89,6 @@ class EngineDawn : public Engine { // Mapping from the generic engine's Pipeline object to our own Dawn-specific // pipelines. std::unordered_map pipeline_map_; - - std::unordered_map buffer_map_; - std::vector<::dawn::Buffer> buffers_; }; } // namespace dawn diff --git a/src/dawn/pipeline_info.h b/src/dawn/pipeline_info.h index 7825e9505..f825766af 100644 --- a/src/dawn/pipeline_info.h +++ b/src/dawn/pipeline_info.h @@ -17,6 +17,8 @@ #include #include +#include +#include #include #include @@ -28,6 +30,15 @@ namespace amber { namespace dawn { +struct hash_pair { + template + size_t operator()(const std::pair& p) const { + auto hash1 = std::hash{}(p.first); + auto hash2 = std::hash{}(p.second); + return hash1 ^ hash2; + } +}; + /// Stores information relating to a graphics pipeline in Dawn. struct RenderPipelineInfo { RenderPipelineInfo() {} @@ -53,9 +64,16 @@ struct RenderPipelineInfo { ::dawn::Buffer fb_buffer; std::vector<::dawn::Buffer> vertex_buffers; ::dawn::Buffer index_buffer; + /// storage and uniform buffers + std::vector<::dawn::Buffer> buffers_; + + std::vector<::dawn::BindGroup> bind_groups; + std::vector<::dawn::BindGroupLayout> bind_group_layouts; - ::dawn::BindGroup bind_group; - ::dawn::BindGroupLayout bind_group_layout; + // Mapping from the to dawn buffer index in buffers_ + std::unordered_map, uint32_t, hash_pair> + buffer_map_; + std::set used_descriptor_set; }; /// Stores information relating to a compute pipeline in Dawn. From 30a072fd7036f1ce8a9c7d86ed3d96b5031389dd Mon Sep 17 00:00:00 2001 From: SarahM0 Date: Tue, 9 Jul 2019 12:59:56 -0400 Subject: [PATCH 06/11] clean up test script - fix a few unsupported formats in tests --- src/dawn/engine_dawn.cc | 15 +++-- .../cases/draw_array_after_draw_rect.vkscript | 5 +- tests/cases/draw_rectangles_once.vkscript | 5 +- .../draw_rectangles_without_probe.vkscript | 5 +- .../draw_triangle_list_with_depth.vkscript | 62 +++++++++---------- ...w_triangle_list_with_index_buffer.vkscript | 44 ++++++------- ...th_index_buffer_and_vertex_offset.vkscript | 56 ++++++++--------- .../draw_triangle_list_without_probe.vkscript | 18 +++--- tests/run_tests.py | 12 ++-- 9 files changed, 107 insertions(+), 115 deletions(-) diff --git a/src/dawn/engine_dawn.cc b/src/dawn/engine_dawn.cc index 4e6de7972..596ff492c 100644 --- a/src/dawn/engine_dawn.cc +++ b/src/dawn/engine_dawn.cc @@ -501,6 +501,9 @@ Result GetDawnVertexFormat(const ::amber::Format& amber_format, case FormatType::kR8G8B8A8_UNORM: dawn_format = ::dawn::VertexFormat::UChar4Norm; break; + case FormatType::kR8G8B8A8_SNORM: + dawn_format = ::dawn::VertexFormat::Char4Norm; + break; default: return Result( "Amber vertex format " + @@ -1161,9 +1164,9 @@ Result EngineDawn::DoBuffer(const BufferCommand* command) { // TODO(SarahM0): Make this work for compute pipeline RenderPipelineInfo* render_pipeline = GetRenderPipeline(command); if (!render_pipeline) - return Result("DoBuffer invoked on invalid or missing render pipeline"); + return Result("DoBuffer: invoked on invalid or missing render pipeline"); if (!command->IsSSBO() && !command->IsUniform()) - return Result("DoBuffer not supported buffer type"); + return Result("DoBuffer: only supports SSBO and uniform buffer type"); if (render_pipeline->buffer_map_.find( {command->GetDescriptorSet(), command->GetBinding()}) != @@ -1339,10 +1342,12 @@ Result EngineDawn::AttachBuffersAndTextures( bindingInitalizerHelper[buf_info.descriptor_set].push_back(tempBinding); } - // TODO(sarahM0): investigate if Dawn support sparse descriptor sets - if (render_pipeline->used_descriptor_set.size() - 1 != max_descriptor_set) { + // TODO(sarahM0): fix issue: Add support for doBuffer with sparse descriptor + // sets #573 + if (render_pipeline->used_descriptor_set.size() != 0 && + render_pipeline->used_descriptor_set.size() != max_descriptor_set + 1) { return Result( - "AttachBuffersAndTextures: sparse descriptor_set is not supported"); + "AttachBuffersAndTextures: Sparse descriptor_set is not supported"); } for (uint32_t i = 0; i < kMaxDawnBindGroup; i++) { diff --git a/tests/cases/draw_array_after_draw_rect.vkscript b/tests/cases/draw_array_after_draw_rect.vkscript index 9f9dcc90b..4b9804946 100644 --- a/tests/cases/draw_array_after_draw_rect.vkscript +++ b/tests/cases/draw_array_after_draw_rect.vkscript @@ -12,16 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -[require] -vertexPipelineStoresAndAtomics - [vertex shader] #version 430 layout(location = 0) in vec4 position; layout(location = 0) out vec4 frag_color; -layout(set = 0, binding = 0) buffer block1 { +layout(set = 0, binding = 0) readonly buffer block1 { vec4 in_color; }; diff --git a/tests/cases/draw_rectangles_once.vkscript b/tests/cases/draw_rectangles_once.vkscript index 0a77382ff..039a75c70 100644 --- a/tests/cases/draw_rectangles_once.vkscript +++ b/tests/cases/draw_rectangles_once.vkscript @@ -12,16 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -[require] -vertexPipelineStoresAndAtomics - [vertex shader] #version 430 layout(location = 0) in vec4 position; layout(location = 0) out vec4 frag_color; -layout(set = 0, binding = 0) buffer block1 { +layout(set = 0, binding = 0) readonly buffer block1 { vec4 in_color; }; diff --git a/tests/cases/draw_rectangles_without_probe.vkscript b/tests/cases/draw_rectangles_without_probe.vkscript index 70a843353..173e15412 100644 --- a/tests/cases/draw_rectangles_without_probe.vkscript +++ b/tests/cases/draw_rectangles_without_probe.vkscript @@ -12,16 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -[require] -vertexPipelineStoresAndAtomics - [vertex shader] #version 430 layout(location = 0) in vec4 position; layout(location = 0) out vec4 frag_color; -layout(set = 0, binding = 0) buffer block1 { +layout(set = 0, binding = 0) readonly buffer block1 { vec4 in_color; }; diff --git a/tests/cases/draw_triangle_list_with_depth.vkscript b/tests/cases/draw_triangle_list_with_depth.vkscript index 56677f503..bfa46d35b 100644 --- a/tests/cases/draw_triangle_list_with_depth.vkscript +++ b/tests/cases/draw_triangle_list_with_depth.vkscript @@ -39,44 +39,44 @@ void main() { [vertex data] # position vert_color - 0/R8G8B8_SNORM 1/R8G8B8_UNORM + 0/R8G8B8A8_SNORM 1/R8G8B8A8_UNORM # Red for entire frame -# R8 G8 B8 R8 G8 B8 - -128 -128 3 255 0 0 - 127 127 3 255 0 0 - -128 127 3 255 0 0 +# R8 G8 B8 A8 R8 G8 B8 A8 + -128 -128 3 127 255 0 0 0 + 127 127 3 127 255 0 0 0 + -128 127 3 127 255 0 0 0 - -128 -128 3 255 0 0 - 127 127 3 255 0 0 - 127 -128 3 255 0 0 + -128 -128 3 127 255 0 0 0 + 127 127 3 127 255 0 0 0 + 127 -128 3 127 255 0 0 0 # Green for half frame - 0 -128 2 0 255 0 - 127 127 2 0 255 0 - 0 127 2 0 255 0 + 0 -128 2 127 0 255 0 0 + 127 127 2 127 0 255 0 0 + 0 127 2 127 0 255 0 0 - 0 -128 2 0 255 0 - 127 127 2 0 255 0 - 127 -128 2 0 255 0 + 0 -128 2 127 0 255 0 0 + 127 127 2 127 0 255 0 0 + 127 -128 2 127 0 255 0 0 # Blue for quarter frame - -128 0 1 0 0 255 - 0 127 1 0 0 255 - -128 127 1 0 0 255 + -128 0 1 127 0 0 255 0 + 0 127 1 127 0 0 255 0 + -128 127 1 127 0 0 255 0 - -128 0 1 0 0 255 - 0 127 1 0 0 255 - 0 0 1 0 0 255 + -128 0 1 127 0 0 255 0 + 0 127 1 127 0 0 255 0 + 0 0 1 127 0 0 255 0 -# Mixed color for quarter frame - 0 0 0 127 127 127 - 127 127 0 127 127 127 - 0 127 0 127 127 127 +# Mixed color for quarter frame + 0 0 0 127 127 127 127 0 + 127 127 0 127 127 127 127 0 + 0 127 0 127 127 127 127 0 - 0 0 0 127 127 127 - 127 127 0 127 127 127 - 127 0 0 127 127 127 + 0 0 0 127 127 127 127 0 + 127 127 0 127 127 127 127 0 + 127 0 0 127 127 127 127 0 [test] clear @@ -95,7 +95,7 @@ draw arrays TRIANGLE_LIST 6 6 draw arrays TRIANGLE_LIST 0 6 # The final frame buffer shows all red, green, blue, and mixed color. -relative probe rect rgb (0.0, 0.0, 0.5, 0.5) (1.0, 0, 0) -relative probe rect rgb (0.5, 0.0, 0.5, 0.5) (0, 1.0, 0) -relative probe rect rgb (0.0, 0.5, 0.5, 0.5) (0, 0, 1.0) -relative probe rect rgb (0.5, 0.5, 0.5, 0.5) (0.5, 0.5, 0.5) +relative probe rect rgba (0.0, 0.0, 0.5, 0.5) (1.0, 0, 0, 0) +relative probe rect rgba (0.5, 0.0, 0.5, 0.5) (0, 1.0, 0, 0) +relative probe rect rgba (0.0, 0.5, 0.5, 0.5) (0, 0, 1.0, 0) +relative probe rect rgba (0.5, 0.5, 0.5, 0.5) (0.5, 0.5, 0.5, 0) diff --git a/tests/cases/draw_triangle_list_with_index_buffer.vkscript b/tests/cases/draw_triangle_list_with_index_buffer.vkscript index 3e0c2d1ec..b3f7f67a5 100644 --- a/tests/cases/draw_triangle_list_with_index_buffer.vkscript +++ b/tests/cases/draw_triangle_list_with_index_buffer.vkscript @@ -42,41 +42,41 @@ void main() { [vertex data] # position vert_color - 0/R8G8_SNORM 1/R8G8B8_UNORM + 0/R8G8_SNORM 1/R8G8B8A8_UNORM # Red for entire frame -# R8 G8 R8 G8 B8 - -128 -128 255 0 0 - 127 127 255 0 0 - -128 127 255 0 0 - 127 -128 255 0 0 +# R8 G8 R8 G8 B8 A8 + -128 -128 255 0 0 255 + 127 127 255 0 0 255 + -128 127 255 0 0 255 + 127 -128 255 0 0 255 # Green for half frame # R8 G8 R8 G8 B8 - 0 -128 0 255 0 - 127 127 0 255 0 - 0 127 0 255 0 - 127 -128 0 255 0 + 0 -128 0 255 0 255 + 127 127 0 255 0 255 + 0 127 0 255 0 255 + 127 -128 0 255 0 255 # Blue for quarter frame # R8 G8 R8 G8 B8 - -128 0 0 0 255 - 0 127 0 0 255 - -128 127 0 0 255 - 0 0 0 0 255 + -128 0 0 0 255 255 + 0 127 0 0 255 255 + -128 127 0 0 255 255 + 0 0 0 0 255 255 # Mixed color for quarter frame # R8 G8 R8 G8 B8 - 0 0 127 127 127 - 127 127 127 127 127 - 0 127 127 127 127 - 127 0 127 127 127 + 0 0 127 127 127 255 + 127 127 127 127 127 255 + 0 127 127 127 127 255 + 127 0 127 127 127 255 [test] clear draw arrays indexed TRIANGLE_LIST 0 24 -relative probe rect rgb (0.0, 0.0, 0.5, 0.5) (1.0, 0, 0) -relative probe rect rgb (0.5, 0.0, 0.5, 0.5) (0, 1.0, 0) -relative probe rect rgb (0.0, 0.5, 0.5, 0.5) (0, 0, 1.0) -relative probe rect rgb (0.5, 0.5, 0.5, 0.5) (0.5, 0.5, 0.5) +relative probe rect rgba (0.0, 0.0, 0.5, 0.5) (1.0, 0, 0, 1.0) +relative probe rect rgba (0.5, 0.0, 0.5, 0.5) (0, 1.0, 0, 1.0) +relative probe rect rgba (0.0, 0.5, 0.5, 0.5) (0, 0, 1.0, 1.0) +relative probe rect rgba (0.5, 0.5, 0.5, 0.5) (0.5, 0.5, 0.5, 1.0) diff --git a/tests/cases/draw_triangle_list_with_index_buffer_and_vertex_offset.vkscript b/tests/cases/draw_triangle_list_with_index_buffer_and_vertex_offset.vkscript index aaae91e4d..4e6be2ee1 100644 --- a/tests/cases/draw_triangle_list_with_index_buffer_and_vertex_offset.vkscript +++ b/tests/cases/draw_triangle_list_with_index_buffer_and_vertex_offset.vkscript @@ -39,35 +39,35 @@ void main() { [vertex data] # position vert_color - 0/R8G8_SNORM 1/R8G8B8_UNORM + 0/R8G8_SNORM 1/R8G8B8A8_UNORM # Red for entire frame -# R8 G8 R8 G8 B8 - -128 -128 255 0 0 - 127 127 255 0 0 - -128 127 255 0 0 - 127 -128 255 0 0 +# R8 G8 R8 G8 B8 A8 + -128 -128 255 0 0 255 + 127 127 255 0 0 255 + -128 127 255 0 0 255 + 127 -128 255 0 0 255 # Green for half frame # R8 G8 R8 G8 B8 - 0 -128 0 255 0 - 127 127 0 255 0 - 0 127 0 255 0 - 127 -128 0 255 0 + 0 -128 0 255 0 255 + 127 127 0 255 0 255 + 0 127 0 255 0 255 + 127 -128 0 255 0 255 # Blue for quarter frame # R8 G8 R8 G8 B8 - -128 0 0 0 255 - 0 127 0 0 255 - -128 127 0 0 255 - 0 0 0 0 255 + -128 0 0 0 255 255 + 0 127 0 0 255 255 + -128 127 0 0 255 255 + 0 0 0 0 255 255 # Mixed color for quarter frame # R8 G8 R8 G8 B8 - 0 0 127 127 127 - 127 127 127 127 127 - 0 127 127 127 127 - 127 0 127 127 127 + 0 0 127 127 127 255 + 127 127 127 127 127 255 + 0 127 127 127 127 255 + 127 0 127 127 127 255 [test] clear @@ -79,7 +79,7 @@ clear # | # V draw arrays indexed TRIANGLE_LIST 0 6 -relative probe rect rgb (0.0, 0.0, 1.0, 1.0) (1.0, 0, 0) +relative probe rect rgba (0.0, 0.0, 1.0, 1.0) (1.0, 0, 0, 1.0) # "4" means the fifth vertex among # vertices which is shown in line 53. @@ -88,8 +88,8 @@ relative probe rect rgb (0.0, 0.0, 1.0, 1.0) (1.0, 0, 0) # | # V draw arrays indexed TRIANGLE_LIST 4 6 -relative probe rect rgb (0.0, 0.0, 0.5, 1.0) (1.0, 0, 0) -relative probe rect rgb (0.5, 0.0, 0.5, 1.0) (0, 1.0, 0) +relative probe rect rgba (0.0, 0.0, 0.5, 1.0) (1.0, 0, 0, 1.0) +relative probe rect rgba (0.5, 0.0, 0.5, 1.0) (0, 1.0, 0, 1.0) # "8" means the nineth vertex among # vertices which is shown in line 60. @@ -98,9 +98,9 @@ relative probe rect rgb (0.5, 0.0, 0.5, 1.0) (0, 1.0, 0) # | # V draw arrays indexed TRIANGLE_LIST 8 6 -relative probe rect rgb (0.0, 0.0, 0.5, 0.5) (1.0, 0, 0) -relative probe rect rgb (0.5, 0.0, 0.5, 1.0) (0, 1.0, 0) -relative probe rect rgb (0.0, 0.5, 0.5, 0.5) (0, 0, 1.0) +relative probe rect rgba (0.0, 0.0, 0.5, 0.5) (1.0, 0, 0, 1.0) +relative probe rect rgba (0.5, 0.0, 0.5, 1.0) (0, 1.0, 0, 1.0) +relative probe rect rgba (0.0, 0.5, 0.5, 0.5) (0, 0, 1.0, 1.0) # "12" means the thirteenth vertex among # vertices which is shown in line 60. @@ -109,7 +109,7 @@ relative probe rect rgb (0.0, 0.5, 0.5, 0.5) (0, 0, 1.0) # | # V draw arrays indexed TRIANGLE_LIST 12 6 -relative probe rect rgb (0.0, 0.0, 0.5, 0.5) (1.0, 0, 0) -relative probe rect rgb (0.5, 0.0, 0.5, 0.5) (0, 1.0, 0) -relative probe rect rgb (0.0, 0.5, 0.5, 0.5) (0, 0, 1.0) -relative probe rect rgb (0.5, 0.5, 0.5, 0.5) (0.5, 0.5, 0.5) +relative probe rect rgba (0.0, 0.0, 0.5, 0.5) (1.0, 0, 0, 1.0) +relative probe rect rgba (0.5, 0.0, 0.5, 0.5) (0, 1.0, 0, 1.0) +relative probe rect rgba (0.0, 0.5, 0.5, 0.5) (0, 0, 1.0, 1.0) +relative probe rect rgba (0.5, 0.5, 0.5, 0.5) (0.5, 0.5, 0.5, 1.0) diff --git a/tests/cases/draw_triangle_list_without_probe.vkscript b/tests/cases/draw_triangle_list_without_probe.vkscript index 646a0d28f..dbaac5b2e 100644 --- a/tests/cases/draw_triangle_list_without_probe.vkscript +++ b/tests/cases/draw_triangle_list_without_probe.vkscript @@ -36,17 +36,17 @@ void main() { [vertex data] # position vert_color - 0/R8G8_SNORM 1/R8G8B8_UNORM + 0/R8G8_SNORM 1/R8G8B8A8_UNORM # Red for entire frame -# R8 G8 R8 G8 B8 - -128 -128 255 0 0 - 127 127 255 0 0 - -128 127 255 0 0 - - -128 -128 255 0 0 - 127 127 255 0 0 - 127 -128 255 0 0 +# R8 G8 R8 G8 B8 A8 + -128 -128 255 0 0 0 + 127 127 255 0 0 0 + -128 127 255 0 0 0 + + -128 -128 255 0 0 0 + 127 127 255 0 0 0 + 127 -128 255 0 0 0 [test] draw arrays TRIANGLE_LIST 0 6 diff --git a/tests/run_tests.py b/tests/run_tests.py index 577809a04..e3cce79d4 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -55,9 +55,12 @@ } SUPPRESSIONS_DAWN = [ + # Dawn does not support push constants + "graphics_push_constants.amber", + "graphics_push_constants.vkscript", # Dawn requires a fragmentStage now and in the medium term "position_to_ssbo.amber", - # not implemented in Dawn backend + # Compute pipeline is not implemented in Dawn backend "compute_accumulated_ubo_definition.amber", "compute_accumulated_ubo_definition.vkscript", "compute_mat2x2.amber", @@ -99,11 +102,8 @@ "draw_array_after_draw_rect.vkscript", "draw_rect_after_draw_array.vkscript", "draw_rect_and_draw_array_mixed.vkscript", - "draw_rect_and_ortho.vkscript", "draw_rect_multiple_color_attachment.amber", "draw_rectangles.vkscript", - "draw_rectangles_once.vkscript", - "draw_rectangles_without_probe.vkscript", "draw_triangle_list_in_r16g16b16a16_snorm_color_frame.vkscript", "draw_triangle_list_in_r16g16b16a16_uint_color_frame.vkscript", "draw_triangle_list_in_r32g32b32a32_sfloat_color_frame.vkscript", @@ -112,12 +112,9 @@ "draw_triangle_list_using_geom_shader.vkscript", "draw_triangle_list_using_tessellation.vkscript", "draw_triangle_list_with_depth.vkscript", - "draw_triangle_list_with_index_buffer.vkscript", "draw_triangle_list_with_index_buffer_and_vertex_offset.vkscript", "draw_triangle_list_with_probe_point.vkscript", "entry_point.amber", - "graphics_push_constants.amber", - "graphics_push_constants.vkscript", "multiple_ssbo_update_with_graphics_pipeline.vkscript", "multiple_ssbo_with_sparse_descriptor_set_in_compute_pipeline.vkscript", "multiple_ubo_update_with_graphics_pipeline.vkscript", @@ -127,7 +124,6 @@ "scratch_ssbo.vkscript", "shader_specialization.amber", "ssbo_subdata_size.vkscript", - "ssbo_with_graphics_pipeline.vkscript" ] class TestCase: From 797d326f9923d641e66f98fe5bd64016e183a01a Mon Sep 17 00:00:00 2001 From: SarahM0 Date: Tue, 9 Jul 2019 13:22:49 -0400 Subject: [PATCH 07/11] clean up test script --- tests/cases/draw_rectangles.vkscript | 3 +-- tests/run_tests.py | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/tests/cases/draw_rectangles.vkscript b/tests/cases/draw_rectangles.vkscript index 58f9b5889..a35663da3 100644 --- a/tests/cases/draw_rectangles.vkscript +++ b/tests/cases/draw_rectangles.vkscript @@ -13,7 +13,6 @@ # limitations under the License. [require] -vertexPipelineStoresAndAtomics fbsize 800 600 [vertex shader] @@ -22,7 +21,7 @@ fbsize 800 600 layout(location = 0) in vec4 position; layout(location = 0) out vec4 frag_color; -layout(set = 0, binding = 0) buffer block1 { +layout(set = 0, binding = 0) readonly buffer block1 { vec4 in_color; }; diff --git a/tests/run_tests.py b/tests/run_tests.py index e3cce79d4..b97c54eca 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -60,7 +60,7 @@ "graphics_push_constants.vkscript", # Dawn requires a fragmentStage now and in the medium term "position_to_ssbo.amber", - # Compute pipeline is not implemented in Dawn backend + # DoCompute is not implemented in Dawn backend "compute_accumulated_ubo_definition.amber", "compute_accumulated_ubo_definition.vkscript", "compute_mat2x2.amber", @@ -99,11 +99,24 @@ "compute_ssbo_with_tolerance.vkscript", "compute_ssbo_without_probe.vkscript", "compute_ubo_and_ssbo.vkscript", + "repeat.amber", + "scratch_ssbo.vkscript", + "shader_specialization.amber", + "ssbo_subdata_size.vkscript", + # Dawn DoCommands require a pipeline + "probe_no_compute_with_multiple_ssbo_commands.vkscript", + "probe_no_compute_with_ssbo.vkscript", + # Sparse descriptor sets are not in Dawn backend + "multiple_ssbo_update_with_graphics_pipeline.vkscript", + "multiple_ssbo_with_sparse_descriptor_set_in_compute_pipeline.vkscript", + "multiple_ubo_update_with_graphics_pipeline.vkscript", + # DoEntryPoint is not supported in Dawn backend + "entry_point.amber", + # Currently not working, under investigation "draw_array_after_draw_rect.vkscript", "draw_rect_after_draw_array.vkscript", "draw_rect_and_draw_array_mixed.vkscript", "draw_rect_multiple_color_attachment.amber", - "draw_rectangles.vkscript", "draw_triangle_list_in_r16g16b16a16_snorm_color_frame.vkscript", "draw_triangle_list_in_r16g16b16a16_uint_color_frame.vkscript", "draw_triangle_list_in_r32g32b32a32_sfloat_color_frame.vkscript", @@ -114,16 +127,6 @@ "draw_triangle_list_with_depth.vkscript", "draw_triangle_list_with_index_buffer_and_vertex_offset.vkscript", "draw_triangle_list_with_probe_point.vkscript", - "entry_point.amber", - "multiple_ssbo_update_with_graphics_pipeline.vkscript", - "multiple_ssbo_with_sparse_descriptor_set_in_compute_pipeline.vkscript", - "multiple_ubo_update_with_graphics_pipeline.vkscript", - "probe_no_compute_with_multiple_ssbo_commands.vkscript", - "probe_no_compute_with_ssbo.vkscript", - "repeat.amber", - "scratch_ssbo.vkscript", - "shader_specialization.amber", - "ssbo_subdata_size.vkscript", ] class TestCase: From 47a4769eb6ff3b75b4e11b9a345b55885f104469 Mon Sep 17 00:00:00 2001 From: SarahM0 Date: Tue, 9 Jul 2019 14:02:33 -0400 Subject: [PATCH 08/11] test script clean up --- tests/run_tests.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/run_tests.py b/tests/run_tests.py index b97c54eca..1677db6f5 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -106,22 +106,25 @@ # Dawn DoCommands require a pipeline "probe_no_compute_with_multiple_ssbo_commands.vkscript", "probe_no_compute_with_ssbo.vkscript", - # Sparse descriptor sets are not in Dawn backend + # Sparse descriptor sets are not supported in Dawn backend (issue #573) "multiple_ssbo_update_with_graphics_pipeline.vkscript", "multiple_ssbo_with_sparse_descriptor_set_in_compute_pipeline.vkscript", "multiple_ubo_update_with_graphics_pipeline.vkscript", # DoEntryPoint is not supported in Dawn backend "entry_point.amber", - # Currently not working, under investigation - "draw_array_after_draw_rect.vkscript", - "draw_rect_after_draw_array.vkscript", - "draw_rect_and_draw_array_mixed.vkscript", - "draw_rect_multiple_color_attachment.amber", + # framebuffer format is not supported according to table "Mandatory format + # support" in Vulkan spec: VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT = 0 "draw_triangle_list_in_r16g16b16a16_snorm_color_frame.vkscript", "draw_triangle_list_in_r16g16b16a16_uint_color_frame.vkscript", "draw_triangle_list_in_r32g32b32a32_sfloat_color_frame.vkscript", "draw_triangle_list_in_r8g8b8a8_snorm_color_frame.vkscript", "draw_triangle_list_in_r8g8b8a8_srgb_color_frame.vkscript", + # Currently not working, an issue is created + "draw_rect_multiple_color_attachment.amber", + # Currently not working, under investigation + "draw_array_after_draw_rect.vkscript", + "draw_rect_after_draw_array.vkscript", + "draw_rect_and_draw_array_mixed.vkscript", "draw_triangle_list_using_geom_shader.vkscript", "draw_triangle_list_using_tessellation.vkscript", "draw_triangle_list_with_depth.vkscript", From 38b83e48da0508f2c0ceb66239ff43baad010a09 Mon Sep 17 00:00:00 2001 From: SarahM0 Date: Tue, 9 Jul 2019 14:41:11 -0400 Subject: [PATCH 09/11] dawn does not support geom shaders or tessellation --- tests/run_tests.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/run_tests.py b/tests/run_tests.py index 1677db6f5..fadfc4ca4 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -55,9 +55,11 @@ } SUPPRESSIONS_DAWN = [ - # Dawn does not support push constants + # Dawn does not support push constants, tessellation, geometry shader "graphics_push_constants.amber", "graphics_push_constants.vkscript", + "draw_triangle_list_using_geom_shader.vkscript", + "draw_triangle_list_using_tessellation.vkscript", # Dawn requires a fragmentStage now and in the medium term "position_to_ssbo.amber", # DoCompute is not implemented in Dawn backend @@ -125,8 +127,6 @@ "draw_array_after_draw_rect.vkscript", "draw_rect_after_draw_array.vkscript", "draw_rect_and_draw_array_mixed.vkscript", - "draw_triangle_list_using_geom_shader.vkscript", - "draw_triangle_list_using_tessellation.vkscript", "draw_triangle_list_with_depth.vkscript", "draw_triangle_list_with_index_buffer_and_vertex_offset.vkscript", "draw_triangle_list_with_probe_point.vkscript", From 658bcccc9b770dd2737d2697e393794065edf10c Mon Sep 17 00:00:00 2001 From: SarahM0 Date: Tue, 9 Jul 2019 17:31:58 -0400 Subject: [PATCH 10/11] no need to resize in ssbo --- src/vkscript/command_parser.cc | 4 - .../cases/draw_rect_after_draw_array.vkscript | 5 +- .../draw_rect_and_draw_array_mixed.vkscript | 5 +- ...aw_triangle_list_with_probe_point.vkscript | 110 ++++++++---------- tests/run_tests.py | 3 - 5 files changed, 51 insertions(+), 76 deletions(-) diff --git a/src/vkscript/command_parser.cc b/src/vkscript/command_parser.cc index 1babe0dc8..ac2ca91fc 100644 --- a/src/vkscript/command_parser.cc +++ b/src/vkscript/command_parser.cc @@ -633,10 +633,6 @@ Result CommandParser::ProcessSSBO() { if (value_count > buf->ValueCount()) buf->SetValueCount(value_count); - // Even if the value count doesn't change, the buffer is still resized - // because this maybe the first time data is set into the buffer. - buf->ResizeTo(buf->GetSizeInBytes()); - cmd->SetValues(std::move(values)); } else { diff --git a/tests/cases/draw_rect_after_draw_array.vkscript b/tests/cases/draw_rect_after_draw_array.vkscript index c1a1dec7d..2f9b34452 100644 --- a/tests/cases/draw_rect_after_draw_array.vkscript +++ b/tests/cases/draw_rect_after_draw_array.vkscript @@ -12,16 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -[require] -vertexPipelineStoresAndAtomics - [vertex shader] #version 430 layout(location = 0) in vec4 position; layout(location = 0) out vec4 frag_color; -layout(set = 0, binding = 0) buffer block1 { +layout(set = 0, binding = 0) readonly buffer block1 { vec4 in_color; }; diff --git a/tests/cases/draw_rect_and_draw_array_mixed.vkscript b/tests/cases/draw_rect_and_draw_array_mixed.vkscript index 4452aad59..3fdc29bc9 100644 --- a/tests/cases/draw_rect_and_draw_array_mixed.vkscript +++ b/tests/cases/draw_rect_and_draw_array_mixed.vkscript @@ -12,16 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -[require] -vertexPipelineStoresAndAtomics - [vertex shader] #version 430 layout(location = 0) in vec4 position; layout(location = 0) out vec4 frag_color; -layout(set = 0, binding = 0) buffer block1 { +layout(set = 0, binding = 0) readonly buffer block1 { vec4 in_color; }; diff --git a/tests/cases/draw_triangle_list_with_probe_point.vkscript b/tests/cases/draw_triangle_list_with_probe_point.vkscript index bdbe2b0bc..c21020831 100644 --- a/tests/cases/draw_triangle_list_with_probe_point.vkscript +++ b/tests/cases/draw_triangle_list_with_probe_point.vkscript @@ -36,86 +36,74 @@ void main() { [vertex data] # position vert_color - 0/R8G8_SNORM 1/R8G8B8_UNORM + 0/R8G8_SNORM 1/R8G8B8A8_UNORM # Red for entire frame -# R8 G8 R8 G8 B8 - -128 -128 255 0 0 - 127 127 255 0 0 - -128 127 255 0 0 - - -128 -128 255 0 0 - 127 127 255 0 0 - 127 -128 255 0 0 +# R8 G8 R8 G8 B8 A8 + -128 -128 255 0 0 255 + 127 127 255 0 0 255 + -128 127 255 0 0 255 + 127 -128 255 0 0 255 # Green for half frame # R8 G8 R8 G8 B8 - 0 -128 0 255 0 - 127 127 0 255 0 - 0 127 0 255 0 - - 0 -128 0 255 0 - 127 127 0 255 0 - 127 -128 0 255 0 + 0 -128 0 255 0 255 + 127 127 0 255 0 255 + 0 127 0 255 0 255 + 127 -128 0 255 0 255 # Blue for quarter frame # R8 G8 R8 G8 B8 - -128 0 0 0 255 - 0 127 0 0 255 - -128 127 0 0 255 - - -128 0 0 0 255 - 0 127 0 0 255 - 0 0 0 0 255 + -128 0 0 0 255 255 + 0 127 0 0 255 255 + -128 127 0 0 255 255 + 0 0 0 0 255 255 # Mixed color for quarter frame # R8 G8 R8 G8 B8 - 0 0 128 128 128 - 127 127 128 128 128 - 0 127 128 128 128 - - 0 0 128 128 128 - 127 127 128 128 128 - 127 0 128 128 128 + 0 0 127 127 127 255 + 127 127 127 127 127 255 + 0 127 127 127 127 255 + 127 0 127 127 127 255 [test] clear draw arrays TRIANGLE_LIST 0 6 -relative probe rgb (0.9, 0.9) (1.0, 0, 0) -relative probe rgb (0.5, 0.5) (1.0, 0, 0) -relative probe rgb (0.1, 0.7) (1.0, 0, 0) -relative probe rgb (0.8, 0.3) (1.0, 0, 0) +relative probe rgba (0.9, 0.9) (1.0, 0, 0, 1.0) +relative probe rgba (0.5, 0.5) (1.0, 0, 0, 1.0) +relative probe rgba (0.1, 0.7) (1.0, 0, 0, 1.0) +relative probe rgba (0.8, 0.3) (1.0, 0, 0, 1.0) draw arrays TRIANGLE_LIST 6 6 -relative probe rgb (0.0, 0.0) (1.0, 0, 0) -relative probe rgb (0.3, 0.7) (1.0, 0, 0) -relative probe rgb (0.4, 0.9) (1.0, 0, 0) -relative probe rgb (0.5, 0.0) (0, 1.0, 0) -relative probe rgb (0.8, 0.7) (0, 1.0, 0) -relative probe rgb (0.9, 0.9) (0, 1.0, 0) +relative probe rgba (0.0, 0.0) (1.0, 0, 0, 1.0) +relative probe rgba (0.3, 0.7) (1.0, 0, 0, 1.0) +relative probe rgba (0.4, 0.9) (1.0, 0, 0, 1.0) +relative probe rgba (0.5, 0.0) (0, 1.0, 0, 1.0) +relative probe rgba (0.8, 0.7) (0, 1.0, 0, 1.0) +relative probe rgba (0.9, 0.9) (0, 1.0, 0, 1.0) draw arrays TRIANGLE_LIST 12 6 -relative probe rgb (0.0, 0.0) (1.0, 0, 0) -relative probe rgb (0.3, 0.2) (1.0, 0, 0) -relative probe rgb (0.4, 0.4) (1.0, 0, 0) -relative probe rgb (0.5, 0.0) (0, 1.0, 0) -relative probe rgb (0.8, 0.7) (0, 1.0, 0) -relative probe rgb (0.9, 0.9) (0, 1.0, 0) -relative probe rgb (0.0, 0.5) (0, 0, 1.0) -relative probe rgb (0.3, 0.7) (0, 0, 1.0) -relative probe rgb (0.4, 0.9) (0, 0, 1.0) +relative probe rgba (0.0, 0.0) (1.0, 0, 0, 1.0) +relative probe rgba (0.3, 0.2) (1.0, 0, 0, 1.0) +relative probe rgba (0.4, 0.4) (1.0, 0, 0, 1.0) +relative probe rgba (0.5, 0.0) (0, 1.0, 0, 1.0) +relative probe rgba (0.8, 0.7) (0, 1.0, 0, 1.0) +relative probe rgba (0.9, 0.9) (0, 1.0, 0, 1.0) +relative probe rgba (0.0, 0.5) (0, 0, 1.0, 1.0) +relative probe rgba (0.3, 0.7) (0, 0, 1.0, 1.0) +relative probe rgba (0.4, 0.9) (0, 0, 1.0, 1.0) draw arrays TRIANGLE_LIST 18 6 -relative probe rgb (0.0, 0.0) (1.0, 0, 0) -relative probe rgb (0.3, 0.2) (1.0, 0, 0) -relative probe rgb (0.4, 0.4) (1.0, 0, 0) -relative probe rgb (0.5, 0.0) (0, 1.0, 0) -relative probe rgb (0.8, 0.2) (0, 1.0, 0) -relative probe rgb (0.9, 0.4) (0, 1.0, 0) -relative probe rgb (0.0, 0.5) (0, 0, 1.0) -relative probe rgb (0.3, 0.7) (0, 0, 1.0) -relative probe rgb (0.4, 0.9) (0, 0, 1.0) -relative probe rgb (0.5, 0.5) (0.5, 0.5, 0.5) -relative probe rgb (0.8, 0.7) (0.5, 0.5, 0.5) -relative probe rgb (0.9, 0.9) (0.5, 0.5, 0.5) +relative probe rgba (0.0, 0.0) (1.0, 0, 0, 1.0) +relative probe rgba (0.3, 0.2) (1.0, 0, 0, 1.0) +relative probe rgba (0.4, 0.4) (1.0, 0, 0, 1.0) +relative probe rgba (0.5, 0.0) (0, 1.0, 0, 1.0) +relative probe rgba (0.8, 0.2) (0, 1.0, 0, 1.0) +relative probe rgba (0.9, 0.4) (0, 1.0, 0, 1.0) +relative probe rgba (0.0, 0.5) (0, 0, 1.0, 1.0) +relative probe rgba (0.3, 0.7) (0, 0, 1.0, 1.0) +relative probe rgba (0.4, 0.9) (0, 0, 1.0, 1.0) +relative probe rgba (0.5, 0.5) (0.5, 0.5, 0.5, 1.0) +relative probe rgba (0.8, 0.7) (0.5, 0.5, 0.5, 1.0) +relative probe rgba (0.9, 0.9) (0.5, 0.5, 0.5, 1.0) diff --git a/tests/run_tests.py b/tests/run_tests.py index fadfc4ca4..454fdb7f6 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -124,9 +124,6 @@ # Currently not working, an issue is created "draw_rect_multiple_color_attachment.amber", # Currently not working, under investigation - "draw_array_after_draw_rect.vkscript", - "draw_rect_after_draw_array.vkscript", - "draw_rect_and_draw_array_mixed.vkscript", "draw_triangle_list_with_depth.vkscript", "draw_triangle_list_with_index_buffer_and_vertex_offset.vkscript", "draw_triangle_list_with_probe_point.vkscript", From ca8a6eea8b890bed1802c632d67909f8a5d45c80 Mon Sep 17 00:00:00 2001 From: SarahM0 Date: Mon, 15 Jul 2019 10:24:38 -0400 Subject: [PATCH 11/11] revert command_parser.cc - nit buffer_) --- src/dawn/engine_dawn.cc | 8 ++++---- src/dawn/pipeline_info.h | 4 ++-- src/vkscript/command_parser.cc | 4 ++++ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/dawn/engine_dawn.cc b/src/dawn/engine_dawn.cc index 596ff492c..296470175 100644 --- a/src/dawn/engine_dawn.cc +++ b/src/dawn/engine_dawn.cc @@ -1174,7 +1174,7 @@ Result EngineDawn::DoBuffer(const BufferCommand* command) { auto dawn_buffer_index = render_pipeline ->buffer_map_[{command->GetDescriptorSet(), command->GetBinding()}]; - ::dawn::Buffer& dawn_buffer = render_pipeline->buffers_[dawn_buffer_index]; + ::dawn::Buffer& dawn_buffer = render_pipeline->buffers[dawn_buffer_index]; Buffer* amber_buffer = command->GetBuffer(); if (amber_buffer) { @@ -1318,14 +1318,14 @@ Result EngineDawn::AttachBuffersAndTextures( "(descriptor sets)"); } - render_pipeline->buffers_.emplace_back( + render_pipeline->buffers.emplace_back( CreateBufferFromData(*device_, buf_info.buffer->ValuePtr()->data(), buf_info.buffer->GetSizeInBytes(), bufferUsage | ::dawn::BufferUsageBit::TransferSrc | ::dawn::BufferUsageBit::TransferDst)); render_pipeline->buffer_map_[{buf_info.descriptor_set, buf_info.binding}] = - render_pipeline->buffers_.size() - 1; + render_pipeline->buffers.size() - 1; render_pipeline->used_descriptor_set.insert(buf_info.descriptor_set); max_descriptor_set = std::max(max_descriptor_set, buf_info.descriptor_set); @@ -1337,7 +1337,7 @@ Result EngineDawn::AttachBuffersAndTextures( layouts_info[buf_info.descriptor_set].push_back(layout_info); BindingInitializationHelper tempBinding = BindingInitializationHelper( - buf_info.binding, render_pipeline->buffers_.back(), 0, + buf_info.binding, render_pipeline->buffers.back(), 0, buf_info.buffer->GetSizeInBytes()); bindingInitalizerHelper[buf_info.descriptor_set].push_back(tempBinding); } diff --git a/src/dawn/pipeline_info.h b/src/dawn/pipeline_info.h index f825766af..be4513626 100644 --- a/src/dawn/pipeline_info.h +++ b/src/dawn/pipeline_info.h @@ -65,12 +65,12 @@ struct RenderPipelineInfo { std::vector<::dawn::Buffer> vertex_buffers; ::dawn::Buffer index_buffer; /// storage and uniform buffers - std::vector<::dawn::Buffer> buffers_; + std::vector<::dawn::Buffer> buffers; std::vector<::dawn::BindGroup> bind_groups; std::vector<::dawn::BindGroupLayout> bind_group_layouts; - // Mapping from the to dawn buffer index in buffers_ + // Mapping from the to dawn buffer index in buffers std::unordered_map, uint32_t, hash_pair> buffer_map_; std::set used_descriptor_set; diff --git a/src/vkscript/command_parser.cc b/src/vkscript/command_parser.cc index ac2ca91fc..1babe0dc8 100644 --- a/src/vkscript/command_parser.cc +++ b/src/vkscript/command_parser.cc @@ -633,6 +633,10 @@ Result CommandParser::ProcessSSBO() { if (value_count > buf->ValueCount()) buf->SetValueCount(value_count); + // Even if the value count doesn't change, the buffer is still resized + // because this maybe the first time data is set into the buffer. + buf->ResizeTo(buf->GetSizeInBytes()); + cmd->SetValues(std::move(values)); } else {