From 4c6d6d449b6cfc378ce1f0739f0c96fd5d4583be Mon Sep 17 00:00:00 2001 From: David Neto Date: Tue, 27 Oct 2020 22:11:58 -0400 Subject: Roll third_party dependencies (#920) Roll third_party/spirv-tools/ 7e1825a59..df4198e50 (35 commits) https://github.com/KhronosGroup/SPIRV-Tools/compare/7e1825a59619...df4198e50eaa $ git log 7e1825a59..df4198e50 --date=short --no-merges --format='%ad %ae %s' 2020-10-27 jaebaek Add DebugValue for DebugDecl invisible to value assignment (#3973) 2020-10-26 greg Fix bounds check instrumentation to handle 16-bit values (#3983) 2020-10-23 andreperezmaselco.developer spirv-fuzz: Add expand vector reduction transformation (#3869) 2020-10-23 vasniktel spirv-fuzz: Don't replace irrelevant indices in OpAccessChain (#3988) 2020-10-23 vasniktel spirv-fuzz: Add FuzzerPassAddCompositeExtract (#3904) 2020-10-22 afdx spirv-fuzz: Fix mismatch with shrinker step limit (#3985) 2020-10-22 afdx spirv-fuzz: Fix off-by-one error in replayer (#3982) 2020-10-22 afdx spirv-fuzz: Get order right for OpSelect arguments (#3974) 2020-10-22 afdx spirv-fuzz: Do not add synonym-creating loops in dead blocks (#3975) 2020-10-22 afdx spirv-fuzz: Skip OpTypeSampledImage when propagating up (#3976) 2020-10-22 afdx spirv-fuzz: Pass OpUndef in function call if needed (#3978) 2020-10-22 afdx spirv-fuzz: Fix off-by-one in TransformationCompositeConstruct (#3979) 2020-10-22 afdx spirv-fuzz: Tolerate absent ids in data synonym fact management (#3966) 2020-10-21 afdx spirv-fuzz: Fix to id availability (#3971) 2020-10-21 afdx spirv-fuzz: Fix operand types (#3962) 2020-10-21 8729214+jonahryandavis Update SPIRV-Headers revision in DEPS file (#3961) 2020-10-21 afdx spirv-fuzz: Don't flatten conditional if condition is irrelevant (#3944) 2020-10-21 afdx spirv-fuzz: Do not produce OpPhis of type OpTypeSampledImage (#3964) 2020-10-21 afdx spirv-fuzz: Restrict fuzzer pass to reachable blocks (#3970) 2020-10-21 afdx spirv-fuzz: Handle more types when extending OpPhi instructions (#3969) 2020-10-21 afdx spirv-fuzz: Skip early terminator wrappers when merging returns (#3968) 2020-10-21 afdx spirv-fuzz: Avoid irrelevant constants in synonym-creating loops (#3967) 2020-10-21 afdx spirv-fuzz: Skip dead blocks in FuzzerPassAddOpPhiSynonyms (#3965) 2020-10-21 afdx spirv-fuzz: Avoid the type manager when looking for struct types (#3963) 2020-10-20 afdx spirv-fuzz: Fix to TransformationDuplicateRegionWithSelection (#3941) 2020-10-20 afdx spirv-fuzz: Skip OpFunction when replacing irrelevant ids (#3932) 2020-10-20 afdx spirv-fuzz: Use component-wise selectors when flattening conditional branches (#3921) 2020-10-20 TobyHector Add SPV_EXT_shader_image_int64 (#3852) 2020-10-20 TobyHector Support SPV_KHR_fragment_shading_rate (#3943) 2020-10-19 afdx spirv-val: Fix validation of OpPhi instructions (#3919) 2020-10-19 afdx spirv-fuzz: Avoid void struct member when outlining functions (#3936) 2020-10-19 afdx spirv-fuzz: Do not allow Block-decorated structs when adding parameters (#3931) 2020-10-19 afdx spirv-fuzz: Fix to operand id type (#3937) 2020-10-19 afdx spirv-fuzz: Handle dead blocks in TransformationEquationInstruction (#3933) 2020-10-19 afdx spirv-fuzz: Do not allow sampled image load when flattening conditionals (#3930) Created with: roll-dep third_party/spirv-tools Roll third_party/vulkan-loader/ 970c13274..2b0892e15 (6 commits) https://github.com/KhronosGroup/Vulkan-Loader/compare/970c132746b1...2b0892e15bd8 $ git log 970c13274..2b0892e15 --date=short --no-merges --format='%ad %ae %s' 2020-10-19 shannon build: Update known-good files for 1.2.158 header 2020-10-22 xantares09 tests: Use cmake -E copy instead of xcopy 2020-10-26 cstout Add support for VK_FUCHSIA_imagepipe_surface 2020-10-20 xantares09 Fix vulkan link to on cfgmgr32 case-sensitive fs 2020-10-12 rverschelde CMake: Fix libdir in pkg-config file, dehardcode includedir 2020-09-30 cstout Add Fuchsia support Created with: roll-dep third_party/vulkan-loader Roll third_party/dxc/ 141a5c2ec..c607bb3c0 (5 commits) $ git log 141a5c2ec..c607bb3c0 --date=short --no-merges --format='%ad %ae %s' 2020-10-22 mgong Some improvements to cmake files of dxilconv (#2876) 2020-10-22 Junda.Liu Fix [[vk::push_constant]] on ConstantBuffer (#3215) 2020-10-21 jaebaek [spirv] handle sizeof using Clang's const folding (#3208) 2020-10-20 31109344+adam-yang Fixing store undef later in the compilation. (#3212) 2020-10-20 hekotas Fix build for ARM64EC dxilconv.dll, because _xgetbv is currently not a supported intrinsic for ARM64EC. (#3211) Created with: roll-dep third_party/dxc Roll third_party/vulkan-validationlayers/ 8c5a10d95..87b0951f8 (31 commits) https://github.com/KhronosGroup/Vulkan-ValidationLayers/compare/8c5a10d952f4...87b0951f8dba $ git log 8c5a10d95..87b0951f8 --date=short --no-merges --format='%ad %ae %s' 2020-10-26 s.fricke tests: Add VUID 02502 and 02503 2020-10-26 s.fricke layers: Label VUID 02502 and 02503 2020-10-25 nathbappai cmake: Check MSVC instead of WIN32 for MSVC compiler options 2020-10-26 s.fricke tests: Add drm format aspect planes 2020-10-26 s.fricke layers: Add drm format aspect planes 2020-09-23 tony layers: Tune image layout loop 2020-10-20 shannon build: Update known-good files for 1.2.158 header 2020-10-20 mikes scripts: Rework PV array length handling 2020-10-20 mikes scripts: Escape backslashes in C strings 2020-10-22 mark tests: Create DisplayKHR objs with GetPDDisplayPlaneProps APIs 2020-10-22 mark lifetimes: Created GetPDDisplayPlaneProperties display objs 2020-10-22 mark threading: Created GetPDDisplayPlaneProperties display objs 2020-10-21 s.fricke layers: Label copy2 00212 2020-10-21 s.fricke tests: Check clearAttachment implict VUs 2020-10-21 s.fricke layers: Remove redundant implicit check 2020-10-13 locke layers: Pref improvement 2020-10-13 locke layers: Bug fixed 2020-10-21 locke tests: VerifyDynamicStateSettingCommands 2020-10-21 locke layers: VUID 02859 2020-10-16 locke tests: Test Vertex Binding 2020-10-16 locke layers: VUID-02721 2020-10-19 jbauman Revert "layers: Fix wrong if statement" 2020-10-19 locke tests: Remove VUID-02686 2020-10-19 locke layers: Remove VUID-02686 2020-10-17 s.fricke layers: Label VUID 04477 2020-10-18 s.fricke layers: Improve ValidateCmdQueueFlags message 2020-10-11 s.fricke tests: Remove clang 10 warning for string copy 2020-09-10 locke tests: Push constant update 2020-09-10 locke layers: VUID-vkCmdDraw-None-02698 2020-10-19 mark stateless: Changed bool checks from warnings to errors 2020-10-18 jleger layers: Remove unneeded validation checks Created with: roll-dep third_party/vulkan-validationlayers Roll third_party/spirv-headers/ c43a43c7c..7845730ca (3 commits) https://github.com/KhronosGroup/SPIRV-Headers/compare/c43a43c7cc3a...7845730cab6e $ git log c43a43c7c..7845730ca --date=short --no-merges --format='%ad %ae %s' 2020-10-23 john Bump revision to 4, for SPIR-V 1.5. 2020-10-19 TobyHector Add SPV_EXT_shader_image_int64 (#170) 2020-10-19 TobyHector Added SPV_KHR_fragment_shading_rate (#172) Created with: roll-dep third_party/spirv-headers Roll third_party/glslang/ f4f1d8a35..740ae9f60 (8 commits) https://github.com/KhronosGroup/glslang/compare/f4f1d8a352ca...740ae9f60b00 $ git log f4f1d8a35..740ae9f60 --date=short --no-merges --format='%ad %ae %s' 2020-10-23 rex.xu HLSL: Add support for printf(). 2020-10-21 bclayton Fix GN build and presubmits 2020-10-20 john SPV: Update to the latest SPIR-V header, includes variable-rate shading 2020-07-02 laddoc Add GL_EXT_fragment_shading_rate 2020-10-20 bclayton Kokoro: Add configurations for GN presubmit 2020-10-19 bclayton Fix uninitialized use of TIntermediate::resource (#2424) 2020-10-16 bclayton Add GN build instructions to README.md 2020-10-16 bclayton Add basic GN configurations Created with: roll-dep third_party/glslang Roll third_party/shaderc/ 011139094..813ef3dc0 (1 commit) https://github.com/google/shaderc/compare/011139094ec7...813ef3dc0d5e $ git log 011139094..813ef3dc0 --date=short --no-merges --format='%ad %ae %s' 2020-10-26 antiagainst Handle alias libraries in shaderc_combined to avoid duplicated symbols (#1141) Created with: roll-dep third_party/shaderc Roll third_party/googletest/ 3c95bf552..3005672db (5 commits) https://github.com/google/googletest/compare/3c95bf552405...3005672db1d0 $ git log 3c95bf552..3005672db --date=short --no-merges --format='%ad %ae %s' 2020-10-26 absl-team Googletest export 2020-10-20 sonzogniarthur Fix typo "definedin in" => "defined in" 2020-10-15 absl-team Googletest export 2020-10-15 absl-team Googletest export 2020-10-07 manavrion Improve FilePath::Normalize method Created with: roll-dep third_party/googletest --- DEPS | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/DEPS b/DEPS index 20fb76d..7fb9f48 100644 --- a/DEPS +++ b/DEPS @@ -13,18 +13,18 @@ vars = { 'clspv_revision': '3a11614ee40907c6f9edd99bd7d23b123111e947', 'cppdap_revision': '1fd23dda91e01550be1a421de307e6fedb2035a9', 'cpplint_revision': '26470f9ccb354ff2f6d098f831271a1833701b28', - 'dxc_revision': '141a5c2ec5f77733f301f9f332bc3b0aefbc2c62', - 'glslang_revision': 'f4f1d8a352ca1908943aea2ad8c54b39b4879080', - 'googletest_revision': '3c95bf552405fd0cc63cea0ca2f6c4cd89c8d356', + 'dxc_revision': 'c607bb3c032d9d50a60224e29a85f0a04b78acbf', + 'glslang_revision': '740ae9f60b009196662bad811924788cee56133a', + 'googletest_revision': '3005672db1d05f2378f642b61faa96f85498befe', 'json_revision': '350ff4f7ced7c4117eae2fb93df02823c8021fcb', 'lodepng_revision': '7fdcc96a5e5864eee72911c3ca79b1d9f0d12292', - 'shaderc_revision': '011139094ec790ff7f32ea2d80286255fc9ed18b', - 'spirv_headers_revision': 'c43a43c7cc3af55910b9bec2a71e3e8a622443cf', - 'spirv_tools_revision': '7e1825a59619f3decd9b46f25d457b1a8878ca89', + 'shaderc_revision': '813ef3dc0d5e10bfdf836c651099fcb2203c24ae', + 'spirv_headers_revision': '7845730cab6ebbdeb621e7349b7dc1a59c3377be', + 'spirv_tools_revision': 'df4198e50eaa705298167d3c0b3cb01ffd28a5ff', 'swiftshader_revision': 'df17a76102dfabb3f1bd6e51449cece9f77b45e3', 'vulkan_headers_revision': '320af06cbdd29848e1d7100d9b8e4e517db1dfd5', - 'vulkan_loader_revision': '970c132746b1d8bc2baeeb2bcdb5edf490b47f94', - 'vulkan_validationlayers_revision': '8c5a10d952f4122898205854b61f9e8de46d2363', + 'vulkan_loader_revision': '2b0892e15bd83886476141c1f19801d2968efadf', + 'vulkan_validationlayers_revision': '87b0951f8dbaf3d0562a073bc5dd580c4468a1a1', } deps = { -- cgit v1.2.3 From 760076b7c8bf43d6c6cc4928f5129afca16e895e Mon Sep 17 00:00:00 2001 From: David Neto Date: Tue, 27 Oct 2020 22:13:05 -0400 Subject: roll-all: Fix for GNU find (#919) Use -mindepth 1 instead of -depth 1 Also, put global options before non-global options --- tools/roll-all | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/roll-all b/tools/roll-all index f9427e6..97f00c3 100755 --- a/tools/roll-all +++ b/tools/roll-all @@ -42,7 +42,7 @@ fi old_head=$(git rev-parse HEAD) -for i in $(find third_party -type d -maxdepth 1 -depth 1); do +for i in $(find third_party -maxdepth 1 -mindepth 1 -type d); do name=`echo "${i%%/}" | cut -f2 -d'/' | tr '-' '_'` if [ "x${name}" == "xcpplint" ]; then -- cgit v1.2.3 From 8915c4f9a04e703d5273939f25d8fe08010c2b43 Mon Sep 17 00:00:00 2001 From: alan-baker Date: Wed, 4 Nov 2020 17:00:05 -0500 Subject: Add passthrough support for region offset (#922) * In order to support OpenCL C 2.0 kernels that use get_global_id() pass 0s for the region offset push constant * Allow use of the region offset push constant reflection instruction --- src/clspv_helper.cc | 10 +++++++++- src/pipeline.cc | 6 ++++++ src/pipeline.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/clspv_helper.cc b/src/clspv_helper.cc index a6c4d50..59b8737 100644 --- a/src/clspv_helper.cc +++ b/src/clspv_helper.cc @@ -180,9 +180,17 @@ spv_result_t ParseExtendedInst(ReflectionHelper* helper, helper->shader_info->AddPushConstant(std::move(push_constant)); break; } + case NonSemanticClspvReflectionPushConstantRegionOffset: { + auto offset_id = inst->words[inst->operands[4].offset]; + auto size_id = inst->words[inst->operands[5].offset]; + Pipeline::ShaderInfo::PushConstant push_constant{ + Pipeline::ShaderInfo::PushConstant::PushConstantType::kRegionOffset, + helper->constants[offset_id], helper->constants[size_id]}; + helper->shader_info->AddPushConstant(std::move(push_constant)); + break; + } case NonSemanticClspvReflectionPushConstantEnqueuedLocalSize: case NonSemanticClspvReflectionPushConstantGlobalSize: - case NonSemanticClspvReflectionPushConstantRegionOffset: case NonSemanticClspvReflectionPushConstantNumWorkgroups: case NonSemanticClspvReflectionPushConstantRegionGroupOffset: helper->error_message = "Unsupported push constant"; diff --git a/src/pipeline.cc b/src/pipeline.cc index 7df2401..3e5353a 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -1015,6 +1015,12 @@ Result Pipeline::GenerateOpenCLPushConstants() { bytes[base + 1] = 0; bytes[base + 2] = 0; break; + case Pipeline::ShaderInfo::PushConstant::PushConstantType::kRegionOffset: + // Region offsets are not currently supported. + bytes[base] = 0; + bytes[base + 1] = 0; + bytes[base + 2] = 0; + break; } memcpy(buf->ValuePtr()->data() + pc.offset, bytes.data(), bytes.size() * sizeof(uint32_t)); diff --git a/src/pipeline.h b/src/pipeline.h index 212255b..ddeb2a4 100644 --- a/src/pipeline.h +++ b/src/pipeline.h @@ -149,6 +149,7 @@ class Pipeline { enum class PushConstantType { kDimensions = 0, kGlobalOffset, + kRegionOffset, }; PushConstantType type; uint32_t offset = 0; -- cgit v1.2.3 From 9ef2248b535fafabf6bc18e01e2e8808e2d6e6db Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Fri, 6 Nov 2020 10:32:46 -0500 Subject: Add some missing includes. (#923) This Cl adds a few missing includes. --- src/cast_hash.h | 2 ++ src/image.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/cast_hash.h b/src/cast_hash.h index e02c148..4d9d812 100644 --- a/src/cast_hash.h +++ b/src/cast_hash.h @@ -15,6 +15,8 @@ #ifndef SRC_CAST_HASH_H_ #define SRC_CAST_HASH_H_ +#include + namespace amber { /// A hash implementation for types that can trivially be up-cast to a size_t. diff --git a/src/image.h b/src/image.h index a74c3ac..c6a51a3 100644 --- a/src/image.h +++ b/src/image.h @@ -15,6 +15,8 @@ #ifndef SRC_IMAGE_H_ #define SRC_IMAGE_H_ +#include + namespace amber { enum class ImageDimension : int8_t { kUnknown = -1, k1D = 0, k2D = 1, k3D = 2 }; -- cgit v1.2.3 From 4d6fcf03895737bea3aacffde22cd983f1c8c492 Mon Sep 17 00:00:00 2001 From: asuonpaa <34128694+asuonpaa@users.noreply.github.com> Date: Tue, 10 Nov 2020 12:41:12 +0200 Subject: Skip data readback for read-only descriptors (#921) This works as an optimization but also fixes an issue where binding a single buffer multiple times (to read-only descriptors) in a pipeline would fail because Amber would try to copy back to the Amber buffer multiple times. --- src/command.h | 4 ++ src/pipeline.cc | 1 + src/pipeline.h | 1 + src/vulkan/buffer_backed_descriptor.cc | 48 ++++++++++--- src/vulkan/buffer_backed_descriptor.h | 5 +- src/vulkan/buffer_descriptor.cc | 1 + src/vulkan/engine_vulkan.cc | 1 + src/vulkan/image_descriptor.cc | 13 ++-- src/vulkan/pipeline.cc | 2 +- tests/cases/multiple_samplers.amber | 126 +++++++++++++++++++++++++++++++++ 10 files changed, 185 insertions(+), 17 deletions(-) create mode 100644 tests/cases/multiple_samplers.amber diff --git a/src/command.h b/src/command.h index c6c7e08..207c336 100644 --- a/src/command.h +++ b/src/command.h @@ -552,10 +552,14 @@ class BufferCommand : public BindableResourceCommand { void SetBuffer(Buffer* buffer) { buffer_ = buffer; } Buffer* GetBuffer() const { return buffer_; } + void SetSampler(Sampler* sampler) { sampler_ = sampler; } + Sampler* GetSampler() const { return sampler_; } + std::string ToString() const override { return "BufferCommand"; } private: Buffer* buffer_ = nullptr; + Sampler* sampler_ = nullptr; BufferType buffer_type_; bool is_subdata_ = false; uint32_t offset_ = 0; diff --git a/src/pipeline.cc b/src/pipeline.cc index 3e5353a..beb09b1 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -521,6 +521,7 @@ void Pipeline::AddBuffer(Buffer* buf, info.type = type; info.base_mip_level = base_mip_level; info.dynamic_offset = dynamic_offset; + info.sampler = buf->GetSampler(); } void Pipeline::AddBuffer(Buffer* buf, diff --git a/src/pipeline.h b/src/pipeline.h index ddeb2a4..bdb1679 100644 --- a/src/pipeline.h +++ b/src/pipeline.h @@ -199,6 +199,7 @@ class Pipeline { uint32_t arg_no = 0; BufferType type = BufferType::kUnknown; InputRate input_rate = InputRate::kVertex; + Sampler* sampler; }; /// Information on a sampler attached to the pipeline. diff --git a/src/vulkan/buffer_backed_descriptor.cc b/src/vulkan/buffer_backed_descriptor.cc index 746195a..2f7aa98 100644 --- a/src/vulkan/buffer_backed_descriptor.cc +++ b/src/vulkan/buffer_backed_descriptor.cc @@ -45,7 +45,11 @@ Result BufferBackedDescriptor::RecordCopyDataToResourceIfNeeded( for (size_t i = 0; i < resources.size(); i++) { if (!buffers[i]->ValuePtr()->empty()) { resources[i]->UpdateMemoryWithRawData(*buffers[i]->ValuePtr()); - buffers[i]->ValuePtr()->clear(); + // If the resource is read-only, keep the buffer data; Amber won't copy + // read-only resources back into the host buffers, so it makes sense to + // leave the buffer intact. + if (!IsReadOnly()) + buffers[i]->ValuePtr()->clear(); } resources[i]->CopyToDevice(command); @@ -55,19 +59,25 @@ Result BufferBackedDescriptor::RecordCopyDataToResourceIfNeeded( } Result BufferBackedDescriptor::RecordCopyDataToHost(CommandBuffer* command) { - if (GetResources().empty()) { - return Result( - "Vulkan: BufferBackedDescriptor::RecordCopyDataToHost() no transfer " - "resources"); - } + if (!IsReadOnly()) { + if (GetResources().empty()) { + return Result( + "Vulkan: BufferBackedDescriptor::RecordCopyDataToHost() no transfer " + "resources"); + } - for (const auto& r : GetResources()) - r->CopyToHost(command); + for (const auto& r : GetResources()) + r->CopyToHost(command); + } return {}; } Result BufferBackedDescriptor::MoveResourceToBufferOutput() { + // No need to copy results of read only resources. + if (IsReadOnly()) + return {}; + auto resources = GetResources(); auto buffers = GetAmberBuffers(); if (resources.size() != buffers.size()) @@ -78,8 +88,7 @@ Result BufferBackedDescriptor::MoveResourceToBufferOutput() { if (resources.empty()) { return Result( "Vulkan: BufferBackedDescriptor::MoveResourceToBufferOutput() no " - "transfer" - " resource"); + "transfer resource"); } for (size_t i = 0; i < resources.size(); i++) { @@ -107,5 +116,24 @@ Result BufferBackedDescriptor::MoveResourceToBufferOutput() { return {}; } +bool BufferBackedDescriptor::IsReadOnly() const { + switch (type_) { + case DescriptorType::kUniformBuffer: + case DescriptorType::kUniformBufferDynamic: + case DescriptorType::kUniformTexelBuffer: + case DescriptorType::kSampledImage: + case DescriptorType::kCombinedImageSampler: + return true; + case DescriptorType::kStorageBuffer: + case DescriptorType::kStorageBufferDynamic: + case DescriptorType::kStorageTexelBuffer: + case DescriptorType::kStorageImage: + return false; + default: + assert(false && "Unexpected descriptor type"); + return false; + } +} + } // namespace vulkan } // namespace amber diff --git a/src/vulkan/buffer_backed_descriptor.h b/src/vulkan/buffer_backed_descriptor.h index 788bf4e..c626dd8 100644 --- a/src/vulkan/buffer_backed_descriptor.h +++ b/src/vulkan/buffer_backed_descriptor.h @@ -42,13 +42,16 @@ class BufferBackedDescriptor : public Descriptor { Result RecordCopyDataToResourceIfNeeded(CommandBuffer* command) override; Result RecordCopyDataToHost(CommandBuffer* command) override; Result MoveResourceToBufferOutput() override; - virtual std::vector GetResources() = 0; uint32_t GetDescriptorCount() override { return static_cast(amber_buffers_.size()); } const std::vector& GetAmberBuffers() const { return amber_buffers_; } void AddAmberBuffer(Buffer* buffer) { amber_buffers_.push_back(buffer); } BufferBackedDescriptor* AsBufferBackedDescriptor() override { return this; } + bool IsReadOnly() const; + + protected: + virtual std::vector GetResources() = 0; private: std::vector amber_buffers_; diff --git a/src/vulkan/buffer_descriptor.cc b/src/vulkan/buffer_descriptor.cc index 001c45e..510565d 100644 --- a/src/vulkan/buffer_descriptor.cc +++ b/src/vulkan/buffer_descriptor.cc @@ -75,6 +75,7 @@ Result BufferDescriptor::CreateResourceIfNeeded() { Result BufferDescriptor::MoveResourceToBufferOutput() { Result r = BufferBackedDescriptor::MoveResourceToBufferOutput(); + transfer_buffers_.clear(); return r; diff --git a/src/vulkan/engine_vulkan.cc b/src/vulkan/engine_vulkan.cc index 0e65298..035c269 100644 --- a/src/vulkan/engine_vulkan.cc +++ b/src/vulkan/engine_vulkan.cc @@ -253,6 +253,7 @@ Result EngineVulkan::CreatePipeline(amber::Pipeline* pipeline) { cmd->SetBaseMipLevel(buf_info.base_mip_level); cmd->SetDynamicOffset(buf_info.dynamic_offset); cmd->SetBuffer(buf_info.buffer); + cmd->SetSampler(buf_info.sampler); if (cmd->GetValues().empty()) { cmd->GetBuffer()->SetSizeInElements(cmd->GetBuffer()->ElementCount()); diff --git a/src/vulkan/image_descriptor.cc b/src/vulkan/image_descriptor.cc index e1e9535..1305a52 100644 --- a/src/vulkan/image_descriptor.cc +++ b/src/vulkan/image_descriptor.cc @@ -125,18 +125,21 @@ Result ImageDescriptor::CreateResourceIfNeeded() { } Result ImageDescriptor::RecordCopyDataToHost(CommandBuffer* command) { - for (auto& image : transfer_images_) { - image->ImageBarrier(command, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - VK_PIPELINE_STAGE_TRANSFER_BIT); - } + if (!IsReadOnly()) { + for (auto& image : transfer_images_) { + image->ImageBarrier(command, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, + VK_PIPELINE_STAGE_TRANSFER_BIT); + } - BufferBackedDescriptor::RecordCopyDataToHost(command); + BufferBackedDescriptor::RecordCopyDataToHost(command); + } return {}; } Result ImageDescriptor::MoveResourceToBufferOutput() { Result r = BufferBackedDescriptor::MoveResourceToBufferOutput(); + transfer_images_.clear(); return r; diff --git a/src/vulkan/pipeline.cc b/src/vulkan/pipeline.cc index 0bd3e36..4f4075b 100644 --- a/src/vulkan/pipeline.cc +++ b/src/vulkan/pipeline.cc @@ -321,7 +321,7 @@ Result Pipeline::AddBufferDescriptor(const BufferCommand* cmd) { cmd->GetBuffer(), desc_type, device_, cmd->GetBaseMipLevel(), cmd->GetDescriptorSet(), cmd->GetBinding()); if (cmd->IsSampledImage() || cmd->IsCombinedImageSampler()) - image_desc->SetAmberSampler(cmd->GetBuffer()->GetSampler()); + image_desc->SetAmberSampler(cmd->GetSampler()); descriptors.push_back(std::move(image_desc)); } else { auto buffer_desc = MakeUnique( diff --git a/tests/cases/multiple_samplers.amber b/tests/cases/multiple_samplers.amber new file mode 100644 index 0000000..dd37e8e --- /dev/null +++ b/tests/cases/multiple_samplers.amber @@ -0,0 +1,126 @@ +#!amber +# Copyright 2020 The Amber Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SHADER vertex vert_shader PASSTHROUGH + +SHADER fragment frag_shader_red GLSL +#version 430 +layout(location = 0) out vec4 color_out; +void main() { + color_out = vec4(1.0, 0.0, 0.0, 1.0); +} +END + +SHADER vertex vert_shader_tex GLSL +#version 430 +layout(location = 0) in vec4 position; +layout(location = 1) in vec2 texcoords_in; +layout(location = 0) out vec2 texcoords_out; +void main() { + gl_Position = position; + texcoords_out = texcoords_in; +} +END + +SHADER fragment frag_shader_tex GLSL +#version 430 +layout(location = 0) in vec2 texcoords_in; +layout(location = 0) out vec4 color_out; +uniform layout(set=0, binding=0) sampler2D tex_sampler_white; +uniform layout(set=0, binding=1) sampler2D tex_sampler_black; +void main() { + // Use a sampler with a white border color for the right + // side of the color buffer and a sampler with a black + // border color for the left side. + if (gl_FragCoord.x > 128.0) + color_out = texture(tex_sampler_white, texcoords_in); + else + color_out = texture(tex_sampler_black, texcoords_in); +} +END + +BUFFER texture FORMAT R8G8B8A8_UNORM +BUFFER framebuffer FORMAT B8G8R8A8_UNORM + +# A sampler that generates white when texture coordinates +# go out of range [0..1]. +SAMPLER sampler_white \ + ADDRESS_MODE_U clamp_to_border \ + ADDRESS_MODE_V clamp_to_border \ + BORDER_COLOR float_opaque_white + +# A sampler that generates black when texture coordinates +# go out of range [0..1]. +SAMPLER sampler_black \ + ADDRESS_MODE_U clamp_to_border \ + ADDRESS_MODE_V clamp_to_border \ + BORDER_COLOR float_opaque_black + +BUFFER position DATA_TYPE vec2 DATA +-0.75 -0.75 + 0.75 -0.75 + 0.75 0.75 +-0.75 0.75 +END +BUFFER texcoords DATA_TYPE vec2 DATA +-0.5 -0.5 + 1.5 -0.5 + 1.5 1.5 +-0.5 1.5 +END + +# A pipeline for generating a texture. Renders pure red. +PIPELINE graphics texgen + ATTACH vert_shader + ATTACH frag_shader_red + FRAMEBUFFER_SIZE 256 256 + BIND BUFFER texture AS color LOCATION 0 +END + +# A pipeline for drawing a textured quad using two samplers. +PIPELINE graphics pipeline + ATTACH vert_shader_tex + ATTACH frag_shader_tex + BIND BUFFER texture AS combined_image_sampler SAMPLER sampler_white DESCRIPTOR_SET 0 BINDING 0 + BIND BUFFER texture AS combined_image_sampler SAMPLER sampler_black DESCRIPTOR_SET 0 BINDING 1 + VERTEX_DATA position LOCATION 0 + VERTEX_DATA texcoords LOCATION 1 + FRAMEBUFFER_SIZE 256 256 + BIND BUFFER framebuffer AS color LOCATION 0 +END + +# Generate a texture with a blue background and red quad at the lower right corner. +CLEAR_COLOR texgen 0 0 255 255 +CLEAR texgen +RUN texgen DRAW_RECT POS 128 128 SIZE 128 128 + +# Clear to green and draw the generated texture in the center of the screen leaving +# the background color to the edges. Use texture coordinates that go past the [0..1] +# range to show border colors. The left side of the texture is using a sampler with +# a black border, and the right side uses a sampler with a white border. +CLEAR_COLOR pipeline 0 255 0 255 +CLEAR pipeline +RUN pipeline DRAW_ARRAY AS TRIANGLE_FAN START_IDX 0 COUNT 4 + +# Check for the green background. +EXPECT framebuffer IDX 1 1 SIZE 1 1 EQ_RGBA 0 255 0 255 +# Check for the black border color. +EXPECT framebuffer IDX 55 55 SIZE 1 1 EQ_RGBA 0 0 0 255 +# Check for the blue part of the texture. +EXPECT framebuffer IDX 105 105 SIZE 1 1 EQ_RGBA 0 0 255 255 +# Check for the red part of the texture. +EXPECT framebuffer IDX 150 150 SIZE 1 1 EQ_RGBA 255 0 0 255 +# Check for the white border color. +EXPECT framebuffer IDX 200 200 SIZE 1 1 EQ_RGBA 255 255 255 255 -- cgit v1.2.3 From 404e43281bed513ab74f054bfdee57accb527ac2 Mon Sep 17 00:00:00 2001 From: Jaebaek Seo Date: Mon, 16 Nov 2020 10:16:38 -0500 Subject: Updated DXC and SPIRV-Tools DEPS and add tests for debugger (#925) I added tests/cases/debugger_hlsl_function_call.amber from Ben's Amber repo. This change will make Amber successfully test debugging more shaders. --- DEPS | 6 +- tests/cases/debugger_hlsl_basic_compute.amber | 3 +- ...ger_hlsl_basic_fragment_with_legalization.amber | 102 ++++++++++ ...ugger_hlsl_basic_vertex_with_legalization.amber | 128 +++++++++++++ tests/cases/debugger_hlsl_function_call.amber | 212 +++++++++++++++++++++ tests/cases/debugger_hlsl_shadowed_vars.amber | 6 +- tests/run_tests.py | 8 + 7 files changed, 456 insertions(+), 9 deletions(-) create mode 100644 tests/cases/debugger_hlsl_basic_fragment_with_legalization.amber create mode 100644 tests/cases/debugger_hlsl_basic_vertex_with_legalization.amber create mode 100644 tests/cases/debugger_hlsl_function_call.amber diff --git a/DEPS b/DEPS index 7fb9f48..bfd0311 100644 --- a/DEPS +++ b/DEPS @@ -13,15 +13,15 @@ vars = { 'clspv_revision': '3a11614ee40907c6f9edd99bd7d23b123111e947', 'cppdap_revision': '1fd23dda91e01550be1a421de307e6fedb2035a9', 'cpplint_revision': '26470f9ccb354ff2f6d098f831271a1833701b28', - 'dxc_revision': 'c607bb3c032d9d50a60224e29a85f0a04b78acbf', + 'dxc_revision': 'a8d9780046cb64a1cea842fa6fc28a250e3e2c09', 'glslang_revision': '740ae9f60b009196662bad811924788cee56133a', 'googletest_revision': '3005672db1d05f2378f642b61faa96f85498befe', 'json_revision': '350ff4f7ced7c4117eae2fb93df02823c8021fcb', 'lodepng_revision': '7fdcc96a5e5864eee72911c3ca79b1d9f0d12292', 'shaderc_revision': '813ef3dc0d5e10bfdf836c651099fcb2203c24ae', 'spirv_headers_revision': '7845730cab6ebbdeb621e7349b7dc1a59c3377be', - 'spirv_tools_revision': 'df4198e50eaa705298167d3c0b3cb01ffd28a5ff', - 'swiftshader_revision': 'df17a76102dfabb3f1bd6e51449cece9f77b45e3', + 'spirv_tools_revision': 'a61d07a72763c1eb200de0a2c316703643a0d1d9', + 'swiftshader_revision': 'e1012cfc791ddbc6ce11e319831da7973b9a5b32', 'vulkan_headers_revision': '320af06cbdd29848e1d7100d9b8e4e517db1dfd5', 'vulkan_loader_revision': '2b0892e15bd83886476141c1f19801d2968efadf', 'vulkan_validationlayers_revision': '87b0951f8dbaf3d0562a073bc5dd580c4468a1a1', diff --git a/tests/cases/debugger_hlsl_basic_compute.amber b/tests/cases/debugger_hlsl_basic_compute.amber index 386bfb6..84db5df 100644 --- a/tests/cases/debugger_hlsl_basic_compute.amber +++ b/tests/cases/debugger_hlsl_basic_compute.amber @@ -39,8 +39,7 @@ END PIPELINE compute pipeline ATTACH shader SHADER_OPTIMIZATION shader - --inline-entry-points-exhaustive - --eliminate-dead-functions + --legalize-hlsl END BIND BUFFER data AS storage DESCRIPTOR_SET 0 BINDING 0 END diff --git a/tests/cases/debugger_hlsl_basic_fragment_with_legalization.amber b/tests/cases/debugger_hlsl_basic_fragment_with_legalization.amber new file mode 100644 index 0000000..ccbbfa5 --- /dev/null +++ b/tests/cases/debugger_hlsl_basic_fragment_with_legalization.amber @@ -0,0 +1,102 @@ +#!amber +# Copyright 2020 The Amber Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SET ENGINE_DATA fence_timeout_ms 1000000 + +VIRTUAL_FILE "vs.hlsl" +struct VS_OUTPUT { + float4 pos : SV_POSITION; + float4 color : COLOR; +}; + +VS_OUTPUT main(float4 pos : POSITION) { + VS_OUTPUT vout; + vout.pos = pos; + vout.color = float4(25.1 / 255.0, 50.1 / 255.0, 100.1 / 255.0, 1.0); + return vout; +} +END + +VIRTUAL_FILE "fs.hlsl" +float4 main(float4 color : COLOR) : SV_TARGET { + int r = color.r * 255; + int g = color.g * 255; + int b = color.b * 255; + int a = color.a * 255; + return color; +} +END + +SHADER vertex vtex_shader HLSL VIRTUAL_FILE "vs.hlsl" +SHADER fragment frag_shader HLSL VIRTUAL_FILE "fs.hlsl" + +BUFFER position_buf DATA_TYPE R8G8_SNORM DATA +# Full frame +-128 -128 + 127 127 +-128 127 +-128 -128 + 127 127 + 127 -128 +END + +BUFFER framebuffer FORMAT B8G8R8A8_UNORM + +PIPELINE graphics pipeline + FRAMEBUFFER_SIZE 32 32 + + ATTACH vtex_shader + SHADER_OPTIMIZATION vtex_shader + --legalize-hlsl + END + + ATTACH frag_shader + SHADER_OPTIMIZATION frag_shader + --legalize-hlsl + END + + VERTEX_DATA position_buf LOCATION 0 + + BIND BUFFER framebuffer AS color LOCATION 0 +END + +CLEAR pipeline + +DEBUG pipeline DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 + THREAD FRAGMENT_WINDOW_SPACE_POSITION 10 10 + EXPECT LOCATION "fs.hlsl" 2 " int r = color.r * 255;" + STEP_IN + EXPECT LOCAL "r" EQ 25 + EXPECT LOCATION "fs.hlsl" 3 " int g = color.g * 255;" + STEP_IN + EXPECT LOCAL "r" EQ 25 + EXPECT LOCAL "g" EQ 50 + EXPECT LOCATION "fs.hlsl" 4 " int b = color.b * 255;" + STEP_IN + EXPECT LOCAL "r" EQ 25 + EXPECT LOCAL "g" EQ 50 + EXPECT LOCAL "b" EQ 100 + EXPECT LOCATION "fs.hlsl" 5 " int a = color.a * 255;" + STEP_IN + EXPECT LOCAL "r" EQ 25 + EXPECT LOCAL "g" EQ 50 + EXPECT LOCAL "b" EQ 100 + EXPECT LOCAL "a" EQ 255 + EXPECT LOCATION "fs.hlsl" 7 "}" + CONTINUE + END +END + +EXPECT framebuffer IDX 0 0 SIZE 32 32 EQ_RGB 25 50 100 diff --git a/tests/cases/debugger_hlsl_basic_vertex_with_legalization.amber b/tests/cases/debugger_hlsl_basic_vertex_with_legalization.amber new file mode 100644 index 0000000..628646a --- /dev/null +++ b/tests/cases/debugger_hlsl_basic_vertex_with_legalization.amber @@ -0,0 +1,128 @@ +#!amber +# Copyright 2020 The Amber Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SET ENGINE_DATA fence_timeout_ms 1000000 + +VIRTUAL_FILE "vs.hlsl" +struct VS_OUTPUT { + float4 pos : SV_POSITION; + float4 color : COLOR; +}; + +VS_OUTPUT main(float4 pos : POSITION, + float4 color : COLOR) { + VS_OUTPUT vout; + vout.pos = pos; + vout.color = color; + return vout; +} +END + +VIRTUAL_FILE "fs.hlsl" +float4 main(float4 color : COLOR) : SV_TARGET { + return color; +} +END + +SHADER vertex vtex_shader HLSL VIRTUAL_FILE "vs.hlsl" +SHADER fragment frag_shader HLSL VIRTUAL_FILE "fs.hlsl" + +BUFFER position_buf DATA_TYPE R8G8_SNORM DATA +# Full frame +-128 -128 + 127 127 +-128 127 +-128 -128 + 127 127 + 127 -128 +END + +BUFFER vert_color DATA_TYPE R8G8B8A8_UNORM DATA +255 0 0 255 +255 0 0 255 +255 0 0 255 +255 0 0 255 +255 0 0 255 +255 0 0 255 + + 0 255 0 255 + 0 255 0 255 + 0 255 0 255 + 0 255 0 255 + 0 255 0 255 + 0 255 0 255 + + 0 0 255 255 + 0 0 255 255 + 0 0 255 255 + 0 0 255 255 + 0 0 255 255 + 0 0 255 255 + +127 127 127 255 +127 127 127 255 +127 127 127 255 +127 127 127 255 +127 127 127 255 +127 127 127 255 +END + +BUFFER framebuffer FORMAT B8G8R8A8_UNORM + +PIPELINE graphics pipeline + FRAMEBUFFER_SIZE 32 32 + + ATTACH vtex_shader + SHADER_OPTIMIZATION vtex_shader + --legalize-hlsl + END + + ATTACH frag_shader + SHADER_OPTIMIZATION frag_shader + --legalize-hlsl + END + + VERTEX_DATA position_buf LOCATION 0 + VERTEX_DATA vert_color LOCATION 1 + + BIND BUFFER framebuffer AS color LOCATION 0 +END + +CLEAR pipeline + +DEBUG pipeline DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 + THREAD VERTEX_INDEX 0 + EXPECT LOCATION "vs.hlsl" 9 " vout.pos = pos;" + EXPECT LOCAL "pos.x" EQ -1.000000 + EXPECT LOCAL "pos.y" EQ -1.000000 + EXPECT LOCAL "pos.z" EQ 0.000000 + EXPECT LOCAL "color.x" EQ 1.000000 + EXPECT LOCAL "color.y" EQ 0.000000 + EXPECT LOCAL "color.z" EQ 0.000000 + STEP_IN + EXPECT LOCAL "vout.pos.x" EQ -1.000000 + EXPECT LOCAL "vout.pos.y" EQ -1.000000 + EXPECT LOCAL "vout.pos.z" EQ 0.000000 + EXPECT LOCATION "vs.hlsl" 10 " vout.color = color;" + STEP_IN + EXPECT LOCAL "vout.color.x" EQ 1.000000 + EXPECT LOCAL "vout.color.y" EQ 0.000000 + EXPECT LOCAL "vout.color.z" EQ 0.000000 + EXPECT LOCATION "vs.hlsl" 12 "}" + CONTINUE + END +END + +EXPECT framebuffer IDX 0 0 SIZE 32 32 EQ_RGB 255 0 0 diff --git a/tests/cases/debugger_hlsl_function_call.amber b/tests/cases/debugger_hlsl_function_call.amber new file mode 100644 index 0000000..9504b03 --- /dev/null +++ b/tests/cases/debugger_hlsl_function_call.amber @@ -0,0 +1,212 @@ +#!amber +# Copyright 2020 The Amber Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SET ENGINE_DATA fence_timeout_ms 1000000 + +VIRTUAL_FILE "compute.hlsl" + +[[vk::binding(0)]] +StructuredBuffer data; + +int C(int x) +{ + int y = x*x; + return y; +} + +int B(int x) +{ + int y = x + 2; + return C(y) * 2; +} + +int A(int x) +{ + int y = B(x + 1); + int z = B(y) + B(y+1); + return x + y + z; +} + +[numthreads(1,1,1)] +void main() { + data[0] = A(data[0]); +} +END + +SHADER compute shader HLSL VIRTUAL_FILE "compute.hlsl" + +BUFFER data DATA_TYPE int32 DATA + 10 +END + +PIPELINE compute pipeline + ATTACH shader + SHADER_OPTIMIZATION shader + --legalize-hlsl + END + BIND BUFFER data AS storage DESCRIPTOR_SET 0 BINDING 0 +END + +DEBUG pipeline 1 1 1 + THREAD GLOBAL_INVOCATION_ID 0 0 0 + EXPECT CALLSTACK + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 26 " data[0] = A(data[0]);" + STEP_IN + + EXPECT CALLSTACK + "A" "compute.hlsl" 18 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 18 "{" + STEP_IN + + EXPECT CALLSTACK + "A" "compute.hlsl" 19 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 19 " int y = B(x + 1);" + EXPECT LOCAL "x" EQ 10 + STEP_IN + + EXPECT CALLSTACK + "B" "compute.hlsl" 12 + "A" "compute.hlsl" 19 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 12 "{" + STEP_IN + + EXPECT CALLSTACK + "B" "compute.hlsl" 13 + "A" "compute.hlsl" 19 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 13 " int y = x + 2;" + EXPECT LOCAL "x" EQ 11 + STEP_IN + + EXPECT CALLSTACK + "B" "compute.hlsl" 14 + "A" "compute.hlsl" 19 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 14 " return C(y) * 2;" + EXPECT LOCAL "x" EQ 11 + EXPECT LOCAL "y" EQ 13 + STEP_IN + + EXPECT CALLSTACK + "C" "compute.hlsl" 6 + "B" "compute.hlsl" 14 + "A" "compute.hlsl" 19 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 6 "{" + STEP_IN + + EXPECT CALLSTACK + "C" "compute.hlsl" 7 + "B" "compute.hlsl" 14 + "A" "compute.hlsl" 19 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 7 " int y = x*x;" + EXPECT LOCAL "x" EQ 13 + STEP_IN + + # TODO: Returns are non-steppable. Fix + # EXPECT LOCATION "compute.hlsl" 8 " return y;" + # EXPECT LOCAL "x" EQ 11 # TODO: "x" should be visible + # EXPECT LOCAL "y" EQ 0 + # STEP_IN + # EXPECT CALLSTACK + # "B" "compute.hlsl" 14 + # "A" "compute.hlsl" 19 + # "main" "compute.hlsl" 26 + # END + + EXPECT CALLSTACK + "B" "compute.hlsl" 14 + "A" "compute.hlsl" 19 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 14 " return C(y) * 2;" + STEP_IN + EXPECT CALLSTACK + "A" "compute.hlsl" 19 + "main" "compute.hlsl" 26 + END + + EXPECT CALLSTACK + "A" "compute.hlsl" 19 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 19 " int y = B(x + 1);" + STEP_IN + + EXPECT CALLSTACK + "A" "compute.hlsl" 20 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 20 " int z = B(y) + B(y+1);" + EXPECT LOCAL "y" EQ 338 + STEP_IN + + EXPECT CALLSTACK + "B" "compute.hlsl" 12 + "A" "compute.hlsl" 20 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 12 "{" + STEP_IN + + EXPECT CALLSTACK + "B" "compute.hlsl" 13 + "A" "compute.hlsl" 20 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 13 " int y = x + 2;" + STEP_OUT + + EXPECT CALLSTACK + "A" "compute.hlsl" 20 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 20 " int z = B(y) + B(y+1);" + EXPECT LOCAL "y" EQ 338 + STEP_OVER + STEP_OVER + + EXPECT CALLSTACK + "A" "compute.hlsl" 21 + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 21 " return x + y + z;" + EXPECT LOCAL "y" EQ 338 + EXPECT LOCAL "z" EQ 463762 + STEP_OUT + + EXPECT CALLSTACK + "main" "compute.hlsl" 26 + END + EXPECT LOCATION "compute.hlsl" 26 " data[0] = A(data[0]);" + + CONTINUE + END +END + +EXPECT data IDX 0 EQ 464110 diff --git a/tests/cases/debugger_hlsl_shadowed_vars.amber b/tests/cases/debugger_hlsl_shadowed_vars.amber index 458e4d1..bf8a790 100644 --- a/tests/cases/debugger_hlsl_shadowed_vars.amber +++ b/tests/cases/debugger_hlsl_shadowed_vars.amber @@ -99,14 +99,12 @@ BUFFER framebuffer FORMAT B8G8R8A8_UNORM PIPELINE graphics pipeline ATTACH vtex_shader SHADER_OPTIMIZATION vtex_shader - --inline-entry-points-exhaustive - --eliminate-dead-functions + --legalize-hlsl END ATTACH frag_shader SHADER_OPTIMIZATION frag_shader - --inline-entry-points-exhaustive - --eliminate-dead-functions + --legalize-hlsl END VERTEX_DATA position_buf LOCATION 0 diff --git a/tests/run_tests.py b/tests/run_tests.py index 8898491..08bf7ee 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -54,6 +54,10 @@ DEBUGGER_CASES = [ "debugger_hlsl_basic_vertex.amber", "debugger_hlsl_shadowed_vars.amber", "debugger_spirv_line_stepping.amber", + "debugger_hlsl_basic_fragment_with_legalization.amber", + "debugger_hlsl_basic_vertex_with_legalization.amber", + "debugger_hlsl_function_call.amber", + "debugger_hlsl_shadowed_vars.amber", ] SUPPRESSIONS_SWIFTSHADER = [ @@ -105,6 +109,10 @@ DXC_CASES = [ "debugger_hlsl_basic_fragment.amber", "debugger_hlsl_basic_vertex.amber", "debugger_hlsl_shadowed_vars.amber", + "debugger_hlsl_basic_fragment_with_legalization.amber", + "debugger_hlsl_basic_vertex_with_legalization.amber", + "debugger_hlsl_function_call.amber", + "debugger_hlsl_shadowed_vars.amber", ] SUPPRESSIONS_DAWN = [ -- cgit v1.2.3 From 758f918f2b49588ba8b1e58f08eaa833e96b2fa4 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Wed, 18 Nov 2020 16:33:00 -0500 Subject: Various fixes for size comparisons (#924) * Various fixes for size comparisons This CL fixes up various size comparison issues in amber along with running the formatter. * Roll Deps Roll third_party/dxc/ c607bb3c0..f1f60648d (23 commits) https://github.com/Microsoft/DirectXShaderCompiler/compare/c607bb3c032d...f1f60648df03 $ git log c607bb3c0..f1f60648d --date=short --no-merges --format='%ad %ae %s' 2020-11-12 hekotas Fix hctbuild to enable passing of quoted values and values with parenthesis (#3256) 2020-11-12 marijns95 Linux: Implement prefix-counted BSTR allocation in SysAllocStringLen (#3250) 2020-11-11 hekotas Fix dxilconv crash when initialization fails (#3254) 2020-11-10 grroth Handle scalar args to out vector params (#3246) 2020-11-09 jaebaek [spirv] emit OpLine at the end of entry function (#3244) 2020-11-06 hekotas Support for ARM64EC and custom cmake (#3245) 2020-11-05 hekotas Minor refactoring to reduce size of dxilconv.dll (#3240) 2020-11-04 texr Fix lost debug info on DispatchMesh payload in AS (#3243) 2020-11-04 jaebaek Revert "[spirv] add location for DebugDeclare (#3230)" (#3242) 2020-11-04 grroth Initialize conversion remarks result (#3241) 2020-11-03 31109344+adam-yang Made exit values not have to dominate latch in structurize loop exit (#3220) 2020-11-03 hekotas Fix DIA SDK detection for ARM64 and VS2017 (#3239) 2020-11-02 grroth New approach to avoid skipallocas (#3219) 2020-11-02 jaebaek [spirv] add location for DebugDeclare (#3230) 2020-11-02 jaebaek [spirv] wrap instructions with OpNoLine (#3229) 2020-11-02 hekotas Fix DIA SDK detection (#3231) 2020-11-02 Junda.Liu [spirv] Fix [[vk::push_constant]] on ConstantBuffer part II (#3216) 2020-11-02 Junda.Liu [spirv] globallycoherent should generate SPIR-V decoration Coherent (#3217) 2020-10-30 texr Fix precise propagation through various missing paths (#3224) 2020-10-30 texr Fix regression in lib vector arg case when skipping copy-out (#3232) 2020-10-30 31109344+adam-yang Bitpiece crash when value/addr are null (#3227) 2020-10-29 hekotas Add caps check for optional 16bit ops support to several execution tests. (#3222) 2020-10-28 31109344+adam-yang Make sure bitpiece not generated that covers the entire variable (#3223) Created with: roll-dep third_party/dxc Roll third_party/clspv/ 3a11614ee..e0406e705 (22 commits) https://github.com/google/clspv/compare/3a11614ee409...e0406e7053d1 $ git log 3a11614ee..e0406e705 --date=short --no-merges --format='%ad %ae %s' 2020-11-10 alanbaker Implement fdim (#675) 2020-11-10 marco.antognini Lower OpenCL vloadN and vstoreN (#670) 2020-11-09 alanbaker Implement isnormal (#674) 2020-11-07 alanbaker Implement islessgreater (#672) 2020-11-06 alanbaker Implement isordered and isunordered (#671) 2020-11-05 alanbaker Implement ctz (#669) 2020-11-05 alanbaker Implement sub_sat (#668) 2020-11-03 alanbaker Implement mad_sat (#667) 2020-11-03 marco.antognini Lower function call and initial support for LLVM intrinsics (#666) 2020-11-02 kpet Fix hadd/rhadd for signed types (#665) 2020-11-02 alanbaker Fix non-32-bit clz (#664) 2020-10-30 marco.antognini Lower UnaryOperator and handle fast math flags (#663) 2020-10-29 alanbaker Implement rotate in terms of llvm.fshl (#662) 2020-10-29 alanbaker Implement hadd and rhadd (#660) 2020-10-29 alanbaker Add support for OpenCL 2.0 atomic functions (#657) 2020-10-29 alanbaker Update deps (#661) 2020-10-29 marco.antognini Recusiverly lower instructions (#655) 2020-10-28 alanbaker Add convergent attribute in more cases (#658) 2020-10-26 alanbaker Implement add_sat (#656) 2020-10-22 alanbaker Prevent duplicate types and decorations (#654) 2020-10-19 kpet Add support for -cl-std=CL3.0 (#653) 2020-10-19 marco.antognini Lower function parameters and return type (#646) Created with: roll-dep third_party/clspv Roll third_party/shaderc/ 813ef3dc0..88f9156d7 (3 commits) https://github.com/google/shaderc/compare/813ef3dc0d5e...88f9156d7f6a $ git log 813ef3dc0..88f9156d7 --date=short --no-merges --format='%ad %ae %s' 2020-11-09 dneto Replace C-style cast with static_cast 2020-11-12 dneto Roll back googletest to earlier version 2020-11-02 rharrison Roll 6 dependencies (#1144) Created with: roll-dep third_party/shaderc Roll third_party/spirv-tools/ df4198e50..1f2fcddd3 (21 commits) https://github.com/KhronosGroup/SPIRV-Tools/compare/df4198e50eaa...1f2fcddd3963 $ git log df4198e50..1f2fcddd3 --date=short --no-merges --format='%ad %ae %s' 2020-11-13 afdx spirv-opt: Set parent when adding basic block (#4021) 2020-11-13 jaebaek spirv-opt: properly preserve DebugValue indexes operand (#4022) 2020-11-11 dneto Use less stack space when validating Vulkan builtins (#4019) 2020-11-05 46493288+sfricke-samsung spirv-val: Fix SPV_KHR_fragment_shading_rate VUID label (#4014) 2020-11-05 46493288+sfricke-samsung spirv-val: Label Layer and ViewportIndex VUIDs (#4013) 2020-11-05 alanbaker Add dead function elimination to -O (#4015) 2020-11-04 jaebaek Add DebugValue for invisible store in single_store_elim (#4002) 2020-11-04 dnovillo Fix SSA re-writing in the presence of variable pointers. (#4010) 2020-11-04 afdx spirv-fuzz: Fixes to pass management (#4011) 2020-11-03 afdx spirv-fuzz: Add support for reining in rogue fuzzer passes (#3987) 2020-11-03 vasniktel spirv-fuzz: Fix assertion failure in FuzzerPassAddCompositeExtract (#3995) 2020-11-03 vasniktel spirv-fuzz: Fix invalid equation facts (#4009) 2020-11-03 vasniktel spirv-fuzz: Fix bugs in TransformationFlattenConditionalBranch (#4006) 2020-11-03 andreperezmaselco.developer spirv-fuzz: Fix bug related to transformation applicability (#3990) 2020-10-30 jaebaek Temporarily add EmptyPass to prevent glslang from failing (#4004) 2020-10-30 Junda.Liu spirv-opt: Add support to prevent functions from being inlined if they have DontInline flag (#3858) 2020-10-29 jaebaek Propagate OpLine to all applied instructions in spirv-opt (#3951) 2020-10-29 bclayton CMake: Add SPIRV_TOOLS_BUILD_STATIC flag (#3910) 2020-10-29 dneto Avoid copying a ref in a loop (#4000) 2020-10-28 justsid spirv-val: Allow the ViewportIndex and Layer built-ins on SPIR-V 1.5 (#3986) 2020-10-28 dnovillo Simplify logic to decide whether CCP modified the IR (#3997) Created with: roll-dep third_party/spirv-tools Roll third_party/glslang/ 740ae9f60..beec2e4a7 (17 commits) https://github.com/KhronosGroup/glslang/compare/740ae9f60b00...beec2e4a7c4d $ git log 740ae9f60..beec2e4a7 --date=short --no-merges --format='%ad %ae %s' 2020-11-12 mbechard tweak local_size comparison a bit (#2456) 2020-11-12 dneto Avoid spuriously adding Geometry capability for vert, tesc, tese (#2462) 2020-11-12 greg New nonuniform analysis (#2457) 2020-11-09 jhall1024 Implement GL_EXT_terminate_invocation (#2454) 2020-11-06 rdb Fix token-pasting macros not working in preprocessor directives. (#2453) 2020-11-06 laddoc Fix warning in iomapper. (#2449) 2020-11-04 TobyHector Add GL_EXT_shader_image_int64 support (#2409) 2020-11-04 laddoc 8. io mapping refine & qualifier member check & resolver expand (#2396) 2020-11-02 courtneygo Fix build error with Chromium & ANGLE (#2446) 2020-11-02 dev Add new SpirvToolsDisassemble API interface + Improve Doc on existing API interface (#2442) 2020-11-02 justsid Support for CapabilityShaderViewportIndex and CapabilityShaderLayer (#2432) 2020-11-02 jaebaek Do not use PropagateLineInfoPass and RedundantLineInfoElimPass (#2440) 2020-09-09 greg Add texture sample to nonuniform test 2020-09-08 greg Add buffer store to nonuniform tests 2020-09-03 bas SPV: Add NonUniform decoration for constructors. 2020-09-03 bas SPV: Add NonUniform decoration for OpImages created during lowering. 2020-08-24 bas SPV: Add NonUniform decorations for stores. Created with: roll-dep third_party/glslang Roll third_party/spirv-headers/ 7845730ca..5ab5c9619 (2 commits) https://github.com/KhronosGroup/SPIRV-Headers/compare/7845730cab6e...5ab5c96198f3 $ git log 7845730ca..5ab5c9619 --date=short --no-merges --format='%ad %ae %s' 2020-11-04 michael.kinsner Reserve additional loop control bit for Intel extension (NoFusionINTEL) (#175) 2020-11-02 4464295+XAMPPRocky Add EmbarkStudios/rust-gpu to vendor list. (#174) Created with: roll-dep third_party/spirv-headers Roll third_party/vulkan-loader/ 2b0892e15..be6ccb9ec (7 commits) https://github.com/KhronosGroup/Vulkan-Loader/compare/2b0892e15bd8...be6ccb9ecaf7 $ git log 2b0892e15..be6ccb9ec --date=short --no-merges --format='%ad %ae %s' 2020-11-02 shabbyx Reland "Generate libvulkan.so.1 on Linux instead of libvulkan.so" 2020-11-10 shannon build: Update known-good files for 1.2.160 header 2020-11-02 shannon build: Update known-good files for 1.2.159 header 2020-10-30 shabbyx Revert "Generate libvulkan.so.1 on Linux instead of libvulkan.so" 2020-10-22 xantares09 Add an option to disable MASM 2020-10-20 xantares09 Configure vulkan.pc when pkg-config is available 2020-10-22 shabbyx Generate libvulkan.so.1 on Linux instead of libvulkan.so Created with: roll-dep third_party/vulkan-loader Roll third_party/clspv-llvm/ b91a236ee..a6ac2b32f (2881 commits) https://github.com/llvm/llvm-project/compare/b91a236ee1c3...a6ac2b32fbab $ git log b91a236ee..a6ac2b32f --date=short --no-merges --format='%ad %ae %s' 2020-11-16 schuett Convert TypeSpecifiersPipe from Specifiers.h to a scoped enum; NFC 2020-11-16 v.g.vassilev Reland "Move the test compiler setup in a common place. NFCI" 2020-11-16 dmitry.preobrazhensky [AMDGPU][MC] Corrected error position for some operands and modifiers 2020-11-16 mkazantsev [Test] More tests on range checks 2020-11-11 caroline.concatto [AArch64] Add check for widening instruction for SVE. 2020-11-12 matthew.malcomson Hwasan reporting check for dladdr failing 2020-11-16 vitalybuka Revert "Move the test compiler setup in a common place. NFCI" 2020-11-16 vitalybuka [NFC][tsan] Simplify call_pthread_cancel_with_cleanup 2020-11-16 mkazantsev [Test] More tests on range check elimination 2020-11-13 mgorny [lldb] [Process/FreeBSDRemote] Optimize regset pointer logic 2020-11-11 mgorny [lldb] [Process/FreeBSDRemote] Modernize and simplify YMM logic 2020-11-11 mgorny [lldb] [Process/FreeBSDRemote] Access debug registers via offsets 2020-11-11 mgorny [lldb] [Process/FreeBSDRemote] Access FPR via RegisterInfo offsets 2020-11-16 dmitry.preobrazhensky [AMDGPU][MC] Corrected error position for swizzle() 2020-11-16 dmitry.preobrazhensky [AMDGPU][MC] Corrected error position for hwreg() and sendmsg() 2020-11-10 mgorny [lldb] [Process/FreeBSDRemote] Access GPR via reginfo offsets 2020-11-16 nicolas.vasilache [mlir][Linalg] Add support for tileAndDistribute on tensors. 2020-11-13 marukawa [VE] Add pfchv intrinsic instructions 2020-11-16 vitalybuka [sanitizer] Fix StackDepotPrint testing 2020-11-16 benny.kra [LoopFlatten] Fold variable into assert. NFC. 2020-11-16 flo [IRGen] Add !annotation metadata for auto-init stores. 2020-11-09 sjoerd.meijer [LoopFlatten] Widen the IV 2020-11-16 david.penry [ARM] Cortex-M7 schedule 2020-11-16 goncharov.mikhail [lld] Use %t file in test 2020-11-02 protze [OpenMP][Tool] Add Archer option to disable data race analysis for sequential part 2020-11-13 fraser [RISCV] Use a macro to simplify getTargetNodeName 2020-11-16 marukawa [VE] Change variable capitalization 2020-11-16 simon.moll [VP][NFC] Rename to HANDLE_VP_TO_OPC 2020-11-13 git [clang][cli] Add support for options with two flags for controlling the same field. 2020-11-16 lhames [MCJIT] Profile the code generated by MCJIT engine using Intel VTune profiler 2020-11-16 simon.moll [VE] LVLGen sets VL before vector insts 2020-11-16 mkazantsev Recommit "[NFC] Move code between functions as a preparation step for further improvement" 2020-11-15 kazu [JumpThreading] Call eraseBlock when folding a conditional branch 2020-11-15 kazu [IR] Use llvm::is_contained in BasicBlock::removePredecessor (NFC) 2020-11-15 kazu [Loop Fusion] Use pred_empty and succ_empty (NFC) 2020-11-15 kazu [ADCE] Use succ_empty (NFC) 2020-11-16 qshanz [NFC][Test] Add test coverage for IEEE Long Double on Power8 2020-11-15 kazu [BranchProbabilityInfo] Use predecessors(BB) and successors(BB) (NFC) 2020-11-15 kazu [TRE] Use successors(BB) (NFC) 2020-11-15 craig.topper [X86] Fix crash with i64 bitreverse on 32-bit targets with XOP. 2020-11-15 kazu [SanitizerCoverage] Use llvm::all_of (NFC) 2020-11-10 serguei.katkov [IRCE] Use the same min runtime iteration threshold for BPI and BFI checks 2020-11-16 pengfei.wang [CodeGen][X86] Remove unused trivial check-prefixes from all CodeGen/X86 directory. 2020-11-15 richard PR48169: Fix crash generating debug info for class non-type template parameters. 2020-11-15 spatel [InstCombine] reduce code for flip of masked bit; NFC 2020-11-15 spatel [InstCombine] add multi-use demanded bits fold for add with low-bit mask 2020-11-15 spatel [InstCombine] add vector tests for multi-use demanded bits; NFC 2020-11-14 martin [OpenMP] Fix building for windows after adding omp_calloc 2020-11-15 nikita.ppv [AA] Add missing AAQI parameter 2020-11-15 flo [MemorySSA] Add pointer decrement loop clobber test case. (...) 2020-10-19 martin [libcxx] [test] Mark tests that require specific allocation behaviours as libcpp only 2020-10-19 martin [libcxx] [test] Exclude domain socket tests on windows, like bsd/darwin 2020-10-19 martin [libcxx] [test] Add LIBCPP_ONLY() around another test for an implementation detail 2020-10-19 martin [libcxx] [test] Don't require fs::path::operator(string_type&&) to be noexcept 2020-10-19 martin [libcxx] [test] Allow fs::permissions(path, perms, perm_options, error_code) to be noexcept 2020-10-19 martin [libcxx] [test] Do error printfs to stderr in filesystems tests 2020-10-19 martin [clang] Automatically link against oldnames just as linking against libcmt 2020-10-14 dexonsmith clang/{Format,Rewrite}: Stop using SourceManager::getBuffer, NFC 2020-10-15 eugenis Add alloca size threshold for StackTagging initializer merging. 2020-10-19 aeubanks [test][NPM] Fix already-vectorized.ll under NPM 2020-10-19 craig.topper [SelectionDAG][X86] Enable SimplifySetCC CTPOP transforms for vector splats 2020-10-19 craig.topper [X86] Add i32->float and i64->double bitcast pseudo instructions to store folding table. 2020-10-17 Matthew.Arsenault Fix typo 2020-10-19 lhames [ORC] Fix a missing include. 2020-10-19 aeubanks [NPM][test] Fix some LoopVectorize tests under NPM 2020-10-19 nikita.ppv [BatchAA] Add test for incorrect phi cycle result (NFC) 2020-10-19 Tony.Tye [AMDGPU] Correct comment typo in SIMemoryLegaliizer.cpp 2020-10-19 aeubanks [NPM][opt] Run -O# after other passes in legacy PM compatibility mode 2020-10-19 clementval [flang][openacc] Switch to use TODO from D88909 2020-10-19 alexandre.ganea [LLDB][TestSuite] Improve skipIfWindowsAndNonEnglish in decorators.py 2020-10-19 mcinally [SVE] Update vector reduction intrinsics in new tests. 2020-10-13 michaelrj [libc] Add LLVM libc specific functions to llvm_libc_ext.td. 2020-10-19 jay.foad [AMDGPU] Remove MUL_LOHI_U24/MUL_LOHI_I24 2020-10-19 jhuber6 [OpenMP] Fixing OpenMP/driver.c failing on 32-bit hosts 2020-10-19 atmndp [LangRef] Define mustprogress attribute 2020-10-19 mikhail.maltsev [clang] Use SourceLocation as key in std::map, NFCI 2020-10-19 flo [SCEV] Add tests where assumes can be used to improve tripe multiple. 2020-10-16 ldionne [libc++] Add more tests for operator<< on std::complex 2020-10-15 amy.kwan1 [DAGCombiner][PowerPC] Remove isMulhCheaperThanMulShift TLI hook, Use isOperationLegalOrCustom directly instead. 2020-10-19 jonas [llvm] Make obj2yaml and yaml2obj LLVM utilities instead of tools 2020-10-19 Tony.Tye [AMDGPU] Simplify cumode handling in SIMemoryLegalizer 2020-10-17 Tony.Tye [AMDGPU] Extend hip-toolchin-features.hip test 2020-10-17 Tony.Tye [AMDGPU] Correct hsa-diag-v3.s test 2020-10-19 mtrofin [NFC][MC] Type [MC]Register uses in MachineTraceMetrics 2020-10-19 Alexander.Richardson [libc++] Skip tests using constexpr destructors with older clang versions 2020-10-06 sameeranjayant.joshi [Flang][OpenACC] Fix for branching out issue in OpenACC parallel construct. 2020-10-16 ldionne [libc++] Refactor the fuzzing tests 2020-10-19 lhames [ORC] Fix unused variable warning. 2020-10-19 llvm-dev [InstCombine] foldOrOfICmps - only fold (icmp_eq B, 0) | (icmp_ult/gt A, B) for integer types 2020-10-17 mtrofin [ML] Add final reward logging facility. 2020-10-19 nabeel.omer [Dexter][NFC] Add Missing Commands to Commands.md Contents 2019-10-01 ldionne [libc++] Define new/delete in libc++abi only by default 2020-10-19 Casey [libc++][test] Portably silence warnings 2020-10-19 Alexander.Richardson [lit] Avoid calling realpath() for every printed message 2020-10-19 llvm-dev Revert rGa704d8238c86bac: "[InstCombine] Add or((icmp ult/ule (A + C1), C3), (icmp ult/ule (A + C2), C3)) uniform vector support" 2020-10-19 n.james93 [clang-tidy] Add scoped enum constants to identifier naming check 2020-10-16 psteinfeld [flang] Add name match checks for interface procedures 2020-10-19 sam.mccall [clangd] Add test for structured-binding completion. NFC 2020-10-19 georgemitenk0v [MLIR][SPIRVToLLVM] Updated documentation for composite ops 2020-10-19 llvm-dev [InstCombine] Add (icmp ne A, 0) | (icmp ne B, 0) --> (icmp ne (A|B), 0) vector support Created with: roll-dep third_party/clspv-llvm Roll third_party/swiftshader/ df17a7610..e4c1a25cc (56 commits) https://swiftshader.googlesource.com/SwiftShader.git/+log/df17a76102df..e4c1a25cc679 $ git log df17a7610..e4c1a25cc --date=short --no-merges --format='%ad %ae %s' 2020-11-12 capn Use LLVM JIT for MemorySanitizer GN builds 2020-11-12 srisser Update vulkan headers to 1.2.160 2020-11-12 swiftshader.regress Regres: Update test lists @ 4804ac87 2020-11-11 zzyiwei Disable VK_KHR_external_memory_fd for Android build 2020-10-28 natsu Handle image properties from external device memory 2020-11-12 capn Fix conditionally enabling Reactor MSan instrumentation 2020-11-02 capn Implement MemorySanitizer instrumentation of Reactor routines 2020-08-25 nicolascapens Fix backslash interpreted as part of URL 2020-10-26 srisser Implement VK_KHR_shader_float_controls 2020-11-10 amaiorano Subzero: clang-format crosstest, pnacl-llvm, runtime, and unittest 2020-11-10 amaiorano Subzero: clang-format src 2020-11-02 capn Fix LLVM host triple for ORCv2 JIT 2020-11-11 srisser Add SPIR-V tools dependency to BUILD.gn files 2020-11-10 natsu Fix Android build 2020-11-06 amaiorano Add a unit test for bug fixed by swiftshader-cl/50008 2020-11-09 srisser Track SPIR-V version in VkConfig.hpp 2019-04-24 vhau Modify gralloc0 implementation 2020-11-05 jaebaek SpirvShaderDebugger: Correct member index for DebugValue 2020-11-05 capn Fix Android.bp build after SPIRV-Tools update 2020-11-04 amaiorano Subzero: fix invalid arg access on Windows x86 for split variables 2020-11-03 amaiorano Subzero: fix non-deterministic stack layout and code-gen 2020-11-05 srisser Squashed 'third_party/SPIRV-Tools/' changes from f7da52775..a61d07a72 2020-11-04 capn Fix Vulkan benchmarks build 2020-10-02 capn Fix unaligned access on depth values 2020-11-02 capn Fix LLVM alloca array size type 2020-11-02 capn Resolve MSan symbols dynamically 2020-11-02 capn Switch Chromium/Fuchsia to use the LLVM ORCv2 JIT 2020-11-03 nicolascapens Clarify the ICD/loader compatibility 2020-11-03 swiftshader.regress Regres: Update test lists @ b5bf8269 2020-11-03 capn Set LLVM_ENABLE_ABI_BREAKING_CHECKS for Debug builds only 2020-10-30 jari.komppa Add script to verify proper Memset template use 2020-11-02 capn Set the LLVM module's target triple 2020-10-30 capn Consistently remove double colon from llvm namespace 2020-10-30 capn Emulate gather/scatter for MSan builds 2020-10-30 capn Prevent 'most vexing parse' issue 2020-11-02 sugoi Squashed 'third_party/SPIRV-Tools/' changes from 82b378d671..f7da527757 2020-10-23 amaiorano Subzero: fix Ice::BitVector::grow not copying old to new data 2020-10-30 jari.komppa Ignore third party libraries during presubmit 2020-10-28 jari.komppa Add check for vtable in memset template 2020-10-29 sugoi Squashed 'third_party/SPIRV-Tools/' changes from 8a5500656..82b378d67 2020-10-29 sugoi Squashed 'third_party/SPIRV-Headers/' changes from 979924c8b..7845730ca 2020-10-23 capn Fix LLVM pointer element type 2020-10-29 capn Avoid false-positive MSan error for thread_local 2020-10-29 capn Squashed 'third_party/marl/' changes from f1c446ccd..3285a2dfb 2020-10-28 capn Temporarily support both ORCv1 and ORCv2 2020-10-26 amaiorano Apply google3 upstream fixes for latest LLVM 2020-10-22 amaiorano LLVMJIT: fix asserts in latest LLVM 2020-10-08 capn Support MemorySanitizer builds with CMake 2020-10-15 srisser Implement VK_KHR_shader_subgroup_extended_types 2020-10-19 srisser Update VkStringify to use vulkan.hpp to_string 2020-10-21 bclayton LLVMJIT: Fix memory leak 2020-10-10 natsu Update SwiftShader VK AHB to support generic gralloc 2020-10-21 amaiorano Fix when built against latest LLVM (11) 2020-10-20 amaiorano Fix Android build 2020-10-19 amaiorano Subzero: workaround bad codegen for Windows x86 at Om1 optimization level 2020-10-19 bclayton LLVM: Replace legacy ORC JIT with new API Created with: roll-dep third_party/swiftshader Roll third_party/vulkan-headers/ 320af06cb..11c6670b4 (3 commits) https://github.com/KhronosGroup/Vulkan-Headers/compare/320af06cbdd2...11c6670b4a4f $ git log 320af06cb..11c6670b4 --date=short --no-merges --format='%ad %ae %s' 2020-11-15 oddhack Update for Vulkan-Docs 1.2.161 2020-11-08 oddhack Update for Vulkan-Docs 1.2.160 2020-11-01 oddhack Update for Vulkan-Docs 1.2.159 Created with: roll-dep third_party/vulkan-headers Roll third_party/vulkan-validationlayers/ 87b0951f8..9d3ef3258 (70 commits) https://github.com/KhronosGroup/Vulkan-ValidationLayers/compare/87b0951f8dba...9d3ef3258715 $ git log 87b0951f8..9d3ef3258 --date=short --no-merges --format='%ad %ae %s' 2020-11-13 pankratz layers: Removed duplicate type declaration 2020-11-13 mark scripts: Suppress warning for empty difflist 2020-11-12 mark scripts: Remove format checking shell scripts 2020-11-11 mark scripts: Add python format-checking script and update travis 2020-11-05 mark tests: Add oldSwapchain-from-different-device test 2020-11-09 mark threading: Make swapchain objects traceable to parent 2020-11-10 mark tests: Added specialuse extension BP tests 2020-11-10 mark practices: Add checking of specialuse extensions 2020-11-09 mark practices: Check for specialuse extensions and warn 2020-11-09 mark practices: Added specialuse extension table 2020-11-10 karl layers: Fix typedef and spelling 2020-11-09 jeremyg syncval: Convert enum SyncStageAccessFlags to a std::bitset 2020-11-09 jeremyg syncval: Change generated lookup tables to be const. 2020-11-06 marshall tests: Test queue retirement over timeline semaphores 2020-11-06 marshall layers: Fix queue retirement via waited-on timeline semaphores 2020-11-06 rgarcia layers: Check nullDescriptor when validating vertex attributes 2020-11-02 shannon build: Update known-good files for 1.2.159 header 2020-11-05 orbea cmake: Install the header files into the vulkan directory 2020-11-04 liyl build: Allow generating layers json file for cross-compiling 2020-11-05 courtneygo Fix missing source reference 2020-10-31 s.fricke layers: Change copy2 VU from int to string 2020-11-04 orbea cmake: Silence warnings 2020-11-03 orbea cmake: Add BUILD_WERROR 2020-11-01 s.fricke layers: Add VUID 01591 2020-11-01 s.fricke tests: Add VUID 04113 and 04114 2020-11-01 s.fricke layers: Add VUID 04113 and 04114 2020-11-01 s.fricke layers: Label 04101 and 04010 2020-11-03 s.fricke layers: Add Android 24 and 25 support 2020-11-03 tony docs: Fix enabling debug printf 2020-10-31 skdkksfadkadkk layers: Fix checks for 01508 and 01509 2020-11-03 neel.bedekar layers: Remove unnecessary FDM tiling check 2020-11-02 mark tests: Add 2718 security VUID tests 2020-10-30 mark stateless: Fix clang-formatting issues 2020-10-30 mark stateless: Comment out unused legacy vuids 2020-10-30 mark stateless: Output correct VUID for validate_string_array 2020-10-30 mark stateless: Remove non-VU pNext chain cycle check 2020-10-30 mark stateless: Remove warnings from viewport validation 2020-10-30 mark stateless: Use correct VUIDs for drawCount check 2020-10-29 jzulauf syncval: Add raster order rules to load op validation 2020-10-23 jzulauf syncval: Add layout transition info w/o prev access 2020-10-22 jzulauf syncval: Remove unsafe/unused code path. 2020-10-21 jzulauf syncval: Support range gen w/ empty subres ranges 2020-10-19 jzulauf syncval: Add dst scope barriers to all ILT 2020-10-06 jzulauf tests: Add multi dependency syncval test 2020-10-06 jzulauf syncval: Multidep subpass layout transition rework 2020-10-02 jzulauf syncval: Simplify input attachment read tracking 2020-09-29 jzulauf syncval: vkCmdPipelineBarrier multidep support 2020-09-23 jzulauf syncval: Cleanup input attachment read tracking 2020-10-29 tony layers: Fix checks for 02502 and 02503 2020-10-27 tony gpu: Report OpLine info even if no source 2020-10-27 tony tests: Add test for variable count descriptors 2020-10-27 tony layers: Add validation for variable descriptor count 2020-10-27 tony layers: Fix error message 2020-10-28 jeremyg syncval: Add override keyword to ValidationObject method overrides. 2020-10-26 s.fricke layers: Relabel vkCmdDrawIndirectByteCountEXT VUs 2020-10-30 nathaniel layers: Fix test error introduced by #2276 2020-10-29 s.fricke layers: Add extra api names to errors 2020-10-28 s.fricke tests: Add SampleMask Array Limit VUID 2020-10-26 s.fricke layers: Add SampleMask Array Limit VUID 2020-10-24 s.fricke layers: Add table for buffer image copy VUs 2020-10-29 s.fricke layers: Add VK_EXT_4444_formats support 2020-10-30 mark contributing: Updated for Travis CI migration 2020-10-30 mark readme: Updated for Travis migration 2020-10-29 s.fricke layers: Add missing 1.2 overload functions 2020-10-21 s.fricke tests: Add input attachment aspectMask/layout 2020-10-20 s.fricke layers: Remove non-input aspectMask check 2020-10-28 shannon build: Reconcile final 158 VUID inconsistencies 2020-10-21 mark tests: Add invalid stride test for GetQueryPoolResults 2020-10-21 mark corechecks: Added 4519 vuid for GetQueryPoolResults stride 2020-10-28 krzysio.kurek stateless: Add a missing "not" to ValidateGreaterThan Created with: roll-dep third_party/vulkan-validationlayers * Roll deps Roll third_party/dxc/ f1f60648d..489c2e4d3 (6 commits) https://github.com/Microsoft/DirectXShaderCompiler/compare/f1f60648df03...489c2e4d3241 $ git log f1f60648d..489c2e4d3 --date=short --no-merges --format='%ad %ae %s' 2020-11-17 rkarrenberg Move force-zero-store-lifetimes flag to help-hidden, remove accidental check from test. (#3264) 2020-11-17 marijns95 dxcisense: Allocate "TM" classes using IMalloc instead of new (#3258) 2020-11-17 rkarrenberg Enable generation of llvm.lifetime.start/.end intrinsics (#3034) 2020-11-16 ehsannas [spirv] Fix compound MulAssign with type mismatches. (#3255) 2020-11-16 ehsannas [spirv] Use isResourceType to cover SubpassInput. (#3253) 2020-11-16 ehsannas [spirv] Move descriptor scalar replacement to legalization stage. (#3261) Created with: roll-dep third_party/dxc Roll third_party/glslang/ beec2e4a7..7f6559d28 (1 commit) https://github.com/KhronosGroup/glslang/compare/beec2e4a7c4d...7f6559d2802d $ git log beec2e4a7..7f6559d28 --date=short --no-merges --format='%ad %ae %s' 2020-11-16 ShabbyX Compile out code for GL_EXT_shader_image_int64 for ANGLE (#2463) Created with: roll-dep third_party/glslang Roll third_party/clspv-llvm/ a6ac2b32f..7e30989da (134 commits) https://github.com/llvm/llvm-project/compare/a6ac2b32fbab...7e30989dabce $ git log a6ac2b32f..7e30989da --date=short --no-merges --format='%ad %ae %s' 2020-11-17 llvm-dev [IR] ShuffleVectorInst::isIdentityWithPadding - bail on non-fixed-type vector shuffles. 2020-11-17 llvm-dev [X86] nontemporal.ll - replace X32 check prefix with X86. NFC. 2020-11-17 llvm-dev [X86] subvector-broadcast.ll - replace X32 check prefix with X86. NFC. 2020-11-17 jonathan.l.peyton [OpenMP] NFC: remove tabs in message catalog file 2020-11-17 wingo [WebAssembly] Fix parsing of linking section for named global imports 2020-11-05 jonathan.l.peyton [OpenMP][stats] reset serial state when re-entering serial region 2020-11-17 Matthew.Arsenault Linker: Fix linking of byref types 2020-11-16 jay.foad [AMDGPU] Precommit more vccz workaround tests 2020-11-17 anton.a.afanasyev [SLPVectorizer] Fix assert 2020-11-17 powerman1st [clang][AVR] Improve avr-ld command line options 2020-11-16 a.bataev [OPENMP]Fix PR48076: mapping of data member pointer. 2020-11-17 flo [Matrix] Add inline assembly test case. 2020-10-30 anton.a.afanasyev [SLP] Make SLPVectorizer to use `llvm.masked.gather` intrinsic 2020-11-17 wingo [WebAssembly][MC] Remove useless overrides in MCWasmStreamer 2020-11-17 joe.ellis [AArch64][SVE] Support implicit lax vector conversions for SVE types 2020-11-14 paul [TableGen] Clean up Target .td include files 2020-11-17 benny.kra [MLIR] Fix up integration tests after b7382ed3fea08da27530a6d6d53f168fc704e4c4 2020-11-17 andrzej.warzynski [flang][nfc] Add missing dependency in CMake 2020-08-05 flo [ConstraintElimination] Add support for And. 2020-11-17 kadircet [clang-tidy] Make clang-format and include-order-check coherent 2020-11-16 erich.keane Update 'note-candiate' functions to skip lambda-conversion-op-overloads 2020-11-12 sander.desmalen Reland [LoopVectorizer] NFCI: Calculate register usage based on TLI.getTypeLegalizationCost. 2020-11-17 marukawa [VE] Implement JumpTable 2020-11-17 herhut [mlir][std] Canonicalize extract_element(tensor_cast). 2020-11-17 herhut [mlir][std] Fold dim(dynamic_tensor_from_elements, %cst) 2020-11-17 herhut [mlir][linalg] Allow tensor_to_memref in dependence analysis 2020-11-17 marukawa [VE] Correct getMnemonic 2020-11-15 zinenko [mlir] Allow for using interface class name in ODS interface definitions 2020-11-17 zinenko [mlir] Fix Python tests after "module_terminator" migrated to ODS 2020-11-17 n.james93 [clang][NFC] Use SmallString instead of SmallVector + #include #include #include diff --git a/src/amberscript/parser_attach_test.cc b/src/amberscript/parser_attach_test.cc index 1f515a2..6ab92be 100644 --- a/src/amberscript/parser_attach_test.cc +++ b/src/amberscript/parser_attach_test.cc @@ -329,8 +329,8 @@ END)"; const auto& shaders = pipeline->GetShaders(); ASSERT_EQ(1U, shaders.size()); - EXPECT_EQ(1, shaders[0].GetSpecialization().size()); - EXPECT_EQ(4, shaders[0].GetSpecialization().at(1)); + EXPECT_EQ(1u, shaders[0].GetSpecialization().size()); + EXPECT_EQ(4u, shaders[0].GetSpecialization().at(1)); } TEST_F(AmberScriptParserTest, PipelineSpecializationInt32) { @@ -354,8 +354,8 @@ END)"; const auto& shaders = pipeline->GetShaders(); ASSERT_EQ(1U, shaders.size()); - EXPECT_EQ(1, shaders[0].GetSpecialization().size()); - EXPECT_EQ(0xffffffff, shaders[0].GetSpecialization().at(2)); + EXPECT_EQ(1u, shaders[0].GetSpecialization().size()); + EXPECT_EQ(0xffffffffu, shaders[0].GetSpecialization().at(2)); } TEST_F(AmberScriptParserTest, PipelineSpecializationFloat) { @@ -379,8 +379,8 @@ END)"; const auto& shaders = pipeline->GetShaders(); ASSERT_EQ(1U, shaders.size()); - EXPECT_EQ(1, shaders[0].GetSpecialization().size()); - EXPECT_EQ(0x3f8ccccd, shaders[0].GetSpecialization().at(3)); + EXPECT_EQ(1u, shaders[0].GetSpecialization().size()); + EXPECT_EQ(0x3f8ccccdu, shaders[0].GetSpecialization().at(3)); } TEST_F(AmberScriptParserTest, PipelineSpecializationIDIsString) { @@ -469,10 +469,10 @@ END)"; const auto& shaders = pipeline->GetShaders(); ASSERT_EQ(1U, shaders.size()); - EXPECT_EQ(3, shaders[0].GetSpecialization().size()); - EXPECT_EQ(4, shaders[0].GetSpecialization().at(1)); - EXPECT_EQ(5, shaders[0].GetSpecialization().at(2)); - EXPECT_EQ(1, shaders[0].GetSpecialization().at(5)); + EXPECT_EQ(3u, shaders[0].GetSpecialization().size()); + EXPECT_EQ(4u, shaders[0].GetSpecialization().at(1)); + EXPECT_EQ(5u, shaders[0].GetSpecialization().at(2)); + EXPECT_EQ(1u, shaders[0].GetSpecialization().at(5)); } TEST_F(AmberScriptParserTest, PipelineSpecializationNoType) { @@ -496,8 +496,8 @@ END)"; const auto& shaders = pipeline->GetShaders(); ASSERT_EQ(1U, shaders.size()); - EXPECT_EQ(1, shaders[0].GetSpecialization().size()); - EXPECT_EQ(4, shaders[0].GetSpecialization().at(1)); + EXPECT_EQ(1u, shaders[0].GetSpecialization().size()); + EXPECT_EQ(4u, shaders[0].GetSpecialization().at(1)); } } // namespace amberscript diff --git a/src/amberscript/parser_bind_test.cc b/src/amberscript/parser_bind_test.cc index 62c0fc7..7f07980 100644 --- a/src/amberscript/parser_bind_test.cc +++ b/src/amberscript/parser_bind_test.cc @@ -49,10 +49,11 @@ END)"; const auto& buf_info = color_buffers[0]; ASSERT_TRUE(buf_info.buffer != nullptr); - EXPECT_EQ(0, buf_info.location); - EXPECT_EQ(250 * 250, buf_info.buffer->ElementCount()); - EXPECT_EQ(250 * 250 * 4, buf_info.buffer->ValueCount()); - EXPECT_EQ(250 * 250 * 4 * sizeof(float), buf_info.buffer->GetSizeInBytes()); + EXPECT_EQ(0u, buf_info.location); + EXPECT_EQ(250u * 250u, buf_info.buffer->ElementCount()); + EXPECT_EQ(250u * 250u * 4u, buf_info.buffer->ValueCount()); + EXPECT_EQ(250u * 250u * 4u * sizeof(float), + buf_info.buffer->GetSizeInBytes()); } TEST_F(AmberScriptParserTest, BindColorBufferTwice) { @@ -297,19 +298,19 @@ END)"; const auto& buf1 = color_buffers1[0]; ASSERT_TRUE(buf1.buffer != nullptr); - EXPECT_EQ(0, buf1.location); - EXPECT_EQ(90 * 180, buf1.buffer->ElementCount()); - EXPECT_EQ(90 * 180 * 4, buf1.buffer->ValueCount()); - EXPECT_EQ(90 * 180 * 4 * sizeof(float), buf1.buffer->GetSizeInBytes()); + EXPECT_EQ(0u, buf1.location); + EXPECT_EQ(90u * 180u, buf1.buffer->ElementCount()); + EXPECT_EQ(90u * 180u * 4u, buf1.buffer->ValueCount()); + EXPECT_EQ(90u * 180u * 4u * sizeof(float), buf1.buffer->GetSizeInBytes()); pipeline = pipelines[1].get(); const auto& color_buffers2 = pipeline->GetColorAttachments(); const auto& buf2 = color_buffers2[0]; ASSERT_TRUE(buf2.buffer != nullptr); - EXPECT_EQ(9, buf2.location); - EXPECT_EQ(256 * 300, buf2.buffer->ElementCount()); - EXPECT_EQ(256 * 300 * 4, buf2.buffer->ValueCount()); - EXPECT_EQ(256 * 300 * 4 * sizeof(uint8_t), buf2.buffer->GetSizeInBytes()); + EXPECT_EQ(9u, buf2.location); + EXPECT_EQ(256u * 300u, buf2.buffer->ElementCount()); + EXPECT_EQ(256u * 300u * 4u, buf2.buffer->ValueCount()); + EXPECT_EQ(256u * 300u * 4u * sizeof(uint8_t), buf2.buffer->GetSizeInBytes()); } TEST_F(AmberScriptParserTest, BindColorFBSizeSetBeforeBuffer) { @@ -342,10 +343,10 @@ END)"; const auto& buf1 = color_buffers1[0]; ASSERT_TRUE(buf1.buffer != nullptr); - EXPECT_EQ(0, buf1.location); - EXPECT_EQ(90 * 180, buf1.buffer->ElementCount()); - EXPECT_EQ(90 * 180 * 4, buf1.buffer->ValueCount()); - EXPECT_EQ(90 * 180 * 4 * sizeof(float), buf1.buffer->GetSizeInBytes()); + EXPECT_EQ(0u, buf1.location); + EXPECT_EQ(90u * 180u, buf1.buffer->ElementCount()); + EXPECT_EQ(90u * 180u * 4u, buf1.buffer->ValueCount()); + EXPECT_EQ(90u * 180u * 4u * sizeof(float), buf1.buffer->GetSizeInBytes()); } TEST_F(AmberScriptParserTest, BindColorFBSizeSetAfterBuffer) { @@ -378,10 +379,10 @@ END)"; const auto& buf1 = color_buffers1[0]; ASSERT_TRUE(buf1.buffer != nullptr); - EXPECT_EQ(0, buf1.location); - EXPECT_EQ(90 * 180, buf1.buffer->ElementCount()); - EXPECT_EQ(90 * 180 * 4, buf1.buffer->ValueCount()); - EXPECT_EQ(90 * 180 * 4 * sizeof(float), buf1.buffer->GetSizeInBytes()); + EXPECT_EQ(0u, buf1.location); + EXPECT_EQ(90u * 180u, buf1.buffer->ElementCount()); + EXPECT_EQ(90u * 180u * 4u, buf1.buffer->ValueCount()); + EXPECT_EQ(90u * 180u * 4u * sizeof(float), buf1.buffer->GetSizeInBytes()); } TEST_F(AmberScriptParserTest, BindColorBaseMipLevel) { @@ -414,7 +415,7 @@ END)"; const auto& buf1 = color_buffers1[0]; ASSERT_TRUE(buf1.buffer != nullptr); - EXPECT_EQ(1, buf1.base_mip_level); + EXPECT_EQ(1u, buf1.base_mip_level); } TEST_F(AmberScriptParserTest, BindColorMissingBaseMipLevel) { @@ -515,9 +516,9 @@ END)"; const auto* pipeline = pipelines[0].get(); const auto& buf = pipeline->GetDepthStencilBuffer(); ASSERT_TRUE(buf.buffer != nullptr); - EXPECT_EQ(90 * 180, buf.buffer->ElementCount()); - EXPECT_EQ(90 * 180 * 4, buf.buffer->ValueCount()); - EXPECT_EQ(90 * 180 * 4 * sizeof(float), buf.buffer->GetSizeInBytes()); + EXPECT_EQ(90u * 180u, buf.buffer->ElementCount()); + EXPECT_EQ(90u * 180u * 4u, buf.buffer->ValueCount()); + EXPECT_EQ(90u * 180u * 4u * sizeof(float), buf.buffer->GetSizeInBytes()); } TEST_F(AmberScriptParserTest, BindDepthBufferExtraParams) { @@ -680,16 +681,16 @@ END)"; const auto* pipeline = pipelines[0].get(); const auto& vertex_buffers = pipeline->GetVertexBuffers(); - ASSERT_EQ(2, vertex_buffers.size()); + ASSERT_EQ(2u, vertex_buffers.size()); const auto& info1 = vertex_buffers[0]; ASSERT_TRUE(info1.buffer != nullptr); - EXPECT_EQ(0, info1.location); + EXPECT_EQ(0u, info1.location); EXPECT_EQ(InputRate::kVertex, info1.input_rate); const auto& info2 = vertex_buffers[1]; ASSERT_TRUE(info2.buffer != nullptr); - EXPECT_EQ(1, info2.location); + EXPECT_EQ(1u, info2.location); EXPECT_EQ(InputRate::kVertex, info2.input_rate); } @@ -871,16 +872,16 @@ END)"; const auto* pipeline = pipelines[0].get(); const auto& vertex_buffers = pipeline->GetVertexBuffers(); - ASSERT_EQ(2, vertex_buffers.size()); + ASSERT_EQ(2u, vertex_buffers.size()); const auto& info1 = vertex_buffers[0]; ASSERT_TRUE(info1.buffer != nullptr); - EXPECT_EQ(0, info1.location); + EXPECT_EQ(0u, info1.location); EXPECT_EQ(InputRate::kVertex, info1.input_rate); const auto& info2 = vertex_buffers[1]; ASSERT_TRUE(info2.buffer != nullptr); - EXPECT_EQ(1, info2.location); + EXPECT_EQ(1u, info2.location); EXPECT_EQ(InputRate::kInstance, info2.input_rate); } @@ -1312,9 +1313,9 @@ END)"; const auto* pipeline = pipelines[0].get(); const auto& buf = pipeline->GetPushConstantBuffer(); ASSERT_TRUE(buf.buffer != nullptr); - EXPECT_EQ(20, buf.buffer->ElementCount()); - EXPECT_EQ(20, buf.buffer->ValueCount()); - EXPECT_EQ(20 * sizeof(float), buf.buffer->GetSizeInBytes()); + EXPECT_EQ(20u, buf.buffer->ElementCount()); + EXPECT_EQ(20u, buf.buffer->ValueCount()); + EXPECT_EQ(20u * sizeof(float), buf.buffer->GetSizeInBytes()); } TEST_F(AmberScriptParserTest, BindPushConstantsExtraParams) { diff --git a/src/amberscript/parser_buffer_test.cc b/src/amberscript/parser_buffer_test.cc index b6cbf43..aeac2cb 100644 --- a/src/amberscript/parser_buffer_test.cc +++ b/src/amberscript/parser_buffer_test.cc @@ -662,7 +662,7 @@ TEST_F(AmberScriptParserTest, BufferFormat) { ASSERT_EQ(4U, segs.size()); for (size_t i = 0; i < 4; ++i) { - EXPECT_EQ(segs[i].GetNumBits(), 32); + EXPECT_EQ(segs[i].GetNumBits(), 32u); EXPECT_EQ(segs[i].GetFormatMode(), FormatMode::kSInt); EXPECT_EQ(segs[i].GetName(), static_cast(i)); } @@ -950,12 +950,12 @@ END)"; const auto* data = buffer->GetValues(); EXPECT_FLOAT_EQ(1.f, *reinterpret_cast(data + 0)); - EXPECT_EQ(64, + EXPECT_EQ(64u, *reinterpret_cast(data + 4 /* sizeof(float) */)); - EXPECT_EQ(128, + EXPECT_EQ(128u, *reinterpret_cast(data + 16 /* 8 round -> 16 */)); - EXPECT_EQ(220, *reinterpret_cast( - data + 20 /* 8 round -> 16 + 4 */)); + EXPECT_EQ(220u, *reinterpret_cast( + data + 20 /* 8 round -> 16 + 4 */)); } TEST_F(AmberScriptParserTest, BufferWithStructStd430) { @@ -998,9 +998,9 @@ END)"; const auto* data = buffer->GetValues(); EXPECT_FLOAT_EQ(1.f, *reinterpret_cast(data + 0)); - EXPECT_EQ(64, *reinterpret_cast(data + 4)); - EXPECT_EQ(128, *reinterpret_cast(data + 8)); - EXPECT_EQ(220, *reinterpret_cast(data + 12)); + EXPECT_EQ(64u, *reinterpret_cast(data + 4)); + EXPECT_EQ(128u, *reinterpret_cast(data + 8)); + EXPECT_EQ(220u, *reinterpret_cast(data + 12)); } TEST_F(AmberScriptParserTest, BufferWithStructAndPaddingStd430) { @@ -1043,9 +1043,9 @@ END)"; const auto* data = buffer->GetValues(); EXPECT_FLOAT_EQ(1.f, *reinterpret_cast(data + 8)); - EXPECT_EQ(64, *reinterpret_cast(data + 16)); - EXPECT_EQ(128, *reinterpret_cast(data + 28)); - EXPECT_EQ(220, *reinterpret_cast(data + 36)); + EXPECT_EQ(64u, *reinterpret_cast(data + 16)); + EXPECT_EQ(128u, *reinterpret_cast(data + 28)); + EXPECT_EQ(220u, *reinterpret_cast(data + 36)); } TEST_F(AmberScriptParserTest, BufferWithStructPartialInitialization) { @@ -1101,9 +1101,9 @@ END)"; const auto* data = buffer->GetValues(); EXPECT_FLOAT_EQ(1.f, *reinterpret_cast(data + 0)); - EXPECT_FLOAT_EQ(64, *reinterpret_cast(data + 16)); - EXPECT_FLOAT_EQ(128, *reinterpret_cast(data + 20)); - EXPECT_FLOAT_EQ(220, *reinterpret_cast(data + 24)); + EXPECT_FLOAT_EQ(64u, *reinterpret_cast(data + 16)); + EXPECT_FLOAT_EQ(128u, *reinterpret_cast(data + 20)); + EXPECT_FLOAT_EQ(220u, *reinterpret_cast(data + 24)); } TEST_F(AmberScriptParserTest, InvalidBufferWidth) { @@ -1178,9 +1178,9 @@ BUFFER buf DATA_TYPE vec4 WIDTH 2 HEIGHT 3 EXPECT_EQ("buf", buffers[0]->GetName()); auto* buffer = buffers[0].get(); - EXPECT_EQ(2, buffer->GetWidth()); - EXPECT_EQ(3, buffer->GetHeight()); - EXPECT_EQ(6, buffer->ElementCount()); + EXPECT_EQ(2u, buffer->GetWidth()); + EXPECT_EQ(3u, buffer->GetHeight()); + EXPECT_EQ(6u, buffer->ElementCount()); } TEST_F(AmberScriptParserTest, BufferMipLevels) { diff --git a/src/amberscript/parser_clear_stencil_test.cc b/src/amberscript/parser_clear_stencil_test.cc index 2e8cbb2..eed7f14 100644 --- a/src/amberscript/parser_clear_stencil_test.cc +++ b/src/amberscript/parser_clear_stencil_test.cc @@ -47,7 +47,7 @@ CLEAR_STENCIL my_pipeline 15)"; ASSERT_TRUE(cmd->IsClearStencil()); auto* clr = cmd->AsClearStencil(); - EXPECT_EQ(15, clr->GetValue()); + EXPECT_EQ(15u, clr->GetValue()); } TEST_F(AmberScriptParserTest, ClearStencilWithComputePipeline) { diff --git a/src/amberscript/parser_expect_test.cc b/src/amberscript/parser_expect_test.cc index fccd491..125e38b 100644 --- a/src/amberscript/parser_expect_test.cc +++ b/src/amberscript/parser_expect_test.cc @@ -656,7 +656,7 @@ EXPECT orig_buf IDX 5 EQ 11)"; EXPECT_EQ(5U, probe->GetOffset()); EXPECT_TRUE(probe->GetFormat()->IsInt32()); ASSERT_EQ(1U, probe->GetValues().size()); - EXPECT_EQ(11U, probe->GetValues()[0].AsInt32()); + EXPECT_EQ(11, probe->GetValues()[0].AsInt32()); } TEST_F(AmberScriptParserTest, ExpectEQStruct) { @@ -874,7 +874,7 @@ EXPECT orig_buf IDX 5 TOLERANCE 1 EQ 11)"; EXPECT_EQ(5U, probe->GetOffset()); EXPECT_TRUE(probe->GetFormat()->IsInt32()); ASSERT_EQ(1U, probe->GetValues().size()); - EXPECT_EQ(11U, probe->GetValues()[0].AsInt32()); + EXPECT_EQ(11, probe->GetValues()[0].AsInt32()); EXPECT_TRUE(probe->HasTolerances()); auto& tolerances = probe->GetTolerances(); @@ -904,7 +904,7 @@ EXPECT orig_buf IDX 5 TOLERANCE 1% EQ 11)"; EXPECT_EQ(5U, probe->GetOffset()); EXPECT_TRUE(probe->GetFormat()->IsInt32()); ASSERT_EQ(1U, probe->GetValues().size()); - EXPECT_EQ(11U, probe->GetValues()[0].AsInt32()); + EXPECT_EQ(11, probe->GetValues()[0].AsInt32()); EXPECT_TRUE(probe->HasTolerances()); auto& tolerances = probe->GetTolerances(); @@ -934,7 +934,7 @@ EXPECT orig_buf IDX 5 TOLERANCE 1% .2 3.7% 4 EQ 11)"; EXPECT_EQ(5U, probe->GetOffset()); EXPECT_TRUE(probe->GetFormat()->IsInt32()); ASSERT_EQ(1U, probe->GetValues().size()); - EXPECT_EQ(11U, probe->GetValues()[0].AsInt32()); + EXPECT_EQ(11, probe->GetValues()[0].AsInt32()); EXPECT_TRUE(probe->HasTolerances()); auto& tolerances = probe->GetTolerances(); diff --git a/src/amberscript/parser_framebuffer_test.cc b/src/amberscript/parser_framebuffer_test.cc index 27dc0ce..f0cf96f 100644 --- a/src/amberscript/parser_framebuffer_test.cc +++ b/src/amberscript/parser_framebuffer_test.cc @@ -41,8 +41,8 @@ END ASSERT_EQ(1U, pipelines.size()); const auto* pipeline = pipelines[0].get(); - EXPECT_EQ(250, pipeline->GetFramebufferWidth()); - EXPECT_EQ(250, pipeline->GetFramebufferHeight()); + EXPECT_EQ(250u, pipeline->GetFramebufferWidth()); + EXPECT_EQ(250u, pipeline->GetFramebufferHeight()); } TEST_F(AmberScriptParserTest, FramebufferSize) { @@ -67,8 +67,8 @@ END ASSERT_EQ(1U, pipelines.size()); const auto* pipeline = pipelines[0].get(); - EXPECT_EQ(256, pipeline->GetFramebufferWidth()); - EXPECT_EQ(246, pipeline->GetFramebufferHeight()); + EXPECT_EQ(256u, pipeline->GetFramebufferWidth()); + EXPECT_EQ(246u, pipeline->GetFramebufferHeight()); } TEST_F(AmberScriptParserTest, FramebufferSizeMissingSize) { diff --git a/src/amberscript/parser_image_test.cc b/src/amberscript/parser_image_test.cc index bbd98fb..bfa3fb6 100644 --- a/src/amberscript/parser_image_test.cc +++ b/src/amberscript/parser_image_test.cc @@ -214,10 +214,10 @@ IMAGE image DATA_TYPE uint32 DIM_1D WIDTH 4 auto* buffer = buffers[0].get(); EXPECT_TRUE(buffer->GetFormat()->IsUint32()); EXPECT_EQ(ImageDimension::k1D, buffer->GetImageDimension()); - EXPECT_EQ(4, buffer->GetWidth()); - EXPECT_EQ(1, buffer->GetHeight()); - EXPECT_EQ(1, buffer->GetDepth()); - EXPECT_EQ(4, buffer->ElementCount()); + EXPECT_EQ(4u, buffer->GetWidth()); + EXPECT_EQ(1u, buffer->GetHeight()); + EXPECT_EQ(1u, buffer->GetDepth()); + EXPECT_EQ(4u, buffer->ElementCount()); } TEST_F(AmberScriptParserTest, Image2D) { @@ -238,10 +238,10 @@ IMAGE image DATA_TYPE uint32 DIM_2D WIDTH 3 HEIGHT 4 auto* buffer = buffers[0].get(); EXPECT_TRUE(buffer->GetFormat()->IsUint32()); EXPECT_EQ(ImageDimension::k2D, buffer->GetImageDimension()); - EXPECT_EQ(3, buffer->GetWidth()); - EXPECT_EQ(4, buffer->GetHeight()); - EXPECT_EQ(1, buffer->GetDepth()); - EXPECT_EQ(12, buffer->ElementCount()); + EXPECT_EQ(3u, buffer->GetWidth()); + EXPECT_EQ(4u, buffer->GetHeight()); + EXPECT_EQ(1u, buffer->GetDepth()); + EXPECT_EQ(12u, buffer->ElementCount()); } TEST_F(AmberScriptParserTest, Image2DMultiSample) { @@ -260,7 +260,7 @@ IMAGE image DATA_TYPE uint32 DIM_2D WIDTH 3 HEIGHT 4 SAMPLES 4 EXPECT_EQ("image", buffers[0]->GetName()); auto* buffer = buffers[0].get(); - EXPECT_EQ(4, buffer->GetSamples()); + EXPECT_EQ(4u, buffer->GetSamples()); } TEST_F(AmberScriptParserTest, Image2DInvalidSampleValue) { @@ -303,10 +303,10 @@ IMAGE image DATA_TYPE uint32 DIM_3D WIDTH 3 HEIGHT 4 DEPTH 5 auto* buffer = buffers[0].get(); EXPECT_TRUE(buffer->GetFormat()->IsUint32()); EXPECT_EQ(ImageDimension::k3D, buffer->GetImageDimension()); - EXPECT_EQ(3, buffer->GetWidth()); - EXPECT_EQ(4, buffer->GetHeight()); - EXPECT_EQ(5, buffer->GetDepth()); - EXPECT_EQ(60, buffer->ElementCount()); + EXPECT_EQ(3u, buffer->GetWidth()); + EXPECT_EQ(4u, buffer->GetHeight()); + EXPECT_EQ(5u, buffer->GetDepth()); + EXPECT_EQ(60u, buffer->ElementCount()); } } // namespace amberscript diff --git a/src/amberscript/parser_pipeline_test.cc b/src/amberscript/parser_pipeline_test.cc index 197f1a1..2b56e2e 100644 --- a/src/amberscript/parser_pipeline_test.cc +++ b/src/amberscript/parser_pipeline_test.cc @@ -198,21 +198,21 @@ END)"; Buffer* buffer1 = buf1.buffer; EXPECT_EQ(FormatType::kB8G8R8A8_UNORM, buffer1->GetFormat()->GetFormatType()); - EXPECT_EQ(0, buf1.location); - EXPECT_EQ(250 * 250, buffer1->ElementCount()); - EXPECT_EQ(250 * 250 * 4, buffer1->ValueCount()); - EXPECT_EQ(250 * 250 * 4 * sizeof(uint8_t), buffer1->GetSizeInBytes()); + EXPECT_EQ(0u, buf1.location); + EXPECT_EQ(250u * 250u, buffer1->ElementCount()); + EXPECT_EQ(250u * 250u * 4u, buffer1->ValueCount()); + EXPECT_EQ(250u * 250u * 4u * sizeof(uint8_t), buffer1->GetSizeInBytes()); ASSERT_EQ(1U, pipelines[1]->GetColorAttachments().size()); const auto& buf2 = pipelines[1]->GetColorAttachments()[0]; ASSERT_TRUE(buf2.buffer != nullptr); ASSERT_EQ(buffer1, buf2.buffer); - EXPECT_EQ(0, buf2.location); + EXPECT_EQ(0u, buf2.location); EXPECT_EQ(FormatType::kB8G8R8A8_UNORM, buf2.buffer->GetFormat()->GetFormatType()); - EXPECT_EQ(250 * 250, buf2.buffer->ElementCount()); - EXPECT_EQ(250 * 250 * 4, buf2.buffer->ValueCount()); - EXPECT_EQ(250 * 250 * 4 * sizeof(uint8_t), buf2.buffer->GetSizeInBytes()); + EXPECT_EQ(250u * 250u, buf2.buffer->ElementCount()); + EXPECT_EQ(250u * 250u * 4u, buf2.buffer->ValueCount()); + EXPECT_EQ(250u * 250u * 4u * sizeof(uint8_t), buf2.buffer->GetSizeInBytes()); } TEST_F(AmberScriptParserTest, PipelineDefaultColorBufferMismatchSize) { @@ -367,8 +367,8 @@ END auto buffers1 = pipeline1->GetBuffers(); ASSERT_EQ(1U, buffers1.size()); EXPECT_EQ("buf1", buffers1[0].buffer->GetName()); - EXPECT_EQ(1, buffers1[0].descriptor_set); - EXPECT_EQ(3, buffers1[0].binding); + EXPECT_EQ(1u, buffers1[0].descriptor_set); + EXPECT_EQ(3u, buffers1[0].binding); auto shaders1 = pipeline1->GetShaders(); ASSERT_EQ(2U, shaders1.size()); @@ -381,8 +381,8 @@ END auto buffers2 = pipeline2->GetBuffers(); ASSERT_EQ(1U, buffers2.size()); EXPECT_EQ("buf2", buffers2[0].buffer->GetName()); - EXPECT_EQ(1, buffers2[0].descriptor_set); - EXPECT_EQ(3, buffers2[0].binding); + EXPECT_EQ(1u, buffers2[0].descriptor_set); + EXPECT_EQ(3u, buffers2[0].binding); auto shaders2 = pipeline2->GetShaders(); ASSERT_EQ(2U, shaders2.size()); @@ -530,15 +530,15 @@ END const auto& s1 = p1->GetShaders(); ASSERT_EQ(1U, s1.size()); - EXPECT_EQ(1, s1[0].GetSpecialization().size()); - EXPECT_EQ(4, s1[0].GetSpecialization().at(3)); + EXPECT_EQ(1u, s1[0].GetSpecialization().size()); + EXPECT_EQ(4u, s1[0].GetSpecialization().at(3)); const auto* p2 = pipelines[1].get(); const auto& s2 = p2->GetShaders(); ASSERT_EQ(1U, s2.size()); - EXPECT_EQ(1, s2[0].GetSpecialization().size()); - EXPECT_EQ(4, s2[0].GetSpecialization().at(3)); + EXPECT_EQ(1u, s2[0].GetSpecialization().size()); + EXPECT_EQ(4u, s2[0].GetSpecialization().at(3)); } } // namespace amberscript diff --git a/src/amberscript/parser_run_test.cc b/src/amberscript/parser_run_test.cc index 2060c5f..0f6b23f 100644 --- a/src/amberscript/parser_run_test.cc +++ b/src/amberscript/parser_run_test.cc @@ -517,8 +517,8 @@ RUN my_pipeline DRAW_GRID POS 2 4 SIZE 10 20 CELLS 4 5)"; EXPECT_FLOAT_EQ(4.f, cmd->AsDrawGrid()->GetY()); EXPECT_FLOAT_EQ(10.f, cmd->AsDrawGrid()->GetWidth()); EXPECT_FLOAT_EQ(20.f, cmd->AsDrawGrid()->GetHeight()); - EXPECT_EQ(4, cmd->AsDrawGrid()->GetColumns()); - EXPECT_EQ(5, cmd->AsDrawGrid()->GetRows()); + EXPECT_EQ(4u, cmd->AsDrawGrid()->GetColumns()); + EXPECT_EQ(5u, cmd->AsDrawGrid()->GetRows()); } TEST_F(AmberScriptParserTest, RunDrawGridWithComputePipelineInvalid) { diff --git a/src/amberscript/parser_stencil_test.cc b/src/amberscript/parser_stencil_test.cc index f4492da..194761f 100644 --- a/src/amberscript/parser_stencil_test.cc +++ b/src/amberscript/parser_stencil_test.cc @@ -84,12 +84,12 @@ END)"; ASSERT_EQ(CompareOp::kGreater, pipeline->GetPipelineData()->GetBackCompareOp()); - ASSERT_EQ(1, pipeline->GetPipelineData()->GetFrontCompareMask()); - ASSERT_EQ(4, pipeline->GetPipelineData()->GetBackCompareMask()); - ASSERT_EQ(2, pipeline->GetPipelineData()->GetFrontWriteMask()); - ASSERT_EQ(5, pipeline->GetPipelineData()->GetBackWriteMask()); - ASSERT_EQ(3, pipeline->GetPipelineData()->GetFrontReference()); - ASSERT_EQ(6, pipeline->GetPipelineData()->GetBackReference()); + ASSERT_EQ(1u, pipeline->GetPipelineData()->GetFrontCompareMask()); + ASSERT_EQ(4u, pipeline->GetPipelineData()->GetBackCompareMask()); + ASSERT_EQ(2u, pipeline->GetPipelineData()->GetFrontWriteMask()); + ASSERT_EQ(5u, pipeline->GetPipelineData()->GetBackWriteMask()); + ASSERT_EQ(3u, pipeline->GetPipelineData()->GetFrontReference()); + ASSERT_EQ(6u, pipeline->GetPipelineData()->GetBackReference()); } TEST_F(AmberScriptParserTest, StencilMissingFace) { diff --git a/src/buffer_test.cc b/src/buffer_test.cc index 6e1c121..1868b95 100644 --- a/src/buffer_test.cc +++ b/src/buffer_test.cc @@ -14,9 +14,9 @@ #include "src/buffer.h" +#include #include -#include #include "gtest/gtest.h" #include "src/float16_helper.h" #include "src/type_parser.h" @@ -40,9 +40,9 @@ TEST_F(BufferTest, Size) { Buffer b; b.SetFormat(&fmt); b.SetElementCount(10); - EXPECT_EQ(10, b.ElementCount()); - EXPECT_EQ(10, b.ValueCount()); - EXPECT_EQ(10 * sizeof(int16_t), b.GetSizeInBytes()); + EXPECT_EQ(10u, b.ElementCount()); + EXPECT_EQ(10u, b.ValueCount()); + EXPECT_EQ(10u * sizeof(int16_t), b.GetSizeInBytes()); } TEST_F(BufferTest, SizeFromData) { @@ -57,9 +57,9 @@ TEST_F(BufferTest, SizeFromData) { b.SetFormat(&fmt); b.SetData(std::move(values)); - EXPECT_EQ(5, b.ElementCount()); - EXPECT_EQ(5, b.ValueCount()); - EXPECT_EQ(5 * sizeof(float), b.GetSizeInBytes()); + EXPECT_EQ(5u, b.ElementCount()); + EXPECT_EQ(5u, b.ValueCount()); + EXPECT_EQ(5u * sizeof(float), b.GetSizeInBytes()); } TEST_F(BufferTest, SizeFromDataDoesNotOverrideSize) { @@ -75,9 +75,9 @@ TEST_F(BufferTest, SizeFromDataDoesNotOverrideSize) { b.SetElementCount(20); b.SetData(std::move(values)); - EXPECT_EQ(20, b.ElementCount()); - EXPECT_EQ(20, b.ValueCount()); - EXPECT_EQ(20 * sizeof(float), b.GetSizeInBytes()); + EXPECT_EQ(20u, b.ElementCount()); + EXPECT_EQ(20u, b.ValueCount()); + EXPECT_EQ(20u * sizeof(float), b.GetSizeInBytes()); } TEST_F(BufferTest, SizeMatrixStd430) { @@ -90,9 +90,9 @@ TEST_F(BufferTest, SizeMatrixStd430) { b.SetFormat(&fmt); b.SetElementCount(10); - EXPECT_EQ(10, b.ElementCount()); - EXPECT_EQ(60, b.ValueCount()); - EXPECT_EQ(60 * sizeof(int16_t), b.GetSizeInBytes()); + EXPECT_EQ(10u, b.ElementCount()); + EXPECT_EQ(60u, b.ValueCount()); + EXPECT_EQ(60u * sizeof(int16_t), b.GetSizeInBytes()); } TEST_F(BufferTest, SizeMatrixStd140) { @@ -106,9 +106,9 @@ TEST_F(BufferTest, SizeMatrixStd140) { b.SetFormat(&fmt); b.SetElementCount(10); - EXPECT_EQ(10, b.ElementCount()); - EXPECT_EQ(10 * 2 * 3, b.ValueCount()); - EXPECT_EQ(120 * sizeof(int16_t), b.GetSizeInBytes()); + EXPECT_EQ(10u, b.ElementCount()); + EXPECT_EQ(10u * 2u * 3u, b.ValueCount()); + EXPECT_EQ(120u * sizeof(int16_t), b.GetSizeInBytes()); } TEST_F(BufferTest, SizeMatrixPaddedStd430) { @@ -145,7 +145,7 @@ TEST_F(BufferTest, GetHistogramForChannelGradient) { std::vector bins = b.GetHistogramForChannel(2, 256); for (uint32_t i = 0; i < values.size(); i += 4) - EXPECT_EQ(1, bins[i / 4 * 25]); + EXPECT_EQ(1u, bins[i / 4 * 25]); } // Creates 10 RGBA pixel values, with all channels being 0, and checks that all @@ -166,7 +166,7 @@ TEST_F(BufferTest, GetHistogramForChannelAllBlack) { for (uint8_t i = 0; i < 4; i++) { std::vector bins = b.GetHistogramForChannel(i, 256); for (uint32_t y = 0; y < values.size(); y++) - EXPECT_EQ(10, bins[0]); + EXPECT_EQ(10u, bins[0]); } } @@ -189,7 +189,7 @@ TEST_F(BufferTest, GetHistogramForChannelAllWhite) { for (uint8_t i = 0; i < 4; i++) { std::vector bins = b.GetHistogramForChannel(i, 256); for (uint32_t y = 0; y < values.size(); y++) - EXPECT_EQ(10, bins[255]); + EXPECT_EQ(10u, bins[255]); } } @@ -309,9 +309,9 @@ TEST_F(BufferTest, SetFloat16) { b.SetFormat(&fmt); b.SetData(std::move(values)); - EXPECT_EQ(2, b.ElementCount()); - EXPECT_EQ(2, b.ValueCount()); - EXPECT_EQ(4, b.GetSizeInBytes()); + EXPECT_EQ(2u, b.ElementCount()); + EXPECT_EQ(2u, b.ValueCount()); + EXPECT_EQ(4u, b.GetSizeInBytes()); auto v = b.GetValues(); EXPECT_EQ(float16::FloatToHexFloat16(2.8f), v[0]); diff --git a/src/descriptor_set_and_binding_parser_test.cc b/src/descriptor_set_and_binding_parser_test.cc index ce13f10..b5b9c54 100644 --- a/src/descriptor_set_and_binding_parser_test.cc +++ b/src/descriptor_set_and_binding_parser_test.cc @@ -26,8 +26,8 @@ TEST_F(DescriptorSetAndBindingParserTest, CommaAndBinding) { ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_FALSE(parser.HasPipelineName()); - EXPECT_EQ(0, parser.GetDescriptorSet()); - EXPECT_EQ(1234, parser.GetBinding()); + EXPECT_EQ(0u, parser.GetDescriptorSet()); + EXPECT_EQ(1234u, parser.GetBinding()); } TEST_F(DescriptorSetAndBindingParserTest, Binding) { @@ -35,8 +35,8 @@ TEST_F(DescriptorSetAndBindingParserTest, Binding) { Result r = parser.Parse("1234"); ASSERT_TRUE(r.IsSuccess()) << r.Error(); - EXPECT_EQ(0, parser.GetDescriptorSet()); - EXPECT_EQ(1234, parser.GetBinding()); + EXPECT_EQ(0u, parser.GetDescriptorSet()); + EXPECT_EQ(1234u, parser.GetBinding()); } TEST_F(DescriptorSetAndBindingParserTest, DescSetAndBinding) { @@ -44,8 +44,8 @@ TEST_F(DescriptorSetAndBindingParserTest, DescSetAndBinding) { Result r = parser.Parse("1234:5678"); ASSERT_TRUE(r.IsSuccess()) << r.Error(); - EXPECT_EQ(1234, parser.GetDescriptorSet()); - EXPECT_EQ(5678, parser.GetBinding()); + EXPECT_EQ(1234u, parser.GetDescriptorSet()); + EXPECT_EQ(5678u, parser.GetBinding()); } TEST_F(DescriptorSetAndBindingParserTest, EmptyBufferId) { @@ -115,8 +115,8 @@ TEST_F(DescriptorSetAndBindingParserTest, WithPipelineName) { EXPECT_TRUE(parser.HasPipelineName()); EXPECT_EQ("pipeline1", parser.PipelineName()); - EXPECT_EQ(123, parser.GetDescriptorSet()); - EXPECT_EQ(234, parser.GetBinding()); + EXPECT_EQ(123u, parser.GetDescriptorSet()); + EXPECT_EQ(234u, parser.GetBinding()); } } // namespace amber diff --git a/src/float16_helper_test.cc b/src/float16_helper_test.cc index 5fa8c33..99ea295 100644 --- a/src/float16_helper_test.cc +++ b/src/float16_helper_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "src/float16_helper.h" + #include "gtest/gtest.h" namespace amber { diff --git a/src/format_test.cc b/src/format_test.cc index 341faac..f454297 100644 --- a/src/format_test.cc +++ b/src/format_test.cc @@ -263,13 +263,13 @@ TEST_F(FormatTest, SegmentPackedList_Std430) { auto type = parser.Parse("A8B8G8R8_SINT_PACK32"); Format fmt(type.get()); - EXPECT_EQ(4, fmt.SizeInBytes()); + EXPECT_EQ(4u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(1U, segs.size()); // Always packs into a unsigned ... EXPECT_EQ(FormatMode::kUInt, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); } TEST_F(FormatTest, SegmentListR32G32_Std140) { @@ -278,14 +278,14 @@ TEST_F(FormatTest, SegmentListR32G32_Std140) { Format fmt(type.get()); fmt.SetLayout(Format::Layout::kStd140); - EXPECT_EQ(8, fmt.SizeInBytes()); + EXPECT_EQ(8u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(2U, segs.size()); EXPECT_EQ(FormatMode::kUInt, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); EXPECT_EQ(FormatMode::kUInt, segs[1].GetFormatMode()); - EXPECT_EQ(4, segs[1].SizeInBytes()); + EXPECT_EQ(4u, segs[1].SizeInBytes()); } TEST_F(FormatTest, SegmentListR32G32B32_Std140) { @@ -294,18 +294,18 @@ TEST_F(FormatTest, SegmentListR32G32B32_Std140) { Format fmt(type.get()); fmt.SetLayout(Format::Layout::kStd140); - EXPECT_EQ(16, fmt.SizeInBytes()); + EXPECT_EQ(16u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(4U, segs.size()); EXPECT_EQ(FormatMode::kUInt, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); EXPECT_EQ(FormatMode::kUInt, segs[1].GetFormatMode()); - EXPECT_EQ(4, segs[1].SizeInBytes()); + EXPECT_EQ(4u, segs[1].SizeInBytes()); EXPECT_EQ(FormatMode::kUInt, segs[2].GetFormatMode()); - EXPECT_EQ(4, segs[2].SizeInBytes()); + EXPECT_EQ(4u, segs[2].SizeInBytes()); EXPECT_TRUE(segs[3].IsPadding()); - EXPECT_EQ(4, segs[3].SizeInBytes()); + EXPECT_EQ(4u, segs[3].SizeInBytes()); } TEST_F(FormatTest, SegmentListR32G32B32_Std430) { @@ -314,18 +314,18 @@ TEST_F(FormatTest, SegmentListR32G32B32_Std430) { Format fmt(type.get()); fmt.SetLayout(Format::Format::Layout::kStd430); - EXPECT_EQ(16, fmt.SizeInBytes()); + EXPECT_EQ(16u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(4U, segs.size()); EXPECT_EQ(FormatMode::kUInt, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); EXPECT_EQ(FormatMode::kUInt, segs[1].GetFormatMode()); - EXPECT_EQ(4, segs[1].SizeInBytes()); + EXPECT_EQ(4u, segs[1].SizeInBytes()); EXPECT_EQ(FormatMode::kUInt, segs[2].GetFormatMode()); - EXPECT_EQ(4, segs[2].SizeInBytes()); + EXPECT_EQ(4u, segs[2].SizeInBytes()); EXPECT_TRUE(segs[3].IsPadding()); - EXPECT_EQ(4, segs[3].SizeInBytes()); + EXPECT_EQ(4u, segs[3].SizeInBytes()); } TEST_F(FormatTest, SegmentMat2x2_Std140) { @@ -335,23 +335,23 @@ TEST_F(FormatTest, SegmentMat2x2_Std140) { Format fmt(type.get()); fmt.SetLayout(Format::Format::Layout::kStd140); - EXPECT_EQ(32, fmt.SizeInBytes()); + EXPECT_EQ(32u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(6U, segs.size()); EXPECT_EQ(FormatMode::kSFloat, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[1].GetFormatMode()); - EXPECT_EQ(4, segs[1].SizeInBytes()); + EXPECT_EQ(4u, segs[1].SizeInBytes()); EXPECT_TRUE(segs[2].IsPadding()); - EXPECT_EQ(8, segs[2].SizeInBytes()); + EXPECT_EQ(8u, segs[2].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[3].GetFormatMode()); - EXPECT_EQ(4, segs[3].SizeInBytes()); + EXPECT_EQ(4u, segs[3].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[4].GetFormatMode()); - EXPECT_EQ(4, segs[4].SizeInBytes()); + EXPECT_EQ(4u, segs[4].SizeInBytes()); EXPECT_TRUE(segs[5].IsPadding()); - EXPECT_EQ(8, segs[5].SizeInBytes()); + EXPECT_EQ(8u, segs[5].SizeInBytes()); } TEST_F(FormatTest, SegmentMat2x2_Std430) { @@ -361,19 +361,19 @@ TEST_F(FormatTest, SegmentMat2x2_Std430) { Format fmt(type.get()); fmt.SetLayout(Format::Layout::kStd430); - EXPECT_EQ(16, fmt.SizeInBytes()); + EXPECT_EQ(16u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(4U, segs.size()); EXPECT_EQ(FormatMode::kSFloat, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[1].GetFormatMode()); - EXPECT_EQ(4, segs[1].SizeInBytes()); + EXPECT_EQ(4u, segs[1].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[2].GetFormatMode()); - EXPECT_EQ(4, segs[2].SizeInBytes()); + EXPECT_EQ(4u, segs[2].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[3].GetFormatMode()); - EXPECT_EQ(4, segs[3].SizeInBytes()); + EXPECT_EQ(4u, segs[3].SizeInBytes()); } TEST_F(FormatTest, SegmentMat2x3_Std430) { @@ -383,27 +383,27 @@ TEST_F(FormatTest, SegmentMat2x3_Std430) { Format fmt(type.get()); fmt.SetLayout(Format::Layout::kStd430); - EXPECT_EQ(32, fmt.SizeInBytes()); + EXPECT_EQ(32u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(8U, segs.size()); EXPECT_EQ(FormatMode::kSFloat, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[1].GetFormatMode()); - EXPECT_EQ(4, segs[1].SizeInBytes()); + EXPECT_EQ(4u, segs[1].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[2].GetFormatMode()); - EXPECT_EQ(4, segs[2].SizeInBytes()); + EXPECT_EQ(4u, segs[2].SizeInBytes()); EXPECT_TRUE(segs[3].IsPadding()); - EXPECT_EQ(4, segs[3].SizeInBytes()); + EXPECT_EQ(4u, segs[3].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[4].GetFormatMode()); - EXPECT_EQ(4, segs[4].SizeInBytes()); + EXPECT_EQ(4u, segs[4].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[5].GetFormatMode()); - EXPECT_EQ(4, segs[5].SizeInBytes()); + EXPECT_EQ(4u, segs[5].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[6].GetFormatMode()); - EXPECT_EQ(4, segs[6].SizeInBytes()); + EXPECT_EQ(4u, segs[6].SizeInBytes()); EXPECT_TRUE(segs[7].IsPadding()); - EXPECT_EQ(4, segs[7].SizeInBytes()); + EXPECT_EQ(4u, segs[7].SizeInBytes()); } TEST_F(FormatTest, SegmentRuntimeArray_Std140) { @@ -413,14 +413,14 @@ TEST_F(FormatTest, SegmentRuntimeArray_Std140) { Format fmt(type.get()); fmt.SetLayout(Format::Format::Layout::kStd140); - EXPECT_EQ(16, fmt.SizeInBytes()); + EXPECT_EQ(16u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(2U, segs.size()); EXPECT_EQ(FormatMode::kSFloat, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); EXPECT_TRUE(segs[1].IsPadding()); - EXPECT_EQ(12, segs[1].SizeInBytes()); + EXPECT_EQ(12u, segs[1].SizeInBytes()); } TEST_F(FormatTest, SegmentRuntimeArray_Std430) { @@ -430,12 +430,12 @@ TEST_F(FormatTest, SegmentRuntimeArray_Std430) { Format fmt(type.get()); fmt.SetLayout(Format::Layout::kStd430); - EXPECT_EQ(4, fmt.SizeInBytes()); + EXPECT_EQ(4u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(1U, segs.size()); EXPECT_EQ(FormatMode::kSFloat, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); } // struct { @@ -451,16 +451,16 @@ TEST_F(FormatTest, SegmentStruct_Std140) { Format fmt(s.get()); fmt.SetLayout(Format::Layout::kStd140); - EXPECT_EQ(16, fmt.SizeInBytes()); + EXPECT_EQ(16u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); - ASSERT_EQ(3, segs.size()); + ASSERT_EQ(3u, segs.size()); EXPECT_EQ(FormatMode::kSFloat, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); EXPECT_EQ(FormatMode::kUInt, segs[1].GetFormatMode()); - EXPECT_EQ(4, segs[1].SizeInBytes()); + EXPECT_EQ(4u, segs[1].SizeInBytes()); EXPECT_TRUE(segs[2].IsPadding()); - EXPECT_EQ(8, segs[2].SizeInBytes()); + EXPECT_EQ(8u, segs[2].SizeInBytes()); } TEST_F(FormatTest, SegmentStruct_Std430) { auto s = MakeUnique(); @@ -471,14 +471,14 @@ TEST_F(FormatTest, SegmentStruct_Std430) { Format fmt(s.get()); fmt.SetLayout(Format::Layout::kStd430); - EXPECT_EQ(8, fmt.SizeInBytes()); + EXPECT_EQ(8u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(2U, segs.size()); EXPECT_EQ(FormatMode::kSFloat, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); EXPECT_EQ(FormatMode::kUInt, segs[1].GetFormatMode()); - EXPECT_EQ(4, segs[1].SizeInBytes()); + EXPECT_EQ(4u, segs[1].SizeInBytes()); } // struct STRIDE 20 { @@ -496,16 +496,16 @@ TEST_F(FormatTest, SegmentStructWithStride_Std140) { Format fmt(s.get()); fmt.SetLayout(Format::Layout::kStd140); - EXPECT_EQ(20, fmt.SizeInBytes()); + EXPECT_EQ(20u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(3U, segs.size()); EXPECT_EQ(FormatMode::kSFloat, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); EXPECT_EQ(FormatMode::kUInt, segs[1].GetFormatMode()); - EXPECT_EQ(4, segs[1].SizeInBytes()); + EXPECT_EQ(4u, segs[1].SizeInBytes()); EXPECT_TRUE(segs[2].IsPadding()); - EXPECT_EQ((20 - sizeof(float) - sizeof(uint32_t)), segs[2].SizeInBytes()); + EXPECT_EQ((20u - sizeof(float) - sizeof(uint32_t)), segs[2].SizeInBytes()); } TEST_F(FormatTest, SegmentStructWithStride_Std430) { auto s = MakeUnique(); @@ -517,7 +517,7 @@ TEST_F(FormatTest, SegmentStructWithStride_Std430) { Format fmt(s.get()); fmt.SetLayout(Format::Layout::kStd430); - EXPECT_EQ(20, fmt.SizeInBytes()); + EXPECT_EQ(20u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(3U, segs.size()); @@ -526,7 +526,7 @@ TEST_F(FormatTest, SegmentStructWithStride_Std430) { EXPECT_EQ(FormatMode::kUInt, segs[1].GetFormatMode()); EXPECT_EQ(32U, segs[1].GetNumBits()); EXPECT_TRUE(segs[2].IsPadding()); - EXPECT_EQ((20 - sizeof(float) - sizeof(uint32_t)) * 8, segs[2].GetNumBits()); + EXPECT_EQ((20u - sizeof(float) - sizeof(uint32_t)) * 8, segs[2].GetNumBits()); } // struct { @@ -545,18 +545,18 @@ TEST_F(FormatTest, SegmentStructWithMemberOffset_Std140) { Format fmt(s.get()); fmt.SetLayout(Format::Layout::kStd140); - EXPECT_EQ(16, fmt.SizeInBytes()); + EXPECT_EQ(16u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(4U, segs.size()); EXPECT_TRUE(segs[0].IsPadding()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[1].GetFormatMode()); - EXPECT_EQ(4, segs[1].SizeInBytes()); + EXPECT_EQ(4u, segs[1].SizeInBytes()); EXPECT_EQ(FormatMode::kUInt, segs[2].GetFormatMode()); - EXPECT_EQ(4, segs[2].SizeInBytes()); + EXPECT_EQ(4u, segs[2].SizeInBytes()); EXPECT_TRUE(segs[3].IsPadding()); - EXPECT_EQ(4, segs[3].SizeInBytes()); + EXPECT_EQ(4u, segs[3].SizeInBytes()); } TEST_F(FormatTest, SegmentStructWithMemberOffset_Std430) { auto s = MakeUnique(); @@ -575,11 +575,11 @@ TEST_F(FormatTest, SegmentStructWithMemberOffset_Std430) { const auto& segs = fmt.GetSegments(); ASSERT_EQ(3U, segs.size()); EXPECT_TRUE(segs[0].IsPadding()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[1].GetFormatMode()); - EXPECT_EQ(4, segs[1].SizeInBytes()); + EXPECT_EQ(4u, segs[1].SizeInBytes()); EXPECT_EQ(FormatMode::kUInt, segs[2].GetFormatMode()); - EXPECT_EQ(4, segs[2].SizeInBytes()); + EXPECT_EQ(4u, segs[2].SizeInBytes()); } // struct { @@ -602,20 +602,20 @@ TEST_F(FormatTest, SegmentStructWithStruct_Std140) { Format fmt(s.get()); fmt.SetLayout(Format::Layout::kStd140); - EXPECT_EQ(32, fmt.SizeInBytes()); + EXPECT_EQ(32u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(5U, segs.size()); EXPECT_EQ(FormatMode::kSInt, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[1].GetFormatMode()); - EXPECT_EQ(4, segs[1].SizeInBytes()); + EXPECT_EQ(4u, segs[1].SizeInBytes()); EXPECT_TRUE(segs[2].IsPadding()); - EXPECT_EQ(8, segs[2].SizeInBytes()); + EXPECT_EQ(8u, segs[2].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[3].GetFormatMode()); - EXPECT_EQ(4, segs[3].SizeInBytes()); + EXPECT_EQ(4u, segs[3].SizeInBytes()); EXPECT_TRUE(segs[4].IsPadding()); - EXPECT_EQ(12, segs[4].SizeInBytes()); + EXPECT_EQ(12u, segs[4].SizeInBytes()); } TEST_F(FormatTest, SegmentStructWithStruct_Std430) { auto x = MakeUnique(); @@ -630,16 +630,16 @@ TEST_F(FormatTest, SegmentStructWithStruct_Std430) { Format fmt(s.get()); fmt.SetLayout(Format::Layout::kStd430); - EXPECT_EQ(12, fmt.SizeInBytes()); + EXPECT_EQ(12u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(3U, segs.size()); EXPECT_EQ(FormatMode::kSInt, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[1].GetFormatMode()); - EXPECT_EQ(4, segs[1].SizeInBytes()); + EXPECT_EQ(4u, segs[1].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[2].GetFormatMode()); - EXPECT_EQ(4, segs[2].SizeInBytes()); + EXPECT_EQ(4u, segs[2].SizeInBytes()); } // struct { @@ -660,27 +660,27 @@ TEST_F(FormatTest, SegmentStructWithVec2_Std140) { Format fmt(s.get()); fmt.SetLayout(Format::Layout::kStd140); - EXPECT_EQ(32, fmt.SizeInBytes()); + EXPECT_EQ(32u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(6U, segs.size()); /* w */ EXPECT_EQ(FormatMode::kSInt, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[1].IsPadding()); - EXPECT_EQ(4, segs[1].SizeInBytes()); + EXPECT_EQ(4u, segs[1].SizeInBytes()); /* vec2 */ EXPECT_EQ(FormatMode::kSFloat, segs[2].GetFormatMode()); - EXPECT_EQ(4, segs[2].SizeInBytes()); + EXPECT_EQ(4u, segs[2].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[3].GetFormatMode()); - EXPECT_EQ(4, segs[3].SizeInBytes()); + EXPECT_EQ(4u, segs[3].SizeInBytes()); /* y */ EXPECT_EQ(FormatMode::kSFloat, segs[4].GetFormatMode()); - EXPECT_EQ(4, segs[4].SizeInBytes()); + EXPECT_EQ(4u, segs[4].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[5].IsPadding()); - EXPECT_EQ(12, segs[5].SizeInBytes()); + EXPECT_EQ(12u, segs[5].SizeInBytes()); } TEST_F(FormatTest, SegmentStructWithVec2_Std430) { auto s = MakeUnique(); @@ -695,27 +695,27 @@ TEST_F(FormatTest, SegmentStructWithVec2_Std430) { Format fmt(s.get()); fmt.SetLayout(Format::Layout::kStd430); - EXPECT_EQ(24, fmt.SizeInBytes()); + EXPECT_EQ(24u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(6U, segs.size()); /* w */ EXPECT_EQ(FormatMode::kSInt, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[1].IsPadding()); - EXPECT_EQ(4, segs[1].SizeInBytes()); + EXPECT_EQ(4u, segs[1].SizeInBytes()); /* vec2 */ EXPECT_EQ(FormatMode::kSFloat, segs[2].GetFormatMode()); - EXPECT_EQ(4, segs[2].SizeInBytes()); + EXPECT_EQ(4u, segs[2].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[3].GetFormatMode()); - EXPECT_EQ(4, segs[3].SizeInBytes()); + EXPECT_EQ(4u, segs[3].SizeInBytes()); /* y */ EXPECT_EQ(FormatMode::kSFloat, segs[4].GetFormatMode()); - EXPECT_EQ(4, segs[4].SizeInBytes()); + EXPECT_EQ(4u, segs[4].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[5].IsPadding()); - EXPECT_EQ(4, segs[5].SizeInBytes()); + EXPECT_EQ(4u, segs[5].SizeInBytes()); } // struct { @@ -736,26 +736,26 @@ TEST_F(FormatTest, SegmentStructWithFloatPackedToVec_Std140) { Format fmt(s.get()); fmt.SetLayout(Format::Layout::kStd140); - EXPECT_EQ(32, fmt.SizeInBytes()); + EXPECT_EQ(32u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(6U, segs.size()); /* w */ EXPECT_EQ(FormatMode::kSInt, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[1].IsPadding()); - EXPECT_EQ(12, segs[1].SizeInBytes()); + EXPECT_EQ(12u, segs[1].SizeInBytes()); /* vec2 */ EXPECT_EQ(FormatMode::kSFloat, segs[2].GetFormatMode()); - EXPECT_EQ(4, segs[2].SizeInBytes()); + EXPECT_EQ(4u, segs[2].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[3].GetFormatMode()); - EXPECT_EQ(4, segs[3].SizeInBytes()); + EXPECT_EQ(4u, segs[3].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[4].GetFormatMode()); - EXPECT_EQ(4, segs[4].SizeInBytes()); + EXPECT_EQ(4u, segs[4].SizeInBytes()); /* y */ EXPECT_EQ(FormatMode::kSFloat, segs[5].GetFormatMode()); - EXPECT_EQ(4, segs[5].SizeInBytes()); + EXPECT_EQ(4u, segs[5].SizeInBytes()); } TEST_F(FormatTest, SegmentStructWithFloatPackedToVec_Std430) { auto s = MakeUnique(); @@ -770,26 +770,26 @@ TEST_F(FormatTest, SegmentStructWithFloatPackedToVec_Std430) { Format fmt(s.get()); fmt.SetLayout(Format::Layout::kStd430); - EXPECT_EQ(32, fmt.SizeInBytes()); + EXPECT_EQ(32u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(6U, segs.size()); /* w */ EXPECT_EQ(FormatMode::kSInt, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[1].IsPadding()); - EXPECT_EQ(12, segs[1].SizeInBytes()); + EXPECT_EQ(12u, segs[1].SizeInBytes()); /* vec2 */ EXPECT_EQ(FormatMode::kSFloat, segs[2].GetFormatMode()); - EXPECT_EQ(4, segs[2].SizeInBytes()); + EXPECT_EQ(4u, segs[2].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[3].GetFormatMode()); - EXPECT_EQ(4, segs[3].SizeInBytes()); + EXPECT_EQ(4u, segs[3].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[4].GetFormatMode()); - EXPECT_EQ(4, segs[4].SizeInBytes()); + EXPECT_EQ(4u, segs[4].SizeInBytes()); /* y */ EXPECT_EQ(FormatMode::kSFloat, segs[5].GetFormatMode()); - EXPECT_EQ(4, segs[5].SizeInBytes()); + EXPECT_EQ(4u, segs[5].SizeInBytes()); } // struct { @@ -811,34 +811,34 @@ TEST_F(FormatTest, SegmentStructVec3Vec2_Std140) { Format fmt(s.get()); fmt.SetLayout(Format::Layout::kStd140); - EXPECT_EQ(48, fmt.SizeInBytes()); + EXPECT_EQ(48u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(9U, segs.size()); /* w */ EXPECT_EQ(FormatMode::kSInt, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[1].IsPadding()); - EXPECT_EQ(12, segs[1].SizeInBytes()); + EXPECT_EQ(12u, segs[1].SizeInBytes()); /* vec3 */ EXPECT_EQ(FormatMode::kSFloat, segs[2].GetFormatMode()); - EXPECT_EQ(4, segs[2].SizeInBytes()); + EXPECT_EQ(4u, segs[2].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[3].GetFormatMode()); - EXPECT_EQ(4, segs[3].SizeInBytes()); + EXPECT_EQ(4u, segs[3].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[4].GetFormatMode()); - EXPECT_EQ(4, segs[4].SizeInBytes()); + EXPECT_EQ(4u, segs[4].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[5].IsPadding()); - EXPECT_EQ(4, segs[5].SizeInBytes()); + EXPECT_EQ(4u, segs[5].SizeInBytes()); /* vec2 */ EXPECT_EQ(FormatMode::kSFloat, segs[6].GetFormatMode()); - EXPECT_EQ(4, segs[6].SizeInBytes()); + EXPECT_EQ(4u, segs[6].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[7].GetFormatMode()); - EXPECT_EQ(4, segs[7].SizeInBytes()); + EXPECT_EQ(4u, segs[7].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[8].IsPadding()); - EXPECT_EQ(8, segs[8].SizeInBytes()); + EXPECT_EQ(8u, segs[8].SizeInBytes()); } TEST_F(FormatTest, SegmentStructVec3Vec2_Std430) { auto s = MakeUnique(); @@ -854,34 +854,34 @@ TEST_F(FormatTest, SegmentStructVec3Vec2_Std430) { Format fmt(s.get()); fmt.SetLayout(Format::Layout::kStd430); - EXPECT_EQ(48, fmt.SizeInBytes()); + EXPECT_EQ(48u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(9U, segs.size()); /* w */ EXPECT_EQ(FormatMode::kSInt, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[1].IsPadding()); - EXPECT_EQ(12, segs[1].SizeInBytes()); + EXPECT_EQ(12u, segs[1].SizeInBytes()); /* vec3 */ EXPECT_EQ(FormatMode::kSFloat, segs[2].GetFormatMode()); - EXPECT_EQ(4, segs[2].SizeInBytes()); + EXPECT_EQ(4u, segs[2].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[3].GetFormatMode()); - EXPECT_EQ(4, segs[3].SizeInBytes()); + EXPECT_EQ(4u, segs[3].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[4].GetFormatMode()); - EXPECT_EQ(4, segs[4].SizeInBytes()); + EXPECT_EQ(4u, segs[4].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[5].IsPadding()); - EXPECT_EQ(4, segs[5].SizeInBytes()); + EXPECT_EQ(4u, segs[5].SizeInBytes()); /* vec2 */ EXPECT_EQ(FormatMode::kSFloat, segs[6].GetFormatMode()); - EXPECT_EQ(4, segs[6].SizeInBytes()); + EXPECT_EQ(4u, segs[6].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[7].GetFormatMode()); - EXPECT_EQ(4, segs[7].SizeInBytes()); + EXPECT_EQ(4u, segs[7].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[8].IsPadding()); - EXPECT_EQ(8, segs[8].SizeInBytes()); + EXPECT_EQ(8u, segs[8].SizeInBytes()); } // struct { @@ -903,36 +903,36 @@ TEST_F(FormatTest, SegmentStructMat2x2_Std140) { Format fmt(s.get()); fmt.SetLayout(Format::Layout::kStd140); - EXPECT_EQ(64, fmt.SizeInBytes()); + EXPECT_EQ(64u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(10U, segs.size()); /* w */ EXPECT_EQ(FormatMode::kSInt, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[1].IsPadding()); - EXPECT_EQ(12, segs[1].SizeInBytes()); + EXPECT_EQ(12u, segs[1].SizeInBytes()); /* column 1 */ EXPECT_EQ(FormatMode::kSFloat, segs[2].GetFormatMode()); - EXPECT_EQ(4, segs[2].SizeInBytes()); + EXPECT_EQ(4u, segs[2].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[3].GetFormatMode()); - EXPECT_EQ(4, segs[3].SizeInBytes()); + EXPECT_EQ(4u, segs[3].SizeInBytes()); EXPECT_TRUE(segs[4].IsPadding()); - EXPECT_EQ(8, segs[4].SizeInBytes()); + EXPECT_EQ(8u, segs[4].SizeInBytes()); /* column 2 */ EXPECT_EQ(FormatMode::kSFloat, segs[5].GetFormatMode()); - EXPECT_EQ(4, segs[5].SizeInBytes()); + EXPECT_EQ(4u, segs[5].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[6].GetFormatMode()); - EXPECT_EQ(4, segs[6].SizeInBytes()); + EXPECT_EQ(4u, segs[6].SizeInBytes()); EXPECT_TRUE(segs[7].IsPadding()); - EXPECT_EQ(8, segs[7].SizeInBytes()); + EXPECT_EQ(8u, segs[7].SizeInBytes()); /* y */ EXPECT_EQ(FormatMode::kSFloat, segs[8].GetFormatMode()); - EXPECT_EQ(4, segs[8].SizeInBytes()); + EXPECT_EQ(4u, segs[8].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[9].IsPadding()); - EXPECT_EQ(12, segs[9].SizeInBytes()); + EXPECT_EQ(12u, segs[9].SizeInBytes()); } TEST_F(FormatTest, SegmentStructMat2x2_Std430) { auto s = MakeUnique(); @@ -948,32 +948,32 @@ TEST_F(FormatTest, SegmentStructMat2x2_Std430) { Format fmt(s.get()); fmt.SetLayout(Format::Layout::kStd430); - EXPECT_EQ(32, fmt.SizeInBytes()); + EXPECT_EQ(32u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(8U, segs.size()); /* w */ EXPECT_EQ(FormatMode::kSInt, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[1].IsPadding()); - EXPECT_EQ(4, segs[1].SizeInBytes()); + EXPECT_EQ(4u, segs[1].SizeInBytes()); /* column 1 */ EXPECT_EQ(FormatMode::kSFloat, segs[2].GetFormatMode()); - EXPECT_EQ(4, segs[2].SizeInBytes()); + EXPECT_EQ(4u, segs[2].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[3].GetFormatMode()); - EXPECT_EQ(4, segs[3].SizeInBytes()); + EXPECT_EQ(4u, segs[3].SizeInBytes()); /* column 2 */ EXPECT_EQ(FormatMode::kSFloat, segs[4].GetFormatMode()); - EXPECT_EQ(4, segs[4].SizeInBytes()); + EXPECT_EQ(4u, segs[4].SizeInBytes()); EXPECT_EQ(FormatMode::kSFloat, segs[5].GetFormatMode()); - EXPECT_EQ(4, segs[5].SizeInBytes()); + EXPECT_EQ(4u, segs[5].SizeInBytes()); /* y */ EXPECT_EQ(FormatMode::kSFloat, segs[6].GetFormatMode()); - EXPECT_EQ(4, segs[6].SizeInBytes()); + EXPECT_EQ(4u, segs[6].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[7].IsPadding()); - EXPECT_EQ(4, segs[7].SizeInBytes()); + EXPECT_EQ(4u, segs[7].SizeInBytes()); } // struct { @@ -1000,34 +1000,34 @@ TEST_F(FormatTest, SegmentStructWithStructNoPack_Std140) { Format fmt(s.get()); fmt.SetLayout(Format::Layout::kStd140); - EXPECT_EQ(48, fmt.SizeInBytes()); + EXPECT_EQ(48u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(8U, segs.size()); /* w */ EXPECT_EQ(FormatMode::kSInt, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[1].IsPadding()); - EXPECT_EQ(12, segs[1].SizeInBytes()); + EXPECT_EQ(12u, segs[1].SizeInBytes()); /* a */ EXPECT_EQ(FormatMode::kSInt, segs[2].GetFormatMode()); - EXPECT_EQ(4, segs[2].SizeInBytes()); + EXPECT_EQ(4u, segs[2].SizeInBytes()); /* b */ EXPECT_EQ(FormatMode::kSInt, segs[3].GetFormatMode()); - EXPECT_EQ(4, segs[3].SizeInBytes()); + EXPECT_EQ(4u, segs[3].SizeInBytes()); /* c */ EXPECT_EQ(FormatMode::kSFloat, segs[4].GetFormatMode()); - EXPECT_EQ(4, segs[4].SizeInBytes()); + EXPECT_EQ(4u, segs[4].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[5].IsPadding()); - EXPECT_EQ(4, segs[5].SizeInBytes()); + EXPECT_EQ(4u, segs[5].SizeInBytes()); /* y */ EXPECT_EQ(FormatMode::kSFloat, segs[6].GetFormatMode()); - EXPECT_EQ(4, segs[6].SizeInBytes()); + EXPECT_EQ(4u, segs[6].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[7].IsPadding()); - EXPECT_EQ(12, segs[7].SizeInBytes()); + EXPECT_EQ(12u, segs[7].SizeInBytes()); } TEST_F(FormatTest, SegmentStructWithStructNoPack_Std430) { auto s = MakeUnique(); @@ -1044,25 +1044,25 @@ TEST_F(FormatTest, SegmentStructWithStructNoPack_Std430) { Format fmt(s.get()); fmt.SetLayout(Format::Layout::kStd430); - EXPECT_EQ(20, fmt.SizeInBytes()); + EXPECT_EQ(20u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(5U, segs.size()); /* w */ EXPECT_EQ(FormatMode::kSInt, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); /* a */ EXPECT_EQ(FormatMode::kSInt, segs[1].GetFormatMode()); - EXPECT_EQ(4, segs[1].SizeInBytes()); + EXPECT_EQ(4u, segs[1].SizeInBytes()); /* b */ EXPECT_EQ(FormatMode::kSInt, segs[2].GetFormatMode()); - EXPECT_EQ(4, segs[2].SizeInBytes()); + EXPECT_EQ(4u, segs[2].SizeInBytes()); /* c */ EXPECT_EQ(FormatMode::kSFloat, segs[3].GetFormatMode()); - EXPECT_EQ(4, segs[3].SizeInBytes()); + EXPECT_EQ(4u, segs[3].SizeInBytes()); /* y */ EXPECT_EQ(FormatMode::kSFloat, segs[4].GetFormatMode()); - EXPECT_EQ(4, segs[4].SizeInBytes()); + EXPECT_EQ(4u, segs[4].SizeInBytes()); } // struct { @@ -1092,49 +1092,49 @@ TEST_F(FormatTest, SegmentStructWithStructArray_Std140) { Format fmt(s.get()); fmt.SetLayout(Format::Layout::kStd140); - EXPECT_EQ(96, fmt.SizeInBytes()); + EXPECT_EQ(96u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(13U, segs.size()); /* w */ EXPECT_EQ(FormatMode::kSInt, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[1].IsPadding()); - EXPECT_EQ(12, segs[1].SizeInBytes()); + EXPECT_EQ(12u, segs[1].SizeInBytes()); /* a */ EXPECT_EQ(FormatMode::kSInt, segs[2].GetFormatMode()); - EXPECT_EQ(4, segs[2].SizeInBytes()); + EXPECT_EQ(4u, segs[2].SizeInBytes()); /* b */ EXPECT_EQ(FormatMode::kSInt, segs[3].GetFormatMode()); - EXPECT_EQ(4, segs[3].SizeInBytes()); + EXPECT_EQ(4u, segs[3].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[4].IsPadding()); - EXPECT_EQ(8, segs[4].SizeInBytes()); + EXPECT_EQ(8u, segs[4].SizeInBytes()); /* c[0] */ EXPECT_EQ(FormatMode::kSFloat, segs[5].GetFormatMode()); - EXPECT_EQ(4, segs[5].SizeInBytes()); + EXPECT_EQ(4u, segs[5].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[6].IsPadding()); - EXPECT_EQ(12, segs[6].SizeInBytes()); + EXPECT_EQ(12u, segs[6].SizeInBytes()); /* c[1] */ EXPECT_EQ(FormatMode::kSFloat, segs[7].GetFormatMode()); - EXPECT_EQ(4, segs[7].SizeInBytes()); + EXPECT_EQ(4u, segs[7].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[8].IsPadding()); - EXPECT_EQ(12, segs[8].SizeInBytes()); + EXPECT_EQ(12u, segs[8].SizeInBytes()); /* c[2] */ EXPECT_EQ(FormatMode::kSFloat, segs[9].GetFormatMode()); - EXPECT_EQ(4, segs[9].SizeInBytes()); + EXPECT_EQ(4u, segs[9].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[10].IsPadding()); - EXPECT_EQ(12, segs[10].SizeInBytes()); + EXPECT_EQ(12u, segs[10].SizeInBytes()); /* y */ EXPECT_EQ(FormatMode::kSFloat, segs[11].GetFormatMode()); - EXPECT_EQ(4, segs[11].SizeInBytes()); + EXPECT_EQ(4u, segs[11].SizeInBytes()); /* pad */ EXPECT_TRUE(segs[12].IsPadding()); - EXPECT_EQ(12, segs[12].SizeInBytes()); + EXPECT_EQ(12u, segs[12].SizeInBytes()); } TEST_F(FormatTest, SegmentStructWithStructArray_Std430) { auto s = MakeUnique(); @@ -1153,31 +1153,31 @@ TEST_F(FormatTest, SegmentStructWithStructArray_Std430) { Format fmt(s.get()); fmt.SetLayout(Format::Layout::kStd430); - EXPECT_EQ(28, fmt.SizeInBytes()); + EXPECT_EQ(28u, fmt.SizeInBytes()); const auto& segs = fmt.GetSegments(); ASSERT_EQ(7U, segs.size()); /* w */ EXPECT_EQ(FormatMode::kSInt, segs[0].GetFormatMode()); - EXPECT_EQ(4, segs[0].SizeInBytes()); + EXPECT_EQ(4u, segs[0].SizeInBytes()); /* a */ EXPECT_EQ(FormatMode::kSInt, segs[1].GetFormatMode()); - EXPECT_EQ(4, segs[1].SizeInBytes()); + EXPECT_EQ(4u, segs[1].SizeInBytes()); /* b */ EXPECT_EQ(FormatMode::kSInt, segs[2].GetFormatMode()); - EXPECT_EQ(4, segs[2].SizeInBytes()); + EXPECT_EQ(4u, segs[2].SizeInBytes()); /* c[0] */ EXPECT_EQ(FormatMode::kSFloat, segs[3].GetFormatMode()); - EXPECT_EQ(4, segs[3].SizeInBytes()); + EXPECT_EQ(4u, segs[3].SizeInBytes()); /* c[1] */ EXPECT_EQ(FormatMode::kSFloat, segs[4].GetFormatMode()); - EXPECT_EQ(4, segs[4].SizeInBytes()); + EXPECT_EQ(4u, segs[4].SizeInBytes()); /* c[2] */ EXPECT_EQ(FormatMode::kSFloat, segs[5].GetFormatMode()); - EXPECT_EQ(4, segs[5].SizeInBytes()); + EXPECT_EQ(4u, segs[5].SizeInBytes()); /* y */ EXPECT_EQ(FormatMode::kSFloat, segs[6].GetFormatMode()); - EXPECT_EQ(4, segs[6].SizeInBytes()); + EXPECT_EQ(4u, segs[6].SizeInBytes()); } } // namespace amber diff --git a/src/script_test.cc b/src/script_test.cc index 26fe3f9..c3d602e 100644 --- a/src/script_test.cc +++ b/src/script_test.cc @@ -58,7 +58,7 @@ TEST_F(ScriptTest, GetShaderInfo) { EXPECT_EQ(kShaderFormatGlsl, info[0].format); EXPECT_EQ(kShaderTypeVertex, info[0].type); EXPECT_EQ("This is my shader data", info[0].shader_source); - ASSERT_EQ(2, info[0].optimizations.size()); + ASSERT_EQ(2u, info[0].optimizations.size()); EXPECT_EQ("opt1", info[0].optimizations[0]); EXPECT_EQ("opt2", info[0].optimizations[1]); diff --git a/src/shader_compiler_test.cc b/src/shader_compiler_test.cc index 9bdf5de..db8f43e 100644 --- a/src/shader_compiler_test.cc +++ b/src/shader_compiler_test.cc @@ -22,7 +22,7 @@ #include "src/sampler.h" #include "src/shader_data.h" #if AMBER_ENABLE_SHADERC -#include "shaderc/env.h" +#include "shaderc/shaderc.hpp" #endif namespace amber { @@ -112,7 +112,7 @@ void main() { std::tie(r, binary) = sc.Compile(&pipeline, &shader_info, ShaderMap()); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_FALSE(binary.empty()); - EXPECT_EQ(0x07230203, binary[0]); // Verify SPIR-V header present. + EXPECT_EQ(0x07230203u, binary[0]); // Verify SPIR-V header present. } #endif // AMBER_ENABLE_SHADERC @@ -131,7 +131,7 @@ TEST_F(ShaderCompilerTest, CompilesSpirvAsm) { std::tie(r, binary) = sc.Compile(&pipeline, &shader_info, ShaderMap()); ASSERT_TRUE(r.IsSuccess()); EXPECT_FALSE(binary.empty()); - EXPECT_EQ(0x07230203, binary[0]); // Verify SPIR-V header present. + EXPECT_EQ(0x07230203u, binary[0]); // Verify SPIR-V header present. } TEST_F(ShaderCompilerTest, InvalidSpirvHex) { @@ -241,7 +241,7 @@ TEST_F(ShaderCompilerTest, CompilesSpirvHex) { std::tie(r, binary) = sc.Compile(&pipeline, &shader_info, ShaderMap()); ASSERT_TRUE(r.IsSuccess()); EXPECT_FALSE(binary.empty()); - EXPECT_EQ(0x07230203, binary[0]); // Verify SPIR-V header present. + EXPECT_EQ(0x07230203u, binary[0]); // Verify SPIR-V header present. } TEST_F(ShaderCompilerTest, FailsOnInvalidShader) { @@ -312,7 +312,7 @@ kernel void TestShader(global int* in, global int* out) { std::tie(r, binary) = sc.Compile(&pipeline, &shader_info, ShaderMap()); ASSERT_TRUE(r.IsSuccess()); EXPECT_FALSE(binary.empty()); - EXPECT_EQ(0x07230203, binary[0]); // Verify SPIR-V header present. + EXPECT_EQ(0x07230203u, binary[0]); // Verify SPIR-V header present. } TEST_F(ShaderCompilerTest, ClspvDisallowCaching) { @@ -361,7 +361,7 @@ kernel void TestShader(global int* in, global int* out, int m, int b) { std::tie(r, binary) = sc.Compile(&pipeline, &shader_info1, ShaderMap()); ASSERT_TRUE(r.IsSuccess()); EXPECT_FALSE(binary.empty()); - EXPECT_EQ(0x07230203, binary[0]); // Verify SPIR-V header present. + EXPECT_EQ(0x07230203u, binary[0]); // Verify SPIR-V header present. auto iter = shader_info1.GetDescriptorMap().find("TestShader"); ASSERT_NE(iter, shader_info1.GetDescriptorMap().end()); uint32_t max_binding = 0; @@ -380,7 +380,7 @@ kernel void TestShader(global int* in, global int* out, int m, int b) { std::tie(r, binary) = sc.Compile(&pipeline, &shader_info2, ShaderMap()); ASSERT_TRUE(r.IsSuccess()); EXPECT_FALSE(binary.empty()); - EXPECT_EQ(0x07230203, binary[0]); // Verify SPIR-V header present. + EXPECT_EQ(0x07230203u, binary[0]); // Verify SPIR-V header present. iter = shader_info2.GetDescriptorMap().find("TestShader"); ASSERT_NE(iter, shader_info2.GetDescriptorMap().end()); max_binding = 0; @@ -416,7 +416,7 @@ kernel void TestShader(read_only image2d_t ro_image, write_only image2d_t wo_ima std::tie(r, binary) = sc.Compile(&pipeline, &shader_info1, ShaderMap()); ASSERT_TRUE(r.IsSuccess()); EXPECT_FALSE(binary.empty()); - EXPECT_EQ(0x07230203, binary[0]); // Verify SPIR-V header present. + EXPECT_EQ(0x07230203u, binary[0]); // Verify SPIR-V header present. auto iter = shader_info1.GetDescriptorMap().find("TestShader"); for (const auto& entry : iter->second) { if (entry.binding == 0) { @@ -459,7 +459,7 @@ kernel void foo(read_only image2d_t im, global float4* out) { std::tie(r, binary) = sc.Compile(&pipeline, &shader_info1, ShaderMap()); ASSERT_TRUE(r.IsSuccess()); EXPECT_FALSE(binary.empty()); - EXPECT_EQ(0x07230203, binary[0]); // Verify SPIR-V header present. + EXPECT_EQ(0x07230203u, binary[0]); // Verify SPIR-V header present. bool found_s1 = false; bool found_s2 = false; EXPECT_EQ(0, pipeline.GetSamplers()[0].descriptor_set); diff --git a/src/tokenizer_test.cc b/src/tokenizer_test.cc index 2685d74..b78e57a 100644 --- a/src/tokenizer_test.cc +++ b/src/tokenizer_test.cc @@ -518,13 +518,13 @@ TEST_F(TokenizerTest, Continuations) { ASSERT_TRUE(next != nullptr); ASSERT_TRUE(next->IsInteger()); EXPECT_EQ(1, next->AsInt32()); - EXPECT_EQ(1, t.GetCurrentLine()); + EXPECT_EQ(1u, t.GetCurrentLine()); next = t.NextToken(); ASSERT_TRUE(next != nullptr); ASSERT_TRUE(next->IsInteger()); EXPECT_EQ(2, next->AsInt32()); - EXPECT_EQ(2, t.GetCurrentLine()); + EXPECT_EQ(2u, t.GetCurrentLine()); next = t.NextToken(); ASSERT_TRUE(next != nullptr); @@ -580,7 +580,7 @@ TEST_F(TokenizerTest, ContinuationTokenInMiddleOfLine) { next = t.NextToken(); ASSERT_TRUE(next != nullptr); ASSERT_TRUE(next->IsInteger()); - EXPECT_EQ(2U, next->AsInt32()); + EXPECT_EQ(2u, next->AsInt32()); next = t.NextToken(); ASSERT_TRUE(next != nullptr); diff --git a/src/type_parser_test.cc b/src/type_parser_test.cc index c26c329..0f923ea 100644 --- a/src/type_parser_test.cc +++ b/src/type_parser_test.cc @@ -1208,7 +1208,7 @@ TEST_F(TypeParserTest, Formats) { if (data.component_count < segs.size()) { // Only one padding added - EXPECT_EQ(1, segs.size() - data.component_count); + EXPECT_EQ(1u, segs.size() - data.component_count); EXPECT_TRUE(segs.back().IsPadding()); } } diff --git a/src/type_test.cc b/src/type_test.cc index bc140d4..285ad6f 100644 --- a/src/type_test.cc +++ b/src/type_test.cc @@ -37,7 +37,7 @@ TEST_F(TypeTest, IsArray) { EXPECT_TRUE(i.IsArray()); EXPECT_FALSE(i.IsRuntimeArray()); EXPECT_TRUE(i.IsSizedArray()); - EXPECT_EQ(3, i.ArraySize()); + EXPECT_EQ(3u, i.ArraySize()); } TEST_F(TypeTest, IsStruct) { @@ -62,7 +62,7 @@ TEST_F(TypeTest, Vectors) { Number i(FormatMode::kSInt, 16); i.SetRowCount(2); - EXPECT_EQ(2, i.RowCount()); + EXPECT_EQ(2u, i.RowCount()); EXPECT_TRUE(i.IsVec()); EXPECT_FALSE(i.IsVec3()); EXPECT_FALSE(i.IsMatrix()); @@ -76,8 +76,8 @@ TEST_F(TypeTest, Matrix) { i.SetColumnCount(2); i.SetRowCount(2); - EXPECT_EQ(2, i.ColumnCount()); - EXPECT_EQ(2, i.RowCount()); + EXPECT_EQ(2u, i.ColumnCount()); + EXPECT_EQ(2u, i.RowCount()); EXPECT_FALSE(i.IsVec()); EXPECT_TRUE(i.IsMatrix()); @@ -205,14 +205,14 @@ TEST_F(TypeTest, StructEqual) { } TEST_F(TypeTest, NumberDefault32Bits) { - EXPECT_EQ(4, Number(FormatMode::kUNorm).SizeInBytes()); + EXPECT_EQ(4u, Number(FormatMode::kUNorm).SizeInBytes()); } TEST_F(TypeTest, NumberInBytes) { - EXPECT_EQ(1, Number(FormatMode::kSInt, 8).SizeInBytes()); - EXPECT_EQ(2, Number(FormatMode::kSInt, 16).SizeInBytes()); - EXPECT_EQ(4, Number(FormatMode::kSInt, 32).SizeInBytes()); - EXPECT_EQ(8, Number(FormatMode::kSInt, 64).SizeInBytes()); + EXPECT_EQ(1u, Number(FormatMode::kSInt, 8).SizeInBytes()); + EXPECT_EQ(2u, Number(FormatMode::kSInt, 16).SizeInBytes()); + EXPECT_EQ(4u, Number(FormatMode::kSInt, 32).SizeInBytes()); + EXPECT_EQ(8u, Number(FormatMode::kSInt, 64).SizeInBytes()); } TEST_F(TypeTest, IsInt) { diff --git a/src/vkscript/parser_test.cc b/src/vkscript/parser_test.cc index c62052c..0b82a81 100644 --- a/src/vkscript/parser_test.cc +++ b/src/vkscript/parser_test.cc @@ -163,8 +163,8 @@ TEST_F(VkScriptParserTest, RequireFbSize) { auto script = parser.GetScript(); const auto& pipelines = script->GetPipelines(); ASSERT_EQ(1U, pipelines.size()); - EXPECT_EQ(300, pipelines[0]->GetFramebufferWidth()); - EXPECT_EQ(400, pipelines[0]->GetFramebufferHeight()); + EXPECT_EQ(300u, pipelines[0]->GetFramebufferWidth()); + EXPECT_EQ(400u, pipelines[0]->GetFramebufferHeight()); } TEST_F(VkScriptParserTest, RequireFbSizeMissingSize) { @@ -260,9 +260,9 @@ TEST_F(VkScriptParserTest, IndicesBlock) { EXPECT_EQ(3U * sizeof(uint32_t), bufs[1]->GetSizeInBytes()); const auto* data = bufs[1]->GetValues(); - EXPECT_EQ(1, data[0]); - EXPECT_EQ(2, data[1]); - EXPECT_EQ(3, data[2]); + EXPECT_EQ(1u, data[0]); + EXPECT_EQ(2u, data[1]); + EXPECT_EQ(3u, data[2]); } TEST_F(VkScriptParserTest, IndicesBlockMultipleLines) { @@ -380,7 +380,7 @@ TEST_F(VkScriptParserTest, VertexDataHeaderGlslString) { EXPECT_EQ(FormatType::kR32G32B32_SINT, bufs[2]->GetFormat()->GetFormatType()); auto& segs2 = bufs[2]->GetFormat()->GetSegments(); - ASSERT_EQ(4, segs2.size()); + ASSERT_EQ(4u, segs2.size()); EXPECT_EQ(FormatMode::kSInt, segs2[0].GetFormatMode()); EXPECT_EQ(FormatMode::kSInt, segs2[1].GetFormatMode()); EXPECT_EQ(FormatMode::kSInt, segs2[2].GetFormatMode()); diff --git a/src/vulkan/engine_vulkan_debugger.cc b/src/vulkan/engine_vulkan_debugger.cc index 9129b32..d0f1432 100644 --- a/src/vulkan/engine_vulkan_debugger.cc +++ b/src/vulkan/engine_vulkan_debugger.cc @@ -26,11 +26,10 @@ #include // NOLINT(build/c++11) #include -#include "src/virtual_file_store.h" - #include "dap/network.h" #include "dap/protocol.h" #include "dap/session.h" +#include "src/virtual_file_store.h" // Set to 1 to enable verbose debugger logging #define ENABLE_DEBUGGER_LOG 0 diff --git a/src/vulkan/image_descriptor.cc b/src/vulkan/image_descriptor.cc index 1305a52..550ce0b 100644 --- a/src/vulkan/image_descriptor.cc +++ b/src/vulkan/image_descriptor.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "src/vulkan/image_descriptor.h" + #include "src/vulkan/device.h" #include "src/vulkan/resource.h" diff --git a/src/vulkan/sampler_descriptor.cc b/src/vulkan/sampler_descriptor.cc index 58cbf6a..59f6c77 100644 --- a/src/vulkan/sampler_descriptor.cc +++ b/src/vulkan/sampler_descriptor.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "src/vulkan/sampler_descriptor.h" + #include "src/vulkan/device.h" #include "src/vulkan/resource.h" diff --git a/src/vulkan/transfer_buffer.cc b/src/vulkan/transfer_buffer.cc index a5fb2d1..a13b22e 100644 --- a/src/vulkan/transfer_buffer.cc +++ b/src/vulkan/transfer_buffer.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "src/vulkan/transfer_buffer.h" + #include "src/vulkan/command_buffer.h" #include "src/vulkan/device.h" diff --git a/tests/run_tests.py b/tests/run_tests.py index 08bf7ee..26d9a54 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -89,6 +89,10 @@ SUPPRESSIONS_SWIFTSHADER = [ "glsl_read_and_write_image3d_rgba32i.amber", # shaderStorageImageMultisample feature not supported "draw_storageimage_multisample.amber", + # Fails on Ubuntu bot + "debugger_hlsl_basic_vertex_with_legalization.amber", + "debugger_hlsl_function_call.amber", + "debugger_hlsl_shadowed_vars.amber", ] OPENCL_CASES = [ -- cgit v1.2.3 From 7c19feb333b5e74ec0d346f22456531a38bb43ef Mon Sep 17 00:00:00 2001 From: alan-baker Date: Wed, 9 Dec 2020 09:11:37 -0500 Subject: Don't add an amber sampler for sampled images (#928) When adding a buffer for an image, do not add a sampler for sampled image binding (only for combined sampled image bindings) Fixes #927 --- src/vulkan/pipeline.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vulkan/pipeline.cc b/src/vulkan/pipeline.cc index 4f4075b..e0b875c 100644 --- a/src/vulkan/pipeline.cc +++ b/src/vulkan/pipeline.cc @@ -320,7 +320,7 @@ Result Pipeline::AddBufferDescriptor(const BufferCommand* cmd) { auto image_desc = MakeUnique( cmd->GetBuffer(), desc_type, device_, cmd->GetBaseMipLevel(), cmd->GetDescriptorSet(), cmd->GetBinding()); - if (cmd->IsSampledImage() || cmd->IsCombinedImageSampler()) + if (cmd->IsCombinedImageSampler()) image_desc->SetAmberSampler(cmd->GetSampler()); descriptors.push_back(std::move(image_desc)); } else { -- cgit v1.2.3 From cc1dec6104f5e0e656d8439296265a19393628df Mon Sep 17 00:00:00 2001 From: jeremyg-lunarg Date: Wed, 9 Dec 2020 09:00:17 -0700 Subject: Fix Vulkan synchronization validation errors (#926) Vulkan CTS TransferImage::ImageBarrier() is often used to synchronize images which are then used as attachments in a RenderPass. Depending on the load operation used, the RenderPass may need either read or write access. (see Section 8.1 Render Pass Creation in the Vulkan 1.2.x specification). To allow any load operation to work correctly, set both read and write access in the dstAccessMask when transitioning to an attachment layout. --- src/vulkan/transfer_image.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/vulkan/transfer_image.cc b/src/vulkan/transfer_image.cc index 60bd6fd..fcbbff4 100644 --- a/src/vulkan/transfer_image.cc +++ b/src/vulkan/transfer_image.cc @@ -342,10 +342,12 @@ void TransferImage::ImageBarrier(CommandBuffer* command_buffer, switch (to_layout) { case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL: - barrier.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; + barrier.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | + VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; break; case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL: - barrier.dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; + barrier.dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT; break; case VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL: barrier.dstAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT; -- cgit v1.2.3 From f8a6fdbe4dc9890fa967091f43b5f7669962c403 Mon Sep 17 00:00:00 2001 From: asuonpaa <34128694+asuonpaa@users.noreply.github.com> Date: Wed, 16 Dec 2020 16:40:10 +0200 Subject: VERTEX_DATA: add format, offset, stride parameters (#929) Adds parameters to the VERTEX_DATA AmberScript command: FORMAT, OFFSET, STRIDE. --- docs/amber_script.md | 12 +- src/amberscript/parser.cc | 60 +++++- src/amberscript/parser_bind_test.cc | 310 +++++++++++++++++++++++++++- src/pipeline.cc | 8 +- src/pipeline.h | 16 +- src/pipeline_test.cc | 10 +- src/vkscript/parser.cc | 4 +- src/vulkan/engine_vulkan.cc | 10 +- src/vulkan/vertex_buffer.cc | 12 +- src/vulkan/vertex_buffer.h | 7 +- src/vulkan/vertex_buffer_test.cc | 3 +- tests/cases/draw_triangle_list_format.amber | 91 ++++++++ tests/cases/draw_triangle_list_offset.amber | 147 +++++++++++++ tests/cases/draw_triangle_list_stride.amber | 106 ++++++++++ 14 files changed, 767 insertions(+), 29 deletions(-) create mode 100644 tests/cases/draw_triangle_list_format.amber create mode 100644 tests/cases/draw_triangle_list_offset.amber create mode 100644 tests/cases/draw_triangle_list_stride.amber diff --git a/docs/amber_script.md b/docs/amber_script.md index 6dd2443..c4d249f 100644 --- a/docs/amber_script.md +++ b/docs/amber_script.md @@ -587,9 +587,15 @@ when using dynamic buffers with BUFFER_ARRAY. ``` ```groovy - # Set |buffer_name| as the vertex data at location |val|. `RATE` defines the - # input rate for vertex attribute reading. - VERTEX_DATA {buffer_name} LOCATION _val_ [ RATE { vertex | instance } (default vertex) ] + # Set |buffer_name| as the vertex data at location |val|. RATE defines the + # input rate for vertex attribute reading. OFFSET sets the byte offset for the + # vertex data within the buffer |buffer_name|, which by default is 0. FORMAT + # sets the vertex buffer format, which by default is the format of the buffer + # |buffer_name|. STRIDE sets the byte stride, which by default is the stride + # of the format (set explicitly via FORMAT or from the format of the buffer + # |buffer_name|). + VERTEX_DATA {buffer_name} LOCATION _val_ [ RATE { vertex | instance } (default vertex) ] \ + [ FORMAT {format} ] [ OFFSET {offset} ] [ STRIDE {stride} ] # Set |buffer_name| as the index data to use for `INDEXED` draw commands. INDEX_DATA {buffer_name} diff --git a/src/amberscript/parser.cc b/src/amberscript/parser.cc index 1a5a197..778a659 100644 --- a/src/amberscript/parser.cc +++ b/src/amberscript/parser.cc @@ -1301,20 +1301,60 @@ Result Parser::ParsePipelineVertexData(Pipeline* pipeline) { const uint32_t location = token->AsUint32(); InputRate rate = InputRate::kVertex; + uint32_t offset = 0; + Format* format = buffer->GetFormat(); + uint32_t stride = 0; + token = tokenizer_->PeekNextToken(); - if (token->IsIdentifier() && token->AsString() == "RATE") { - tokenizer_->NextToken(); - token = tokenizer_->NextToken(); - if (!token->IsIdentifier()) - return Result("missing input rate value for RATE"); - if (token->AsString() == "instance") { - rate = InputRate::kInstance; - } else if (token->AsString() != "vertex") { - return Result("expecting 'vertex' or 'instance' for RATE value"); + while (token->IsIdentifier()) { + if (token->AsString() == "RATE") { + tokenizer_->NextToken(); + token = tokenizer_->NextToken(); + if (!token->IsIdentifier()) + return Result("missing input rate value for RATE"); + if (token->AsString() == "instance") { + rate = InputRate::kInstance; + } else if (token->AsString() != "vertex") { + return Result("expecting 'vertex' or 'instance' for RATE value"); + } + } else if (token->AsString() == "OFFSET") { + tokenizer_->NextToken(); + token = tokenizer_->NextToken(); + if (!token->IsInteger()) + return Result("expected unsigned integer for OFFSET"); + offset = token->AsUint32(); + } else if (token->AsString() == "STRIDE") { + tokenizer_->NextToken(); + token = tokenizer_->NextToken(); + if (!token->IsInteger()) + return Result("expected unsigned integer for STRIDE"); + stride = token->AsUint32(); + if (stride == 0) + return Result("STRIDE needs to be larger than zero"); + } else if (token->AsString() == "FORMAT") { + tokenizer_->NextToken(); + token = tokenizer_->NextToken(); + if (!token->IsIdentifier()) + return Result("vertex data FORMAT must be an identifier"); + auto type = script_->ParseType(token->AsString()); + if (!type) + return Result("invalid vertex data FORMAT"); + auto fmt = MakeUnique(type); + format = fmt.get(); + script_->RegisterFormat(std::move(fmt)); + } else { + return Result("unexpected identifier for VERTEX_DATA command: " + + token->ToOriginalString()); } + + token = tokenizer_->PeekNextToken(); } - Result r = pipeline->AddVertexBuffer(buffer, location, rate); + if (stride == 0) + stride = format->SizeInBytes(); + + Result r = + pipeline->AddVertexBuffer(buffer, location, rate, format, offset, stride); if (!r.IsSuccess()) return r; diff --git a/src/amberscript/parser_bind_test.cc b/src/amberscript/parser_bind_test.cc index 7f07980..64e6692 100644 --- a/src/amberscript/parser_bind_test.cc +++ b/src/amberscript/parser_bind_test.cc @@ -842,7 +842,8 @@ END)"; Parser parser; Result r = parser.Parse(in); ASSERT_FALSE(r.IsSuccess()); - EXPECT_EQ("12: extra parameters after VERTEX_DATA command: EXTRA", r.Error()); + EXPECT_EQ("12: unexpected identifier for VERTEX_DATA command: EXTRA", + r.Error()); } TEST_F(AmberScriptParserTest, BindVertexDataInputRate) { @@ -927,6 +928,313 @@ END)"; EXPECT_EQ("12: expecting 'vertex' or 'instance' for RATE value", r.Error()); } +TEST_F(AmberScriptParserTest, BindVertexDataOffset) { + std::string in = R"( +SHADER vertex my_shader PASSTHROUGH +SHADER fragment my_fragment GLSL +# GLSL Shader +END +BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5 +BUFFER my_buf2 DATA_TYPE int8 SIZE 5 FILL 5 + +PIPELINE graphics my_pipeline + ATTACH my_shader + ATTACH my_fragment + + VERTEX_DATA my_buf LOCATION 0 OFFSET 5 + VERTEX_DATA my_buf2 LOCATION 1 OFFSET 10 +END)"; + + Parser parser; + Result r = parser.Parse(in); + ASSERT_TRUE(r.IsSuccess()) << r.Error(); + + auto script = parser.GetScript(); + const auto& pipelines = script->GetPipelines(); + ASSERT_EQ(1U, pipelines.size()); + + const auto* pipeline = pipelines[0].get(); + const auto& vertex_buffers = pipeline->GetVertexBuffers(); + ASSERT_EQ(2u, vertex_buffers.size()); + + const auto& info1 = vertex_buffers[0]; + ASSERT_TRUE(info1.buffer != nullptr); + EXPECT_EQ(0u, info1.location); + EXPECT_EQ(5u, info1.offset); + + const auto& info2 = vertex_buffers[1]; + ASSERT_TRUE(info2.buffer != nullptr); + EXPECT_EQ(1u, info2.location); + EXPECT_EQ(10u, info2.offset); +} + +TEST_F(AmberScriptParserTest, BindVertexDataOffsetMissingValue) { + std::string in = R"( +SHADER vertex my_shader PASSTHROUGH +SHADER fragment my_fragment GLSL +# GLSL Shader +END +BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5 + +PIPELINE graphics my_pipeline + ATTACH my_shader + ATTACH my_fragment + + VERTEX_DATA my_buf LOCATION 0 OFFSET +END)"; + + Parser parser; + Result r = parser.Parse(in); + ASSERT_FALSE(r.IsSuccess()); + EXPECT_EQ("13: expected unsigned integer for OFFSET", r.Error()); +} + +TEST_F(AmberScriptParserTest, BindVertexDataOffsetIncorrectValue) { + std::string in = R"( +SHADER vertex my_shader PASSTHROUGH +SHADER fragment my_fragment GLSL +# GLSL Shader +END +BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5 + +PIPELINE graphics my_pipeline + ATTACH my_shader + ATTACH my_fragment + + VERTEX_DATA my_buf LOCATION 0 OFFSET foo +END)"; + + Parser parser; + Result r = parser.Parse(in); + ASSERT_FALSE(r.IsSuccess()); + EXPECT_EQ("12: expected unsigned integer for OFFSET", r.Error()); +} + +TEST_F(AmberScriptParserTest, BindVertexDataStride) { + std::string in = R"( +SHADER vertex my_shader PASSTHROUGH +SHADER fragment my_fragment GLSL +# GLSL Shader +END +BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5 +BUFFER my_buf2 DATA_TYPE int8 SIZE 5 FILL 5 + +PIPELINE graphics my_pipeline + ATTACH my_shader + ATTACH my_fragment + + VERTEX_DATA my_buf LOCATION 0 STRIDE 5 + VERTEX_DATA my_buf2 LOCATION 1 STRIDE 10 +END)"; + + Parser parser; + Result r = parser.Parse(in); + ASSERT_TRUE(r.IsSuccess()) << r.Error(); + + auto script = parser.GetScript(); + const auto& pipelines = script->GetPipelines(); + ASSERT_EQ(1U, pipelines.size()); + + const auto* pipeline = pipelines[0].get(); + const auto& vertex_buffers = pipeline->GetVertexBuffers(); + ASSERT_EQ(2u, vertex_buffers.size()); + + const auto& info1 = vertex_buffers[0]; + ASSERT_TRUE(info1.buffer != nullptr); + EXPECT_EQ(0u, info1.location); + EXPECT_EQ(5u, info1.stride); + + const auto& info2 = vertex_buffers[1]; + ASSERT_TRUE(info2.buffer != nullptr); + EXPECT_EQ(1u, info2.location); + EXPECT_EQ(10u, info2.stride); +} + +TEST_F(AmberScriptParserTest, BindVertexDataStrideFromFormat) { + std::string in = R"( +SHADER vertex my_shader PASSTHROUGH +SHADER fragment my_fragment GLSL +# GLSL Shader +END +BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5 +BUFFER my_buf2 DATA_TYPE int8 SIZE 5 FILL 5 + +PIPELINE graphics my_pipeline + ATTACH my_shader + ATTACH my_fragment + + VERTEX_DATA my_buf LOCATION 0 + VERTEX_DATA my_buf2 LOCATION 1 FORMAT R16_UINT +END)"; + + Parser parser; + Result r = parser.Parse(in); + ASSERT_TRUE(r.IsSuccess()) << r.Error(); + + auto script = parser.GetScript(); + const auto& pipelines = script->GetPipelines(); + ASSERT_EQ(1U, pipelines.size()); + + const auto* pipeline = pipelines[0].get(); + const auto& vertex_buffers = pipeline->GetVertexBuffers(); + ASSERT_EQ(2u, vertex_buffers.size()); + + const auto& info1 = vertex_buffers[0]; + ASSERT_TRUE(info1.buffer != nullptr); + EXPECT_EQ(0u, info1.location); + EXPECT_EQ(1u, info1.stride); + + const auto& info2 = vertex_buffers[1]; + ASSERT_TRUE(info2.buffer != nullptr); + EXPECT_EQ(1u, info2.location); + EXPECT_EQ(2u, info2.stride); +} + +TEST_F(AmberScriptParserTest, BindVertexDataStrideMissingValue) { + std::string in = R"( +SHADER vertex my_shader PASSTHROUGH +SHADER fragment my_fragment GLSL +# GLSL Shader +END +BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5 + +PIPELINE graphics my_pipeline + ATTACH my_shader + ATTACH my_fragment + + VERTEX_DATA my_buf LOCATION 0 STRIDE +END)"; + + Parser parser; + Result r = parser.Parse(in); + ASSERT_FALSE(r.IsSuccess()); + EXPECT_EQ("13: expected unsigned integer for STRIDE", r.Error()); +} + +TEST_F(AmberScriptParserTest, BindVertexDataStrideIncorrectValue) { + std::string in = R"( +SHADER vertex my_shader PASSTHROUGH +SHADER fragment my_fragment GLSL +# GLSL Shader +END +BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5 + +PIPELINE graphics my_pipeline + ATTACH my_shader + ATTACH my_fragment + + VERTEX_DATA my_buf LOCATION 0 STRIDE foo +END)"; + + Parser parser; + Result r = parser.Parse(in); + ASSERT_FALSE(r.IsSuccess()); + EXPECT_EQ("12: expected unsigned integer for STRIDE", r.Error()); +} + +TEST_F(AmberScriptParserTest, BindVertexDataStrideZero) { + std::string in = R"( +SHADER vertex my_shader PASSTHROUGH +SHADER fragment my_fragment GLSL +# GLSL Shader +END +BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5 + +PIPELINE graphics my_pipeline + ATTACH my_shader + ATTACH my_fragment + + VERTEX_DATA my_buf LOCATION 0 STRIDE 0 +END)"; + + Parser parser; + Result r = parser.Parse(in); + ASSERT_FALSE(r.IsSuccess()); + EXPECT_EQ("12: STRIDE needs to be larger than zero", r.Error()); +} + +TEST_F(AmberScriptParserTest, BindVertexDataFormat) { + std::string in = R"( +SHADER vertex my_shader PASSTHROUGH +SHADER fragment my_fragment GLSL +# GLSL Shader +END +BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5 +BUFFER my_buf2 DATA_TYPE int8 SIZE 5 FILL 5 + +PIPELINE graphics my_pipeline + ATTACH my_shader + ATTACH my_fragment + + VERTEX_DATA my_buf LOCATION 0 FORMAT R8G8_UNORM + VERTEX_DATA my_buf2 LOCATION 1 FORMAT R8_SRGB +END)"; + + Parser parser; + Result r = parser.Parse(in); + ASSERT_TRUE(r.IsSuccess()) << r.Error(); + + auto script = parser.GetScript(); + const auto& pipelines = script->GetPipelines(); + ASSERT_EQ(1U, pipelines.size()); + + const auto* pipeline = pipelines[0].get(); + const auto& vertex_buffers = pipeline->GetVertexBuffers(); + ASSERT_EQ(2u, vertex_buffers.size()); + + const auto& info1 = vertex_buffers[0]; + ASSERT_TRUE(info1.buffer != nullptr); + EXPECT_EQ(0u, info1.location); + EXPECT_EQ(FormatType::kR8G8_UNORM, info1.format->GetFormatType()); + + const auto& info2 = vertex_buffers[1]; + ASSERT_TRUE(info2.buffer != nullptr); + EXPECT_EQ(1u, info2.location); + EXPECT_EQ(FormatType::kR8_SRGB, info2.format->GetFormatType()); +} + +TEST_F(AmberScriptParserTest, BindVertexDataFormatMissingValue) { + std::string in = R"( +SHADER vertex my_shader PASSTHROUGH +SHADER fragment my_fragment GLSL +# GLSL Shader +END +BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5 + +PIPELINE graphics my_pipeline + ATTACH my_shader + ATTACH my_fragment + + VERTEX_DATA my_buf LOCATION 0 FORMAT +END)"; + + Parser parser; + Result r = parser.Parse(in); + ASSERT_FALSE(r.IsSuccess()); + EXPECT_EQ("13: vertex data FORMAT must be an identifier", r.Error()); +} + +TEST_F(AmberScriptParserTest, BindVertexDataFormatIncorrectValue) { + std::string in = R"( +SHADER vertex my_shader PASSTHROUGH +SHADER fragment my_fragment GLSL +# GLSL Shader +END +BUFFER my_buf DATA_TYPE int8 SIZE 5 FILL 5 + +PIPELINE graphics my_pipeline + ATTACH my_shader + ATTACH my_fragment + + VERTEX_DATA my_buf LOCATION 0 FORMAT foo +END)"; + + Parser parser; + Result r = parser.Parse(in); + ASSERT_FALSE(r.IsSuccess()); + EXPECT_EQ("12: invalid vertex data FORMAT", r.Error()); +} + TEST_F(AmberScriptParserTest, BindIndexData) { std::string in = R"( SHADER vertex my_shader PASSTHROUGH diff --git a/src/pipeline.cc b/src/pipeline.cc index beb09b1..ca1a561 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -423,7 +423,10 @@ Result Pipeline::SetIndexBuffer(Buffer* buf) { Result Pipeline::AddVertexBuffer(Buffer* buf, uint32_t location, - InputRate rate) { + InputRate rate, + Format* format, + uint32_t offset, + uint32_t stride) { for (const auto& vtex : vertex_buffers_) { if (vtex.location == location) return Result("can not bind two vertex buffers to the same LOCATION"); @@ -435,6 +438,9 @@ Result Pipeline::AddVertexBuffer(Buffer* buf, vertex_buffers_.back().location = location; vertex_buffers_.back().type = BufferType::kVertex; vertex_buffers_.back().input_rate = rate; + vertex_buffers_.back().format = format; + vertex_buffers_.back().offset = offset; + vertex_buffers_.back().stride = stride; return {}; } diff --git a/src/pipeline.h b/src/pipeline.h index bdb1679..ec38a3a 100644 --- a/src/pipeline.h +++ b/src/pipeline.h @@ -199,7 +199,10 @@ class Pipeline { uint32_t arg_no = 0; BufferType type = BufferType::kUnknown; InputRate input_rate = InputRate::kVertex; - Sampler* sampler; + Format* format; + uint32_t offset = 0; + uint32_t stride = 0; + Sampler* sampler = nullptr; }; /// Information on a sampler attached to the pipeline. @@ -315,8 +318,15 @@ class Pipeline { return vertex_buffers_; } /// Adds |buf| as a vertex buffer at |location| in the pipeline using |rate| - /// as the input rate. - Result AddVertexBuffer(Buffer* buf, uint32_t location, InputRate rate); + /// as the input rate, |format| as vertex data format, |offset| as a starting + /// offset for the vertex buffer data, and |stride| for the data stride in + /// bytes. + Result AddVertexBuffer(Buffer* buf, + uint32_t location, + InputRate rate, + Format* format, + uint32_t offset, + uint32_t stride); /// Binds |buf| as the index buffer for this pipeline. Result SetIndexBuffer(Buffer* buf); diff --git a/src/pipeline_test.cc b/src/pipeline_test.cc index 96a62aa..e16313c 100644 --- a/src/pipeline_test.cc +++ b/src/pipeline_test.cc @@ -353,7 +353,11 @@ TEST_F(PipelineTest, Clone) { auto vtex_buf = MakeUnique(); vtex_buf->SetName("vertex_buffer"); - p.AddVertexBuffer(vtex_buf.get(), 1, InputRate::kVertex); + TypeParser parser; + auto int_type = parser.Parse("R32_SINT"); + auto int_fmt = MakeUnique(int_type.get()); + p.AddVertexBuffer(vtex_buf.get(), 1, InputRate::kVertex, int_fmt.get(), 5, + 10); auto idx_buf = MakeUnique(); idx_buf->SetName("Index Buffer"); @@ -385,6 +389,10 @@ TEST_F(PipelineTest, Clone) { ASSERT_EQ(1U, vtex_buffers.size()); EXPECT_EQ(1, vtex_buffers[0].location); EXPECT_EQ("vertex_buffer", vtex_buffers[0].buffer->GetName()); + EXPECT_EQ(InputRate::kVertex, vtex_buffers[0].input_rate); + EXPECT_EQ(FormatType::kR32_SINT, vtex_buffers[0].format->GetFormatType()); + EXPECT_EQ(5, vtex_buffers[0].offset); + EXPECT_EQ(10, vtex_buffers[0].stride); auto bufs = clone->GetBuffers(); ASSERT_EQ(2U, bufs.size()); diff --git a/src/vkscript/parser.cc b/src/vkscript/parser.cc index aae55cc..c84e2d9 100644 --- a/src/vkscript/parser.cc +++ b/src/vkscript/parser.cc @@ -444,7 +444,9 @@ Result Parser::ProcessVertexDataBlock(const SectionParser::Section& section) { script_->AddBuffer(std::move(buffer)); - pipeline->AddVertexBuffer(buf, headers[i].location, InputRate::kVertex); + pipeline->AddVertexBuffer(buf, headers[i].location, InputRate::kVertex, + buf->GetFormat(), 0, + buf->GetFormat()->SizeInBytes()); } return {}; diff --git a/src/vulkan/engine_vulkan.cc b/src/vulkan/engine_vulkan.cc index 035c269..536993f 100644 --- a/src/vulkan/engine_vulkan.cc +++ b/src/vulkan/engine_vulkan.cc @@ -209,7 +209,9 @@ Result EngineVulkan::CreatePipeline(amber::Pipeline* pipeline) { info.vertex_buffer = MakeUnique(device_.get()); info.vertex_buffer->SetData(static_cast(vtex_info.location), - vtex_info.buffer, vtex_info.input_rate); + vtex_info.buffer, vtex_info.input_rate, + vtex_info.format, vtex_info.offset, + vtex_info.stride); } if (pipeline->GetIndexBuffer()) { @@ -502,7 +504,8 @@ Result EngineVulkan::DoDrawRect(const DrawRectCommand* command) { buf->SetData(std::move(values)); auto vertex_buffer = MakeUnique(device_.get()); - vertex_buffer->SetData(0, buf.get(), InputRate::kVertex); + vertex_buffer->SetData(0, buf.get(), InputRate::kVertex, buf->GetFormat(), 0, + buf->GetFormat()->SizeInBytes()); DrawArraysCommand draw(command->GetPipeline(), *command->GetPipelineData()); draw.SetTopology(command->IsPatch() ? Topology::kPatchList @@ -589,7 +592,8 @@ Result EngineVulkan::DoDrawGrid(const DrawGridCommand* command) { buf->SetData(std::move(values)); auto vertex_buffer = MakeUnique(device_.get()); - vertex_buffer->SetData(0, buf.get(), InputRate::kVertex); + vertex_buffer->SetData(0, buf.get(), InputRate::kVertex, buf->GetFormat(), 0, + buf->GetFormat()->SizeInBytes()); DrawArraysCommand draw(command->GetPipeline(), *command->GetPipelineData()); draw.SetTopology(Topology::kTriangleList); diff --git a/src/vulkan/vertex_buffer.cc b/src/vulkan/vertex_buffer.cc index 409c0f1..ea7e5eb 100644 --- a/src/vulkan/vertex_buffer.cc +++ b/src/vulkan/vertex_buffer.cc @@ -36,18 +36,22 @@ VertexBuffer::VertexBuffer(Device* device) : device_(device) {} VertexBuffer::~VertexBuffer() = default; -void VertexBuffer::SetData(uint8_t location, Buffer* buffer, InputRate rate) { - auto format = buffer->GetFormat(); +void VertexBuffer::SetData(uint8_t location, + Buffer* buffer, + InputRate rate, + Format* format, + uint32_t offset, + uint32_t stride) { const uint32_t binding = static_cast(vertex_attr_desc_.size()); vertex_attr_desc_.emplace_back(); vertex_attr_desc_.back().binding = binding; vertex_attr_desc_.back().location = location; - vertex_attr_desc_.back().offset = 0u; + vertex_attr_desc_.back().offset = offset; vertex_attr_desc_.back().format = device_->GetVkFormat(*format); vertex_binding_desc_.emplace_back(); vertex_binding_desc_.back().binding = binding; - vertex_binding_desc_.back().stride = format->SizeInBytes(); + vertex_binding_desc_.back().stride = stride; vertex_binding_desc_.back().inputRate = GetVkInputRate(rate); data_.push_back(buffer); diff --git a/src/vulkan/vertex_buffer.h b/src/vulkan/vertex_buffer.h index 2837a9e..4c49e46 100644 --- a/src/vulkan/vertex_buffer.h +++ b/src/vulkan/vertex_buffer.h @@ -40,7 +40,12 @@ class VertexBuffer { Result SendVertexData(CommandBuffer* command); bool VertexDataSent() const { return !is_vertex_data_pending_; } - void SetData(uint8_t location, Buffer* buffer, InputRate rate); + void SetData(uint8_t location, + Buffer* buffer, + InputRate rate, + Format* format, + uint32_t offset, + uint32_t stride); const std::vector& GetVkVertexInputAttr() const { diff --git a/src/vulkan/vertex_buffer_test.cc b/src/vulkan/vertex_buffer_test.cc index 914933e..eb8a7bd 100644 --- a/src/vulkan/vertex_buffer_test.cc +++ b/src/vulkan/vertex_buffer_test.cc @@ -151,7 +151,8 @@ class VertexBufferTest : public testing::Test { buffer->SetFormat(format); buffer->SetData(std::move(values)); - vertex_buffer_->SetData(location, buffer.get(), InputRate::kVertex); + vertex_buffer_->SetData(location, buffer.get(), InputRate::kVertex, format, + 0, format->SizeInBytes()); return vertex_buffer_->SendVertexData(commandBuffer_.get()); } diff --git a/tests/cases/draw_triangle_list_format.amber b/tests/cases/draw_triangle_list_format.amber new file mode 100644 index 0000000..894a9fb --- /dev/null +++ b/tests/cases/draw_triangle_list_format.amber @@ -0,0 +1,91 @@ +#!amber +# Copyright 2020 The Amber Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SHADER vertex vtex_shader GLSL +#version 430 + +layout(location = 0) in vec4 position; +layout(location = 1) in vec4 vert_color; +layout(location = 0) out vec4 frag_color; + +void main() { + gl_Position = position; + frag_color = vert_color; +} +END +SHADER fragment frag_shader GLSL +#version 430 + +layout(location = 0) in vec4 frag_color; +layout(location = 0) out vec4 final_color; + +void main() { + final_color = frag_color; +} +END + +BUFFER position_buf DATA_TYPE R8G8_SNORM DATA +-128 -128 + 0 127 +-128 127 +-128 -128 + 0 127 + 0 -128 + + 0 -128 + 127 127 + 0 127 + 0 -128 + 127 127 + 127 -128 +END + +BUFFER vert_color DATA_TYPE R8G8B8A8_UNORM DATA +255 255 255 255 +255 255 255 255 +255 255 255 255 +255 255 255 255 +255 255 255 255 +255 255 255 255 +255 255 255 255 +END + +IMAGE framebuffer FORMAT B8G8R8A8_UNORM DIM_2D WIDTH 64 HEIGHT 64 + +PIPELINE graphics pipeline0 + ATTACH vtex_shader + ATTACH frag_shader + VERTEX_DATA position_buf LOCATION 0 + VERTEX_DATA vert_color LOCATION 1 + BIND BUFFER framebuffer AS color LOCATION 0 + FRAMEBUFFER_SIZE 64 64 +END + +PIPELINE graphics pipeline1 + ATTACH vtex_shader + ATTACH frag_shader + VERTEX_DATA position_buf LOCATION 0 OFFSET 12 + VERTEX_DATA vert_color LOCATION 1 FORMAT R8_UNORM + BIND BUFFER framebuffer AS color LOCATION 0 + FRAMEBUFFER_SIZE 64 64 +END + +CLEAR pipeline0 + +RUN pipeline0 DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 +RUN pipeline1 DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 + +EXPECT framebuffer IDX 0 0 SIZE 32 64 EQ_RGBA 255 255 255 255 +EXPECT framebuffer IDX 32 0 SIZE 32 64 EQ_RGBA 255 0 0 255 diff --git a/tests/cases/draw_triangle_list_offset.amber b/tests/cases/draw_triangle_list_offset.amber new file mode 100644 index 0000000..e0d3777 --- /dev/null +++ b/tests/cases/draw_triangle_list_offset.amber @@ -0,0 +1,147 @@ +#!amber +# Copyright 2020 The Amber Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SHADER vertex vtex_shader GLSL +#version 430 + +layout(location = 0) in vec4 position; +layout(location = 1) in vec4 vert_color; +layout(location = 0) out vec4 frag_color; + +void main() { + gl_Position = position; + frag_color = vert_color; +} +END +SHADER fragment frag_shader GLSL +#version 430 + +layout(location = 0) in vec4 frag_color; +layout(location = 0) out vec4 final_color; + +void main() { + final_color = frag_color; +} +END + +BUFFER position_buf DATA_TYPE R8G8_SNORM DATA +-128 -128 + 0 0 +-128 0 +-128 -128 + 0 0 + 0 -128 + + 0 -128 + 127 0 + 0 0 + 0 -128 + 127 0 + 127 -128 + + 0 0 + 127 127 + 0 127 + 0 0 + 127 127 + 127 0 + +-128 0 + 0 127 +-128 127 +-128 0 + 0 127 + 0 0 +END + +BUFFER vert_color DATA_TYPE R8G8B8A8_UNORM DATA +255 0 0 255 +255 0 0 255 +255 0 0 255 +255 0 0 255 +255 0 0 255 +255 0 0 255 + + 0 255 0 255 + 0 255 0 255 + 0 255 0 255 + 0 255 0 255 + 0 255 0 255 + 0 255 0 255 + + 0 0 255 255 + 0 0 255 255 + 0 0 255 255 + 0 0 255 255 + 0 0 255 255 + 0 0 255 255 + + 0 255 255 255 + 0 255 255 255 + 0 255 255 255 + 0 255 255 255 + 0 255 255 255 + 0 255 255 255 +END + +IMAGE framebuffer FORMAT B8G8R8A8_UNORM DIM_2D WIDTH 64 HEIGHT 64 + +PIPELINE graphics pipeline0 + ATTACH vtex_shader + ATTACH frag_shader + VERTEX_DATA position_buf LOCATION 0 + VERTEX_DATA vert_color LOCATION 1 + BIND BUFFER framebuffer AS color LOCATION 0 + FRAMEBUFFER_SIZE 64 64 +END + +PIPELINE graphics pipeline1 + ATTACH vtex_shader + ATTACH frag_shader + VERTEX_DATA position_buf LOCATION 0 OFFSET 12 + VERTEX_DATA vert_color LOCATION 1 OFFSET 24 + BIND BUFFER framebuffer AS color LOCATION 0 + FRAMEBUFFER_SIZE 64 64 +END + +PIPELINE graphics pipeline2 + ATTACH vtex_shader + ATTACH frag_shader + VERTEX_DATA position_buf LOCATION 0 OFFSET 24 + VERTEX_DATA vert_color LOCATION 1 OFFSET 48 + BIND BUFFER framebuffer AS color LOCATION 0 + FRAMEBUFFER_SIZE 64 64 +END + +PIPELINE graphics pipeline3 + ATTACH vtex_shader + ATTACH frag_shader + VERTEX_DATA position_buf LOCATION 0 OFFSET 36 + VERTEX_DATA vert_color LOCATION 1 OFFSET 72 + BIND BUFFER framebuffer AS color LOCATION 0 + FRAMEBUFFER_SIZE 64 64 +END + +CLEAR pipeline0 + +RUN pipeline0 DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 +RUN pipeline1 DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 +RUN pipeline2 DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 +RUN pipeline3 DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 + +EXPECT framebuffer IDX 0 0 SIZE 32 32 EQ_RGBA 255 0 0 255 +EXPECT framebuffer IDX 32 0 SIZE 32 32 EQ_RGBA 0 255 0 255 +EXPECT framebuffer IDX 32 32 SIZE 32 32 EQ_RGBA 0 0 255 255 +EXPECT framebuffer IDX 0 32 SIZE 32 32 EQ_RGBA 0 255 255 255 diff --git a/tests/cases/draw_triangle_list_stride.amber b/tests/cases/draw_triangle_list_stride.amber new file mode 100644 index 0000000..49c1d46 --- /dev/null +++ b/tests/cases/draw_triangle_list_stride.amber @@ -0,0 +1,106 @@ +#!amber +# Copyright 2020 The Amber Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SHADER vertex vtex_shader GLSL +#version 430 + +layout(location = 0) in vec4 position; +layout(location = 1) in vec4 vert_color; +layout(location = 0) out vec4 frag_color; + +void main() { + gl_Position = position; + frag_color = vert_color; +} +END +SHADER fragment frag_shader GLSL +#version 430 + +layout(location = 0) in vec4 frag_color; +layout(location = 0) out vec4 final_color; + +void main() { + final_color = frag_color; +} +END + +BUFFER position_buf DATA_TYPE R8G8_SNORM DATA +-128 -128 + 0 127 +-128 127 +-128 -128 + 0 127 + 0 -128 + + 0 -128 + 127 127 + 0 127 + 0 -128 + 127 127 + 127 -128 +END + +BUFFER vert_color DATA_TYPE R8G8B8A8_UNORM DATA +255 0 0 255 + 0 255 0 255 +255 0 0 255 + 0 0 0 255 +255 0 0 255 + 0 255 0 255 +255 0 0 255 + 0 0 0 255 +255 0 0 255 + 0 255 0 255 +255 0 0 255 + 0 0 0 255 +255 0 0 255 + 0 255 0 255 +255 0 0 255 + 0 0 0 255 +255 0 0 255 + 0 255 0 255 +255 0 0 255 + 0 0 0 255 +255 0 0 255 + 0 255 0 255 +END + +IMAGE framebuffer FORMAT B8G8R8A8_UNORM DIM_2D WIDTH 64 HEIGHT 64 + +PIPELINE graphics pipeline0 + ATTACH vtex_shader + ATTACH frag_shader + VERTEX_DATA position_buf LOCATION 0 + VERTEX_DATA vert_color LOCATION 1 STRIDE 8 + BIND BUFFER framebuffer AS color LOCATION 0 + FRAMEBUFFER_SIZE 64 64 +END + +PIPELINE graphics pipeline1 + ATTACH vtex_shader + ATTACH frag_shader + VERTEX_DATA position_buf LOCATION 0 OFFSET 12 + VERTEX_DATA vert_color LOCATION 1 OFFSET 4 STRIDE 16 + BIND BUFFER framebuffer AS color LOCATION 0 + FRAMEBUFFER_SIZE 64 64 +END + +CLEAR pipeline0 + +RUN pipeline0 DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 +RUN pipeline1 DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 + +EXPECT framebuffer IDX 0 0 SIZE 32 64 EQ_RGBA 255 0 0 255 +EXPECT framebuffer IDX 32 0 SIZE 32 64 EQ_RGBA 0 255 0 255 -- cgit v1.2.3 From e2ccba04930477fbc0dcde9b080facc033071751 Mon Sep 17 00:00:00 2001 From: asuonpaa <34128694+asuonpaa@users.noreply.github.com> Date: Mon, 11 Jan 2021 11:53:53 +0200 Subject: Expose target environment to shader info (#935) This change exposes shader target environment parsed from Amber Script into shader info structure. This allows Vulkan CTS to compile GLSL into SPIR-V using the specified SPIR-V version. --- include/amber/shader_info.h | 2 ++ src/script.cc | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/amber/shader_info.h b/include/amber/shader_info.h index 03e0c81..6c9126a 100644 --- a/include/amber/shader_info.h +++ b/include/amber/shader_info.h @@ -54,6 +54,8 @@ struct ShaderInfo { std::string shader_source; /// A list of SPIR-V optimization passes to execute on the shader. std::vector optimizations; + /// Target environment for the shader compilation. + std::string target_env; /// The shader SPIR-V if it was compiled by Amber std::vector shader_data; }; diff --git a/src/script.cc b/src/script.cc index 5193aab..7d7483f 100644 --- a/src/script.cc +++ b/src/script.cc @@ -32,10 +32,11 @@ std::vector Script::GetShaderInfo() const { for (const auto& pipeline : pipelines_) { auto shader_info = pipeline->GetShader(shader.get()); if (shader_info) { - ret.emplace_back(ShaderInfo{ - shader->GetFormat(), shader->GetType(), - pipeline->GetName() + "-" + shader->GetName(), shader->GetData(), - shader_info->GetShaderOptimizations(), shader_info->GetData()}); + ret.emplace_back( + ShaderInfo{shader->GetFormat(), shader->GetType(), + pipeline->GetName() + "-" + shader->GetName(), + shader->GetData(), shader_info->GetShaderOptimizations(), + shader->GetTargetEnv(), shader_info->GetData()}); in_pipeline = true; } @@ -47,6 +48,7 @@ std::vector Script::GetShaderInfo() const { shader->GetName(), shader->GetData(), {}, + shader->GetTargetEnv(), {}}); } } -- cgit v1.2.3 From ace2bdee2dbcc2f21ac823ea2f2a9d5698a6cc2c Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Tue, 12 Jan 2021 12:48:09 -0500 Subject: [amberscript] Add DATA to IMAGE command (#934) This CL adds a DATA initializer to the IMAGE command. This allows setting the data to be used in the image as part of the initializer. --- docs/amber_script.md | 19 +++++--- src/amberscript/parser.cc | 17 ++++++- src/amberscript/parser_image_test.cc | 56 ++++++++++++++++++++++ tests/cases/image_data.amber | 92 ++++++++++++++++++++++++++++++++++++ 4 files changed, 175 insertions(+), 9 deletions(-) create mode 100644 tests/cases/image_data.amber diff --git a/docs/amber_script.md b/docs/amber_script.md index c4d249f..57e0632 100644 --- a/docs/amber_script.md +++ b/docs/amber_script.md @@ -215,12 +215,9 @@ either image buffers or, what the target API would refer to as a buffer. Sized arrays and structures are not currently representable. ```groovy -# Filling the buffer with a given set of data. The values must be -# of |type| data. The data can be provided as the type or as a hex value. -# Buffers are STD430 by default. -BUFFER {name} DATA_TYPE {type} {STD140 | STD430} DATA -_value_+ -END +# Filling the buffer with a given initializer. Initializer data must be +# of |type|. Buffers are STD430 by default. +BUFFER {name} DATA_TYPE {type} {STD140 | STD430} {initializer} # Defines a buffer which is filled with data as specified by the `initializer`. BUFFER {name} DATA_TYPE {type} {STD140 | STD430} SIZE _size_in_items_ \ @@ -286,6 +283,14 @@ IMAGE {name} DATA_TYPE {type} {dimensionality} \ #### Buffer Initializers +```groovy +# Filling the buffer with a given set of data. The values must be +# of the correct type. The data can be provided as the type or as a hex +# value. +DATA +_value_+ +END + ```groovy # Fill the buffer with a single value. FILL _value_ @@ -488,7 +493,7 @@ The following commands are all specified within the `PIPELINE` command. # - a power-of-two integer that _must_ be greater or equal to minSubgroupSize # and be less than or equal to maxSubgroupSize # - MIN to set the required subgroup size to the minSubgroupSize - # - MAX to set the required subgroup size to the maxSubgroupSize + # - MAX to set the required subgroup size to the maxSubgroupSize SUBROUP {name_of_shader} FULLY_POPULATED {fully_populated_enable} VARYING_SIZE {varying_size_enable} diff --git a/src/amberscript/parser.cc b/src/amberscript/parser.cc index 778a659..fc5c948 100644 --- a/src/amberscript/parser.cc +++ b/src/amberscript/parser.cc @@ -1937,8 +1937,10 @@ Result Parser::ParseImage() { token = tokenizer_->PeekNextToken(); while (token->IsIdentifier()) { - if (token->AsString() == "FILL" || token->AsString() == "SERIES_FROM") + if (token->AsString() == "FILL" || token->AsString() == "SERIES_FROM" || + token->AsString() == "DATA") { break; + } tokenizer_->NextToken(); @@ -2045,7 +2047,18 @@ Result Parser::ParseImage() { // Parse initializers. token = tokenizer_->NextToken(); if (token->IsIdentifier()) { - if (token->AsString() == "FILL") { + if (token->AsString() == "DATA") { + Result r = ParseBufferInitializerData(buffer.get()); + if (!r.IsSuccess()) + return r; + + if (size_in_items != buffer->ElementCount()) { + return Result( + "Elements provided in data does not match size specified: " + + std::to_string(size_in_items) + " specified vs " + + std::to_string(buffer->ElementCount()) + " provided"); + } + } else if (token->AsString() == "FILL") { Result r = ParseBufferInitializerFill(buffer.get(), size_in_items); if (!r.IsSuccess()) return r; diff --git a/src/amberscript/parser_image_test.cc b/src/amberscript/parser_image_test.cc index bfa3fb6..53c8ad7 100644 --- a/src/amberscript/parser_image_test.cc +++ b/src/amberscript/parser_image_test.cc @@ -309,5 +309,61 @@ IMAGE image DATA_TYPE uint32 DIM_3D WIDTH 3 HEIGHT 4 DEPTH 5 EXPECT_EQ(60u, buffer->ElementCount()); } +TEST_F(AmberScriptParserTest, ImageWithData) { + std::string in = R"( +IMAGE image DATA_TYPE float DIM_3D HEIGHT 2 WIDTH 2 DEPTH 2 DATA + 0.11 0.12 + 0.21 0.22 + + 0.31 0.32 + 0.41 0.42 +END +)"; + + Parser parser; + Result r = parser.Parse(in); + ASSERT_TRUE(r.IsSuccess()) << r.Error(); + auto script = parser.GetScript(); + const auto& buffers = script->GetBuffers(); + ASSERT_EQ(1U, buffers.size()); + + ASSERT_TRUE(buffers[0] != nullptr); + EXPECT_EQ("image", buffers[0]->GetName()); + + auto* buffer = buffers[0].get(); + EXPECT_TRUE(buffer->GetFormat()->IsFloat32()); + EXPECT_EQ(ImageDimension::k3D, buffer->GetImageDimension()); + EXPECT_EQ(2u, buffer->GetWidth()); + EXPECT_EQ(2u, buffer->GetHeight()); + EXPECT_EQ(2u, buffer->GetDepth()); + EXPECT_EQ(8u, buffer->ElementCount()); + + auto* values = buffer->GetValues(); + std::vector result = {0.11f, 0.12f, 0.21f, 0.22f, + 0.31f, 0.32f, 0.41f, 0.42f}; + + EXPECT_EQ((*buffer->ValuePtr()).size(), 8u * sizeof(float)); + for (size_t i = 0; i < result.size(); ++i) { + EXPECT_FLOAT_EQ(result[i], values[i]); + } +} + +TEST_F(AmberScriptParserTest, ImageDataSizeIncorrect) { + std::string in = R"( +IMAGE image DATA_TYPE float DIM_3D HEIGHT 2 WIDTH 2 DEPTH 2 DATA + 0.11 0.12 + 0.21 0.22 +END +)"; + + Parser parser; + Result r = parser.Parse(in); + ASSERT_FALSE(r.IsSuccess()); + EXPECT_EQ( + "6: Elements provided in data does not match size specified: 8 specified " + "vs 4 provided", + r.Error()); +} + } // namespace amberscript } // namespace amber diff --git a/tests/cases/image_data.amber b/tests/cases/image_data.amber new file mode 100644 index 0000000..3d1f79f --- /dev/null +++ b/tests/cases/image_data.amber @@ -0,0 +1,92 @@ +#!amber +# Copyright 2021 The Amber Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SHADER compute compute_shader GLSL +#version 460 + +layout(local_size_x = 4, local_size_y = 4, local_size_z = 1) in; + +layout(binding = 0, r32f) uniform readonly image3D inImg; +layout(binding = 1, r32f) uniform image3D outImg; + +void main() { + // Get current pixel + const int current_x = int(gl_GlobalInvocationID.x); + const int current_y = int(gl_GlobalInvocationID.y); + + for (int idx = 0; idx < 4; ++idx) { + vec4 result = imageLoad(inImg, ivec3(current_x, current_y, 3 - idx)); + imageStore(outImg, ivec3(current_x, current_y, idx), result); + } +} +END + +IMAGE outputImage DATA_TYPE float DIM_3D WIDTH 4 HEIGHT 4 DEPTH 4 FILL 0.0 + +IMAGE inputImage DATA_TYPE float DIM_3D WIDTH 4 HEIGHT 4 DEPTH 4 DATA + 0.110 0.111 0.112 0.113 + 0.120 0.121 0.122 0.123 + 0.130 0.131 0.132 0.133 + 0.140 0.141 0.142 0.143 + + 0.210 0.211 0.212 0.213 + 0.220 0.221 0.222 0.223 + 0.230 0.231 0.232 0.233 + 0.240 0.241 0.242 0.243 + + 0.310 0.311 0.312 0.313 + 0.320 0.321 0.322 0.323 + 0.330 0.331 0.332 0.333 + 0.340 0.341 0.342 0.343 + + 0.410 0.411 0.412 0.413 + 0.420 0.421 0.422 0.423 + 0.430 0.431 0.432 0.433 + 0.440 0.441 0.442 0.443 +END + +IMAGE expectedImage DATA_TYPE float DIM_3D WIDTH 4 HEIGHT 4 DEPTH 4 DATA + 0.410 0.411 0.412 0.413 + 0.420 0.421 0.422 0.423 + 0.430 0.431 0.432 0.433 + 0.440 0.441 0.442 0.443 + + 0.310 0.311 0.312 0.313 + 0.320 0.321 0.322 0.323 + 0.330 0.331 0.332 0.333 + 0.340 0.341 0.342 0.343 + + 0.210 0.211 0.212 0.213 + 0.220 0.221 0.222 0.223 + 0.230 0.231 0.232 0.233 + 0.240 0.241 0.242 0.243 + + 0.110 0.111 0.112 0.113 + 0.120 0.121 0.122 0.123 + 0.130 0.131 0.132 0.133 + 0.140 0.141 0.142 0.143 +END + +PIPELINE compute pipeline + ATTACH compute_shader + + BIND BUFFER inputImage AS storage_image DESCRIPTOR_SET 0 BINDING 0 + BIND BUFFER outputImage AS storage_image DESCRIPTOR_SET 0 BINDING 1 +END + +RUN pipeline 1 1 1 + +EXPECT outputImage EQ_BUFFER expectedImage + -- cgit v1.2.3 From 508bc75eda4f7f8c942093d8c6a2bd0a621e2da4 Mon Sep 17 00:00:00 2001 From: alan-baker Date: Thu, 14 Jan 2021 15:26:09 -0500 Subject: Allow hex for values in expect commands (#937) * Handled the same as parsing buffer data --- src/amberscript/parser.cc | 7 +++-- src/amberscript/parser_expect_test.cc | 54 +++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/src/amberscript/parser.cc b/src/amberscript/parser.cc index fc5c948..50760f0 100644 --- a/src/amberscript/parser.cc +++ b/src/amberscript/parser.cc @@ -2907,7 +2907,7 @@ Result Parser::ParseValues(const std::string& name, } if (type::Type::IsFloat(segs[seg_idx].GetFormatMode())) { - if (!token->IsInteger() && !token->IsDouble()) { + if (!token->IsInteger() && !token->IsDouble() && !token->IsHex()) { return Result(std::string("Invalid value provided to ") + name + " command: " + token->ToOriginalString()); } @@ -2918,12 +2918,13 @@ Result Parser::ParseValues(const std::string& name, v.SetDoubleValue(token->AsDouble()); } else { - if (!token->IsInteger()) { + if (!token->IsInteger() && !token->IsHex()) { return Result(std::string("Invalid value provided to ") + name + " command: " + token->ToOriginalString()); } - v.SetIntValue(token->AsUint64()); + uint64_t val = token->IsHex() ? token->AsHex() : token->AsUint64(); + v.SetIntValue(val); } ++seg_idx; if (seg_idx >= segs.size()) diff --git a/src/amberscript/parser_expect_test.cc b/src/amberscript/parser_expect_test.cc index 125e38b..b7e8c59 100644 --- a/src/amberscript/parser_expect_test.cc +++ b/src/amberscript/parser_expect_test.cc @@ -1278,5 +1278,59 @@ EXPECT buf_1 RMSE_BUFFER buf_2)"; r.Error()); } +TEST_F(AmberScriptParserTest, ExpectAllowIntegerHexValue) { + std::string in = R"( +BUFFER b1 DATA_TYPE uint32 SIZE 4 FILL 0 +EXPECT b1 IDX 0 EQ 0x0 0x1 0x2 0x3 +)"; + + Parser parser; + Result r = parser.Parse(in); + ASSERT_TRUE(r.IsSuccess()); + + auto script = parser.GetScript(); + const auto& commands = script->GetCommands(); + ASSERT_EQ(1U, commands.size()); + + auto* cmd = commands[0].get(); + ASSERT_TRUE(cmd->IsProbeSSBO()); + + auto* probe = cmd->AsProbeSSBO(); + EXPECT_EQ(probe->GetComparator(), ProbeSSBOCommand::Comparator::kEqual); + + EXPECT_EQ(4, probe->GetValues().size()); + EXPECT_EQ(0, probe->GetValues()[0].AsUint64()); + EXPECT_EQ(1, probe->GetValues()[1].AsUint64()); + EXPECT_EQ(2, probe->GetValues()[2].AsUint64()); + EXPECT_EQ(3, probe->GetValues()[3].AsUint64()); +} + +TEST_F(AmberScriptParserTest, ExpectAllowFloatHexValue) { + std::string in = R"( +BUFFER b1 DATA_TYPE float SIZE 4 FILL 0 +EXPECT b1 IDX 0 EQ 0x0 0x1 0x2 0x3 +)"; + + Parser parser; + Result r = parser.Parse(in); + ASSERT_TRUE(r.IsSuccess()); + + auto script = parser.GetScript(); + const auto& commands = script->GetCommands(); + ASSERT_EQ(1U, commands.size()); + + auto* cmd = commands[0].get(); + ASSERT_TRUE(cmd->IsProbeSSBO()); + + auto* probe = cmd->AsProbeSSBO(); + EXPECT_EQ(probe->GetComparator(), ProbeSSBOCommand::Comparator::kEqual); + + EXPECT_EQ(4, probe->GetValues().size()); + EXPECT_EQ(static_cast(0), probe->GetValues()[0].AsDouble()); + EXPECT_EQ(static_cast(1), probe->GetValues()[1].AsDouble()); + EXPECT_EQ(static_cast(2), probe->GetValues()[2].AsDouble()); + EXPECT_EQ(static_cast(3), probe->GetValues()[3].AsDouble()); +} + } // namespace amberscript } // namespace amber -- cgit v1.2.3 From aee124f78b78101b62a2371f57216bf91ab8561f Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Mon, 18 Jan 2021 15:43:17 +0000 Subject: Update license checker config (#939) The license classification rules in github.com/google/licensecheck have been updated. --- license-checker.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/license-checker.cfg b/license-checker.cfg index 7b6ed30..cc7e4dc 100644 --- a/license-checker.cfg +++ b/license-checker.cfg @@ -1,5 +1,6 @@ { "licenses": [ + "Apache-2.0", "Apache-2.0-Header" ], "paths": [ -- cgit v1.2.3 From cbecdfcfccc9b5d04601b48c9d244fd5e3a434b0 Mon Sep 17 00:00:00 2001 From: asuonpaa <34128694+asuonpaa@users.noreply.github.com> Date: Wed, 27 Jan 2021 16:10:05 +0200 Subject: Support binding the same vertex buffer to multiple locations (#936) There's no need to restrict binding a vertex buffer to multiple locations. Now that we have OFFSET supported this has a real use case where the same buffer is used with different offsets. --- src/amberscript/parser_bind_test.cc | 24 +++++++-- src/pipeline.cc | 2 - src/vulkan/vertex_buffer.cc | 19 ++++--- src/vulkan/vertex_buffer.h | 2 + tests/cases/vertex_data_two_locations.amber | 84 +++++++++++++++++++++++++++++ 5 files changed, 119 insertions(+), 12 deletions(-) create mode 100644 tests/cases/vertex_data_two_locations.amber diff --git a/src/amberscript/parser_bind_test.cc b/src/amberscript/parser_bind_test.cc index 64e6692..64f3948 100644 --- a/src/amberscript/parser_bind_test.cc +++ b/src/amberscript/parser_bind_test.cc @@ -731,14 +731,30 @@ PIPELINE graphics my_pipeline ATTACH my_fragment VERTEX_DATA my_buf LOCATION 0 - VERTEX_DATA my_buf LOCATION 1 + VERTEX_DATA my_buf LOCATION 1 OFFSET 10 END)"; Parser parser; Result r = parser.Parse(in); - ASSERT_FALSE(r.IsSuccess()); - EXPECT_EQ("13: vertex buffer may only be bound to a PIPELINE once", - r.Error()); + ASSERT_TRUE(r.IsSuccess()); + + auto script = parser.GetScript(); + const auto& pipelines = script->GetPipelines(); + ASSERT_EQ(1U, pipelines.size()); + + const auto* pipeline = pipelines[0].get(); + const auto& vertex_buffers = pipeline->GetVertexBuffers(); + ASSERT_EQ(2u, vertex_buffers.size()); + + const auto& info1 = vertex_buffers[0]; + ASSERT_TRUE(info1.buffer != nullptr); + EXPECT_EQ(0u, info1.location); + EXPECT_EQ(0u, info1.offset); + + const auto& info2 = vertex_buffers[1]; + ASSERT_TRUE(info2.buffer != nullptr); + EXPECT_EQ(1u, info2.location); + EXPECT_EQ(10u, info2.offset); } TEST_F(AmberScriptParserTest, BindVertexDataMissingBuffer) { diff --git a/src/pipeline.cc b/src/pipeline.cc index ca1a561..55c6bae 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -430,8 +430,6 @@ Result Pipeline::AddVertexBuffer(Buffer* buf, for (const auto& vtex : vertex_buffers_) { if (vtex.location == location) return Result("can not bind two vertex buffers to the same LOCATION"); - if (vtex.buffer == buf) - return Result("vertex buffer may only be bound to a PIPELINE once"); } vertex_buffers_.push_back(BufferInfo{buf}); diff --git a/src/vulkan/vertex_buffer.cc b/src/vulkan/vertex_buffer.cc index ea7e5eb..7503681 100644 --- a/src/vulkan/vertex_buffer.cc +++ b/src/vulkan/vertex_buffer.cc @@ -61,23 +61,28 @@ void VertexBuffer::BindToCommandBuffer(CommandBuffer* command) { std::vector buffers; std::vector offsets; - for (const auto& buf : transfer_buffers_) { - buffers.push_back(buf->GetVkBuffer()); + for (const auto& buf : data_) { + buffers.push_back(buffer_to_vk_buffer_[buf]); offsets.push_back(0); } device_->GetPtrs()->vkCmdBindVertexBuffers( - command->GetVkCommandBuffer(), 0, - static_cast(transfer_buffers_.size()), buffers.data(), - offsets.data()); + command->GetVkCommandBuffer(), 0, static_cast(buffers.size()), + buffers.data(), offsets.data()); } Result VertexBuffer::SendVertexData(CommandBuffer* command) { if (!is_vertex_data_pending_) return Result("Vulkan::Vertices data was already sent"); + buffer_to_vk_buffer_.clear(); + for (const auto& buf : data_) { - uint32_t bytes = buf->GetSizeInBytes(); + if (buffer_to_vk_buffer_.count(buf) != 0) { + continue; + } + // Create a new transfer buffer to hold vertex data. + uint32_t bytes = buf->GetSizeInBytes(); transfer_buffers_.push_back( MakeUnique(device_, bytes, nullptr)); Result r = transfer_buffers_.back()->Initialize( @@ -89,6 +94,8 @@ Result VertexBuffer::SendVertexData(CommandBuffer* command) { if (!r.IsSuccess()) return r; + + buffer_to_vk_buffer_[buf] = transfer_buffers_.back()->GetVkBuffer(); } is_vertex_data_pending_ = false; diff --git a/src/vulkan/vertex_buffer.h b/src/vulkan/vertex_buffer.h index 4c49e46..871a9cc 100644 --- a/src/vulkan/vertex_buffer.h +++ b/src/vulkan/vertex_buffer.h @@ -15,6 +15,7 @@ #ifndef SRC_VULKAN_VERTEX_BUFFER_H_ #define SRC_VULKAN_VERTEX_BUFFER_H_ +#include #include #include @@ -68,6 +69,7 @@ class VertexBuffer { std::vector data_; std::vector vertex_binding_desc_; std::vector vertex_attr_desc_; + std::map buffer_to_vk_buffer_; }; } // namespace vulkan diff --git a/tests/cases/vertex_data_two_locations.amber b/tests/cases/vertex_data_two_locations.amber new file mode 100644 index 0000000..a9a4491 --- /dev/null +++ b/tests/cases/vertex_data_two_locations.amber @@ -0,0 +1,84 @@ +#!amber +# Copyright 2021 The Amber Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SHADER vertex vtex_shader GLSL +#version 430 + +layout(location = 0) in vec4 position; +layout(location = 1) in vec4 vert_color0; +layout(location = 2) in vec4 vert_color1; +layout(location = 0) out vec4 frag_color; + +void main() +{ + gl_Position = position; + frag_color = vert_color0 + vert_color1; +} +END + +SHADER fragment frag_shader GLSL +#version 430 + +layout(location = 0) in vec4 frag_color; +layout(location = 0) out vec4 final_color; + +void main() +{ + final_color = frag_color; +} +END + +BUFFER position_buf DATA_TYPE R8G8_SNORM DATA +-128 -128 + 127 127 +-128 127 +-128 -128 + 127 127 + 127 -128 +END + +BUFFER vert_color DATA_TYPE R8G8B8A8_UNORM DATA +255 0 0 255 +255 0 0 255 +255 0 0 255 +255 0 0 255 +255 0 0 255 +255 0 0 255 + + 0 255 0 255 + 0 255 0 255 + 0 255 0 255 + 0 255 0 255 + 0 255 0 255 + 0 255 0 255 +END + +BUFFER framebuffer FORMAT B8G8R8A8_UNORM + +PIPELINE graphics pipeline + ATTACH vtex_shader + ATTACH frag_shader + + VERTEX_DATA position_buf LOCATION 0 + VERTEX_DATA vert_color LOCATION 1 + VERTEX_DATA vert_color LOCATION 2 OFFSET 24 + + BIND BUFFER framebuffer AS color LOCATION 0 +END + +CLEAR pipeline + +RUN pipeline DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6 +EXPECT framebuffer IDX 0 0 SIZE 250 250 EQ_RGBA 255 255 0 255 -- cgit v1.2.3 From 0db8af9f6be1f7abb8030eaa593409d74476133b Mon Sep 17 00:00:00 2001 From: asuonpaa <34128694+asuonpaa@users.noreply.github.com> Date: Thu, 28 Jan 2021 14:25:36 +0200 Subject: Make room for stencil data in host buffer (#941) When copying a D24_UNORM_S8_UINT depth/stencil buffer to or from the host, the depth and stencil data must be copied separately. This change adds extra space to the end of the Amber host buffer for the stencil data. --- src/vulkan/transfer_image.cc | 9 +- tests/cases/draw_rectangles_depth_test_d24s8.amber | 135 +++++++++++++++++++++ tests/cases/draw_rectangles_depth_test_x8d24.amber | 135 +++++++++++++++++++++ tests/run_tests.py | 3 + 4 files changed, 281 insertions(+), 1 deletion(-) create mode 100644 tests/cases/draw_rectangles_depth_test_d24s8.amber create mode 100644 tests/cases/draw_rectangles_depth_test_x8d24.amber diff --git a/src/vulkan/transfer_image.cc b/src/vulkan/transfer_image.cc index fcbbff4..545549d 100644 --- a/src/vulkan/transfer_image.cc +++ b/src/vulkan/transfer_image.cc @@ -77,7 +77,14 @@ TransferImage::TransferImage(Device* device, uint32_t base_mip_level, uint32_t used_mip_levels, uint32_t samples) - : Resource(device, x * y * z * format.SizeInBytes()), + : Resource( + device, + x * y * z * + (format.SizeInBytes() + + // D24_UNORM_S8_UINT requires 32bit component for depth when + // performing buffer copies. Reserve extra room to handle that. + (format.GetFormatType() == FormatType::kD24_UNORM_S8_UINT ? 1 + : 0))), image_info_(kDefaultImageInfo), aspect_(aspect), mip_levels_(mip_levels), diff --git a/tests/cases/draw_rectangles_depth_test_d24s8.amber b/tests/cases/draw_rectangles_depth_test_d24s8.amber new file mode 100644 index 0000000..75747a2 --- /dev/null +++ b/tests/cases/draw_rectangles_depth_test_d24s8.amber @@ -0,0 +1,135 @@ +#!amber +# +# Copyright 2021 The Amber Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SHADER vertex vert_shader GLSL +#version 430 + +layout(location = 0) in vec4 position; +layout(location = 0) out vec4 frag_color; + +layout(set = 0, binding = 0) readonly buffer block1 { + vec4 in_color; + float depth; +}; + +void main() { + gl_Position = vec4(position.xy, depth, 1.0); + frag_color = in_color; +} +END + +SHADER fragment frag_shader GLSL +#version 430 + +layout(location = 0) in vec4 frag_color; +layout(location = 0) out vec4 final_color; + +void main() { + final_color = frag_color; +} +END + +SHADER vertex vert_shader_tex GLSL +#version 430 +layout(location = 0) in vec4 position; +layout(location = 1) in vec2 texcoords_in; +layout(location = 0) out vec2 texcoords_out; +void main() { + gl_Position = position; + texcoords_out = texcoords_in; +} +END + +SHADER fragment frag_shader_tex GLSL +#version 430 +layout(location = 0) in vec2 texcoords_in; +layout(location = 0) out vec4 color_out; +uniform layout(set=0, binding=0) sampler2D tex_sampler; +void main() { + float f = texture(tex_sampler, texcoords_in).r; + color_out = vec4(f, f, f, 1); +} +END + +BUFFER data_buf1 DATA_TYPE float DATA 1.0 0.0 0.0 1.0 0.3 END +BUFFER data_buf2 DATA_TYPE float DATA 0.0 1.0 0.0 1.0 0.5 END + +BUFFER position DATA_TYPE vec2 DATA +-1.0 -1.0 + 1.0 -1.0 + 1.0 1.0 +-1.0 1.0 +END +BUFFER texcoords DATA_TYPE vec2 DATA +0.0 0.0 +1.0 0.0 +1.0 1.0 +0.0 1.0 +END + +BUFFER framebuffer FORMAT B8G8R8A8_UNORM +BUFFER ddump FORMAT B8G8R8A8_UNORM +BUFFER depthstencil FORMAT D24_UNORM_S8_UINT + +SAMPLER sampler + +PIPELINE graphics pipeline1 + ATTACH vert_shader + ATTACH frag_shader + + FRAMEBUFFER_SIZE 256 256 + BIND BUFFER framebuffer AS color LOCATION 0 + BIND BUFFER depthstencil AS depth_stencil + BIND BUFFER data_buf1 AS storage DESCRIPTOR_SET 0 BINDING 0 + + DEPTH + TEST on + WRITE on + COMPARE_OP less + CLAMP off + BOUNDS min 0.0 max 1.0 + BIAS constant 0.0 clamp 0.0 slope 0.0 + END +END + +DERIVE_PIPELINE pipeline2 FROM pipeline1 + BIND BUFFER data_buf2 AS storage DESCRIPTOR_SET 0 BINDING 0 +END + +PIPELINE graphics depthdump + ATTACH vert_shader_tex + ATTACH frag_shader_tex + BIND BUFFER depthstencil AS combined_image_sampler SAMPLER sampler DESCRIPTOR_SET 0 BINDING 0 + VERTEX_DATA position LOCATION 0 + VERTEX_DATA texcoords LOCATION 1 + FRAMEBUFFER_SIZE 256 256 + BIND BUFFER ddump AS color LOCATION 0 +END + +CLEAR_DEPTH pipeline1 1.0 +CLEAR_COLOR pipeline1 255 255 255 255 +CLEAR pipeline1 +RUN pipeline1 DRAW_RECT POS 0 0 SIZE 200 200 +RUN pipeline2 DRAW_RECT POS 56 56 SIZE 200 200 +RUN depthdump DRAW_ARRAY AS TRIANGLE_FAN START_IDX 0 COUNT 4 + +EXPECT framebuffer IDX 0 0 SIZE 1 1 EQ_RGBA 255 0 0 255 +EXPECT framebuffer IDX 128 128 SIZE 1 1 EQ_RGBA 255 0 0 255 +EXPECT framebuffer IDX 255 255 SIZE 1 1 EQ_RGBA 0 255 0 255 +EXPECT ddump IDX 0 0 SIZE 1 1 EQ_RGBA 76 76 76 255 TOLERANCE 5% 5% 5% 0 +EXPECT ddump IDX 255 0 SIZE 1 1 EQ_RGBA 255 255 255 255 TOLERANCE 5% 5% 5% 0 +EXPECT ddump IDX 0 255 SIZE 1 1 EQ_RGBA 255 255 255 255 TOLERANCE 5% 5% 5% 0 +EXPECT ddump IDX 255 255 SIZE 1 1 EQ_RGBA 128 128 128 255 TOLERANCE 5% 5% 5% 0 diff --git a/tests/cases/draw_rectangles_depth_test_x8d24.amber b/tests/cases/draw_rectangles_depth_test_x8d24.amber new file mode 100644 index 0000000..b46bb64 --- /dev/null +++ b/tests/cases/draw_rectangles_depth_test_x8d24.amber @@ -0,0 +1,135 @@ +#!amber +# +# Copyright 2021 The Amber Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SHADER vertex vert_shader GLSL +#version 430 + +layout(location = 0) in vec4 position; +layout(location = 0) out vec4 frag_color; + +layout(set = 0, binding = 0) readonly buffer block1 { + vec4 in_color; + float depth; +}; + +void main() { + gl_Position = vec4(position.xy, depth, 1.0); + frag_color = in_color; +} +END + +SHADER fragment frag_shader GLSL +#version 430 + +layout(location = 0) in vec4 frag_color; +layout(location = 0) out vec4 final_color; + +void main() { + final_color = frag_color; +} +END + +SHADER vertex vert_shader_tex GLSL +#version 430 +layout(location = 0) in vec4 position; +layout(location = 1) in vec2 texcoords_in; +layout(location = 0) out vec2 texcoords_out; +void main() { + gl_Position = position; + texcoords_out = texcoords_in; +} +END + +SHADER fragment frag_shader_tex GLSL +#version 430 +layout(location = 0) in vec2 texcoords_in; +layout(location = 0) out vec4 color_out; +uniform layout(set=0, binding=0) sampler2D tex_sampler; +void main() { + float f = texture(tex_sampler, texcoords_in).r; + color_out = vec4(f, f, f, 1); +} +END + +BUFFER data_buf1 DATA_TYPE float DATA 1.0 0.0 0.0 1.0 0.3 END +BUFFER data_buf2 DATA_TYPE float DATA 0.0 1.0 0.0 1.0 0.5 END + +BUFFER position DATA_TYPE vec2 DATA +-1.0 -1.0 + 1.0 -1.0 + 1.0 1.0 +-1.0 1.0 +END +BUFFER texcoords DATA_TYPE vec2 DATA +0.0 0.0 +1.0 0.0 +1.0 1.0 +0.0 1.0 +END + +BUFFER framebuffer FORMAT B8G8R8A8_UNORM +BUFFER ddump FORMAT B8G8R8A8_UNORM +BUFFER depthstencil FORMAT X8_D24_UNORM_PACK32 + +SAMPLER sampler + +PIPELINE graphics pipeline1 + ATTACH vert_shader + ATTACH frag_shader + + FRAMEBUFFER_SIZE 256 256 + BIND BUFFER framebuffer AS color LOCATION 0 + BIND BUFFER depthstencil AS depth_stencil + BIND BUFFER data_buf1 AS storage DESCRIPTOR_SET 0 BINDING 0 + + DEPTH + TEST on + WRITE on + COMPARE_OP less + CLAMP off + BOUNDS min 0.0 max 1.0 + BIAS constant 0.0 clamp 0.0 slope 0.0 + END +END + +DERIVE_PIPELINE pipeline2 FROM pipeline1 + BIND BUFFER data_buf2 AS storage DESCRIPTOR_SET 0 BINDING 0 +END + +PIPELINE graphics depthdump + ATTACH vert_shader_tex + ATTACH frag_shader_tex + BIND BUFFER depthstencil AS combined_image_sampler SAMPLER sampler DESCRIPTOR_SET 0 BINDING 0 + VERTEX_DATA position LOCATION 0 + VERTEX_DATA texcoords LOCATION 1 + FRAMEBUFFER_SIZE 256 256 + BIND BUFFER ddump AS color LOCATION 0 +END + +CLEAR_DEPTH pipeline1 1.0 +CLEAR_COLOR pipeline1 255 255 255 255 +CLEAR pipeline1 +RUN pipeline1 DRAW_RECT POS 0 0 SIZE 200 200 +RUN pipeline2 DRAW_RECT POS 56 56 SIZE 200 200 +RUN depthdump DRAW_ARRAY AS TRIANGLE_FAN START_IDX 0 COUNT 4 + +EXPECT framebuffer IDX 0 0 SIZE 1 1 EQ_RGBA 255 0 0 255 +EXPECT framebuffer IDX 128 128 SIZE 1 1 EQ_RGBA 255 0 0 255 +EXPECT framebuffer IDX 255 255 SIZE 1 1 EQ_RGBA 0 255 0 255 +EXPECT ddump IDX 0 0 SIZE 1 1 EQ_RGBA 76 76 76 255 TOLERANCE 5% 5% 5% 0 +EXPECT ddump IDX 255 0 SIZE 1 1 EQ_RGBA 255 255 255 255 TOLERANCE 5% 5% 5% 0 +EXPECT ddump IDX 0 255 SIZE 1 1 EQ_RGBA 255 255 255 255 TOLERANCE 5% 5% 5% 0 +EXPECT ddump IDX 255 255 SIZE 1 1 EQ_RGBA 128 128 128 255 TOLERANCE 5% 5% 5% 0 diff --git a/tests/run_tests.py b/tests/run_tests.py index 26d9a54..1fb7eb6 100755 --- a/tests/run_tests.py +++ b/tests/run_tests.py @@ -93,6 +93,9 @@ SUPPRESSIONS_SWIFTSHADER = [ "debugger_hlsl_basic_vertex_with_legalization.amber", "debugger_hlsl_function_call.amber", "debugger_hlsl_shadowed_vars.amber", + # Unsupported depth/stencil formats + "draw_rectangles_depth_test_d24s8.amber", + "draw_rectangles_depth_test_x8d24.amber", ] OPENCL_CASES = [ -- cgit v1.2.3 From dabae26164714abf951c6815a2b4513260f7c6a4 Mon Sep 17 00:00:00 2001 From: asuonpaa <34128694+asuonpaa@users.noreply.github.com> Date: Sat, 20 Feb 2021 17:10:04 +0200 Subject: Add device API version checking for function pointer loading (#943) Functions from instance extensions promoted to core in a later Vulkan version should only be loaded if the physical device version >= the version. --- license-checker.cfg | 2 +- src/vulkan/device.cc | 12 ++++++--- src/vulkan/device.h | 5 ++-- src/vulkan/vk-funcs-1-0.inc | 65 ++++++++++++++++++++++++++++++++++++++++++++ src/vulkan/vk-funcs-1-1.inc | 1 + src/vulkan/vk-funcs.inc | 66 --------------------------------------------- tools/update_vk_wrappers.py | 64 ++++++++++++++++++++++--------------------- 7 files changed, 112 insertions(+), 103 deletions(-) create mode 100644 src/vulkan/vk-funcs-1-0.inc create mode 100644 src/vulkan/vk-funcs-1-1.inc delete mode 100644 src/vulkan/vk-funcs.inc diff --git a/license-checker.cfg b/license-checker.cfg index cc7e4dc..72a470b 100644 --- a/license-checker.cfg +++ b/license-checker.cfg @@ -31,7 +31,7 @@ "android_gradle/gradlew", "android_gradle/settings.gradle", "android_sample/assets/amber/*.spv", - "src/vulkan/vk-funcs.inc", + "src/vulkan/vk-funcs*.inc", "tests/cases/*.bin", "tests/cases/*.txt", "tools/amber-syntax.vim", diff --git a/src/vulkan/device.cc b/src/vulkan/device.cc index d43b367..22cd77a 100644 --- a/src/vulkan/device.cc +++ b/src/vulkan/device.cc @@ -385,7 +385,14 @@ Result Device::LoadVulkanPointers(PFN_vkGetInstanceProcAddr getInstanceProcAddr, if (delegate && delegate->LogGraphicsCalls()) delegate->Log("Loading Vulkan Pointers"); -#include "vk-wrappers.inc" +#include "vk-wrappers-1-0.inc" + + ptrs_.vkGetPhysicalDeviceProperties(physical_device_, + &physical_device_properties_); + + if (SupportsApiVersion(1, 1, 0)) { +#include "vk-wrappers-1-1.inc" + } return {}; } @@ -632,9 +639,6 @@ Result Device::Initialize( "required extensions"); } - ptrs_.vkGetPhysicalDeviceProperties(physical_device_, - &physical_device_properties_); - ptrs_.vkGetPhysicalDeviceMemoryProperties(physical_device_, &physical_memory_properties_); diff --git a/src/vulkan/device.h b/src/vulkan/device.h index f7796d1..8cd3ba1 100644 --- a/src/vulkan/device.h +++ b/src/vulkan/device.h @@ -30,7 +30,8 @@ namespace amber { namespace vulkan { struct VulkanPtrs { -#include "vk-wrappers.h" // NOLINT(build/include) +#include "vk-wrappers-1-0.h" // NOLINT(build/include) +#include "vk-wrappers-1-1.h" // NOLINT(build/include) }; /// Wrapper around a Vulkan Device object. @@ -71,7 +72,7 @@ class Device { const VkMemoryPropertyFlags flags) const; /// Returns true if the memory at |memory_type_index| is host accessible. bool IsMemoryHostAccessible(uint32_t memory_type_index) const; - /// Returns true if the memory at |memory_type_index| is host corherent. + /// Returns true if the memory at |memory_type_index| is host coherent. bool IsMemoryHostCoherent(uint32_t memory_type_index) const; /// Returns the pointers to the Vulkan API methods. diff --git a/src/vulkan/vk-funcs-1-0.inc b/src/vulkan/vk-funcs-1-0.inc new file mode 100644 index 0000000..22c37e8 --- /dev/null +++ b/src/vulkan/vk-funcs-1-0.inc @@ -0,0 +1,65 @@ +AMBER_VK_FUNC(vkAllocateCommandBuffers) +AMBER_VK_FUNC(vkAllocateDescriptorSets) +AMBER_VK_FUNC(vkAllocateMemory) +AMBER_VK_FUNC(vkBeginCommandBuffer) +AMBER_VK_FUNC(vkBindBufferMemory) +AMBER_VK_FUNC(vkBindImageMemory) +AMBER_VK_FUNC(vkCmdBeginRenderPass) +AMBER_VK_FUNC(vkCmdBindDescriptorSets) +AMBER_VK_FUNC(vkCmdBindIndexBuffer) +AMBER_VK_FUNC(vkCmdBindPipeline) +AMBER_VK_FUNC(vkCmdBindVertexBuffers) +AMBER_VK_FUNC(vkCmdClearAttachments) +AMBER_VK_FUNC(vkCmdCopyBuffer) +AMBER_VK_FUNC(vkCmdCopyBufferToImage) +AMBER_VK_FUNC(vkCmdCopyImageToBuffer) +AMBER_VK_FUNC(vkCmdDispatch) +AMBER_VK_FUNC(vkCmdDraw) +AMBER_VK_FUNC(vkCmdDrawIndexed) +AMBER_VK_FUNC(vkCmdEndRenderPass) +AMBER_VK_FUNC(vkCmdPipelineBarrier) +AMBER_VK_FUNC(vkCmdPushConstants) +AMBER_VK_FUNC(vkCreateBuffer) +AMBER_VK_FUNC(vkCreateBufferView) +AMBER_VK_FUNC(vkCreateCommandPool) +AMBER_VK_FUNC(vkCreateComputePipelines) +AMBER_VK_FUNC(vkCreateDescriptorPool) +AMBER_VK_FUNC(vkCreateDescriptorSetLayout) +AMBER_VK_FUNC(vkCreateFence) +AMBER_VK_FUNC(vkCreateFramebuffer) +AMBER_VK_FUNC(vkCreateGraphicsPipelines) +AMBER_VK_FUNC(vkCreateImage) +AMBER_VK_FUNC(vkCreateImageView) +AMBER_VK_FUNC(vkCreatePipelineLayout) +AMBER_VK_FUNC(vkCreateRenderPass) +AMBER_VK_FUNC(vkCreateSampler) +AMBER_VK_FUNC(vkCreateShaderModule) +AMBER_VK_FUNC(vkDestroyBuffer) +AMBER_VK_FUNC(vkDestroyBufferView) +AMBER_VK_FUNC(vkDestroyCommandPool) +AMBER_VK_FUNC(vkDestroyDescriptorPool) +AMBER_VK_FUNC(vkDestroyDescriptorSetLayout) +AMBER_VK_FUNC(vkDestroyFence) +AMBER_VK_FUNC(vkDestroyFramebuffer) +AMBER_VK_FUNC(vkDestroyImage) +AMBER_VK_FUNC(vkDestroyImageView) +AMBER_VK_FUNC(vkDestroyPipeline) +AMBER_VK_FUNC(vkDestroyPipelineLayout) +AMBER_VK_FUNC(vkDestroyRenderPass) +AMBER_VK_FUNC(vkDestroySampler) +AMBER_VK_FUNC(vkDestroyShaderModule) +AMBER_VK_FUNC(vkEndCommandBuffer) +AMBER_VK_FUNC(vkFreeCommandBuffers) +AMBER_VK_FUNC(vkFreeMemory) +AMBER_VK_FUNC(vkGetBufferMemoryRequirements) +AMBER_VK_FUNC(vkGetImageMemoryRequirements) +AMBER_VK_FUNC(vkGetPhysicalDeviceFormatProperties) +AMBER_VK_FUNC(vkGetPhysicalDeviceMemoryProperties) +AMBER_VK_FUNC(vkGetPhysicalDeviceProperties) +AMBER_VK_FUNC(vkMapMemory) +AMBER_VK_FUNC(vkQueueSubmit) +AMBER_VK_FUNC(vkResetCommandBuffer) +AMBER_VK_FUNC(vkResetFences) +AMBER_VK_FUNC(vkUnmapMemory) +AMBER_VK_FUNC(vkUpdateDescriptorSets) +AMBER_VK_FUNC(vkWaitForFences) diff --git a/src/vulkan/vk-funcs-1-1.inc b/src/vulkan/vk-funcs-1-1.inc new file mode 100644 index 0000000..7fca3c5 --- /dev/null +++ b/src/vulkan/vk-funcs-1-1.inc @@ -0,0 +1 @@ +AMBER_VK_FUNC(vkGetPhysicalDeviceProperties2) diff --git a/src/vulkan/vk-funcs.inc b/src/vulkan/vk-funcs.inc deleted file mode 100644 index fb7d3f6..0000000 --- a/src/vulkan/vk-funcs.inc +++ /dev/null @@ -1,66 +0,0 @@ -AMBER_VK_FUNC(vkAllocateCommandBuffers) -AMBER_VK_FUNC(vkAllocateDescriptorSets) -AMBER_VK_FUNC(vkAllocateMemory) -AMBER_VK_FUNC(vkBeginCommandBuffer) -AMBER_VK_FUNC(vkBindBufferMemory) -AMBER_VK_FUNC(vkBindImageMemory) -AMBER_VK_FUNC(vkCmdBeginRenderPass) -AMBER_VK_FUNC(vkCmdBindDescriptorSets) -AMBER_VK_FUNC(vkCmdBindIndexBuffer) -AMBER_VK_FUNC(vkCmdBindPipeline) -AMBER_VK_FUNC(vkCmdBindVertexBuffers) -AMBER_VK_FUNC(vkCmdClearAttachments) -AMBER_VK_FUNC(vkCmdCopyBuffer) -AMBER_VK_FUNC(vkCmdCopyBufferToImage) -AMBER_VK_FUNC(vkCmdCopyImageToBuffer) -AMBER_VK_FUNC(vkCmdDispatch) -AMBER_VK_FUNC(vkCmdDraw) -AMBER_VK_FUNC(vkCmdDrawIndexed) -AMBER_VK_FUNC(vkCmdEndRenderPass) -AMBER_VK_FUNC(vkCmdPipelineBarrier) -AMBER_VK_FUNC(vkCmdPushConstants) -AMBER_VK_FUNC(vkCreateBuffer) -AMBER_VK_FUNC(vkCreateBufferView) -AMBER_VK_FUNC(vkCreateCommandPool) -AMBER_VK_FUNC(vkCreateComputePipelines) -AMBER_VK_FUNC(vkCreateDescriptorPool) -AMBER_VK_FUNC(vkCreateDescriptorSetLayout) -AMBER_VK_FUNC(vkCreateFence) -AMBER_VK_FUNC(vkCreateFramebuffer) -AMBER_VK_FUNC(vkCreateGraphicsPipelines) -AMBER_VK_FUNC(vkCreateImage) -AMBER_VK_FUNC(vkCreateImageView) -AMBER_VK_FUNC(vkCreatePipelineLayout) -AMBER_VK_FUNC(vkCreateRenderPass) -AMBER_VK_FUNC(vkCreateSampler) -AMBER_VK_FUNC(vkCreateShaderModule) -AMBER_VK_FUNC(vkDestroyBuffer) -AMBER_VK_FUNC(vkDestroyBufferView) -AMBER_VK_FUNC(vkDestroyCommandPool) -AMBER_VK_FUNC(vkDestroyDescriptorPool) -AMBER_VK_FUNC(vkDestroyDescriptorSetLayout) -AMBER_VK_FUNC(vkDestroyFence) -AMBER_VK_FUNC(vkDestroyFramebuffer) -AMBER_VK_FUNC(vkDestroyImage) -AMBER_VK_FUNC(vkDestroyImageView) -AMBER_VK_FUNC(vkDestroyPipeline) -AMBER_VK_FUNC(vkDestroyPipelineLayout) -AMBER_VK_FUNC(vkDestroyRenderPass) -AMBER_VK_FUNC(vkDestroySampler) -AMBER_VK_FUNC(vkDestroyShaderModule) -AMBER_VK_FUNC(vkEndCommandBuffer) -AMBER_VK_FUNC(vkFreeCommandBuffers) -AMBER_VK_FUNC(vkFreeMemory) -AMBER_VK_FUNC(vkGetBufferMemoryRequirements) -AMBER_VK_FUNC(vkGetImageMemoryRequirements) -AMBER_VK_FUNC(vkGetPhysicalDeviceFormatProperties) -AMBER_VK_FUNC(vkGetPhysicalDeviceMemoryProperties) -AMBER_VK_FUNC(vkGetPhysicalDeviceProperties) -AMBER_VK_FUNC(vkGetPhysicalDeviceProperties2) -AMBER_VK_FUNC(vkMapMemory) -AMBER_VK_FUNC(vkQueueSubmit) -AMBER_VK_FUNC(vkResetCommandBuffer) -AMBER_VK_FUNC(vkResetFences) -AMBER_VK_FUNC(vkUnmapMemory) -AMBER_VK_FUNC(vkUpdateDescriptorSets) -AMBER_VK_FUNC(vkWaitForFences) diff --git a/tools/update_vk_wrappers.py b/tools/update_vk_wrappers.py index 9acfc8e..0fc9f87 100755 --- a/tools/update_vk_wrappers.py +++ b/tools/update_vk_wrappers.py @@ -186,36 +186,40 @@ def main(): outdir = sys.argv[1] srcdir = sys.argv[2] - vkfile = os.path.join(srcdir, 'third_party', 'vulkan-headers', 'registry', 'vk.xml') - incfile = os.path.join(srcdir, 'src', 'vulkan', 'vk-funcs.inc') - - data = read_inc(incfile) - - wrapper_content = '' - header_content = '' - if os.path.isfile(vkfile): - vk_data = read_vk(vkfile) - wrapper_content = gen_wrappers(data, vk_data) - header_content = gen_headers(data, vk_data) - else: - wrapper_content = gen_direct(data) - header_content = gen_direct_headers(data) - - outfile = os.path.join(outdir, 'vk-wrappers.inc') - if os.path.isfile(outfile): - with open(outfile, 'r') as f: - if wrapper_content == f.read(): - return - with open(outfile, 'w') as f: - f.write(wrapper_content) - - hdrfile = os.path.join(outdir, 'vk-wrappers.h') - if os.path.isfile(hdrfile): - with open(hdrfile, 'r') as f: - if header_content == f.read(): - return - with open(hdrfile, 'w') as f: - f.write(header_content) + vulkan_versions = ("1-0", "1-1") + + for vulkan_version in vulkan_versions: + + vkfile = os.path.join(srcdir, 'third_party', 'vulkan-headers', 'registry', 'vk.xml') + incfile = os.path.join(srcdir, 'src', 'vulkan', 'vk-funcs-%s.inc' % vulkan_version) + + data = read_inc(incfile) + + wrapper_content = '' + header_content = '' + if os.path.isfile(vkfile): + vk_data = read_vk(vkfile) + wrapper_content = gen_wrappers(data, vk_data) + header_content = gen_headers(data, vk_data) + else: + wrapper_content = gen_direct(data) + header_content = gen_direct_headers(data) + + outfile = os.path.join(outdir, 'vk-wrappers-%s.inc' % vulkan_version) + if os.path.isfile(outfile): + with open(outfile, 'r') as f: + if wrapper_content == f.read(): + return + with open(outfile, 'w') as f: + f.write(wrapper_content) + + hdrfile = os.path.join(outdir, 'vk-wrappers-%s.h' % vulkan_version) + if os.path.isfile(hdrfile): + with open(hdrfile, 'r') as f: + if header_content == f.read(): + return + with open(hdrfile, 'w') as f: + f.write(header_content) if __name__ == '__main__': -- cgit v1.2.3