aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-03-18 01:01:55 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-03-18 01:01:55 +0000
commit8ff7e932e7dde13dc33bb7d72dcd968c45f790cd (patch)
treebdf409c89e96d95b1a90258eb449dfaf7c450239
parent208f0fbf65170ac39baa93d448ccf965baad4a53 (diff)
parent5dc1c60fdeb9a7a3e2d8d3c933a59cb106dd3898 (diff)
downloadamber-android12-d1-release.tar.gz
Change-Id: I1ed22cf50124489143a7befeb43e2e235987d029
-rw-r--r--Android.bp7
-rw-r--r--DEPS24
-rw-r--r--docs/amber_script.md31
-rw-r--r--include/amber/shader_info.h2
-rw-r--r--license-checker.cfg3
-rw-r--r--samples/amber.cc1
-rw-r--r--src/amberscript/parser.cc84
-rw-r--r--src/amberscript/parser_attach_test.cc24
-rw-r--r--src/amberscript/parser_bind_test.cc401
-rw-r--r--src/amberscript/parser_buffer_test.cc34
-rw-r--r--src/amberscript/parser_clear_stencil_test.cc2
-rw-r--r--src/amberscript/parser_expect_test.cc62
-rw-r--r--src/amberscript/parser_framebuffer_test.cc8
-rw-r--r--src/amberscript/parser_image_test.cc82
-rw-r--r--src/amberscript/parser_pipeline_test.cc32
-rw-r--r--src/amberscript/parser_run_test.cc4
-rw-r--r--src/amberscript/parser_stencil_test.cc12
-rw-r--r--src/buffer_test.cc44
-rw-r--r--src/cast_hash.h2
-rw-r--r--src/clspv_helper.cc10
-rw-r--r--src/command.h4
-rw-r--r--src/descriptor_set_and_binding_parser_test.cc16
-rw-r--r--src/float16_helper_test.cc1
-rw-r--r--src/format_test.cc356
-rw-r--r--src/image.h2
-rw-r--r--src/pipeline.cc17
-rw-r--r--src/pipeline.h16
-rw-r--r--src/pipeline_test.cc10
-rw-r--r--src/script.cc10
-rw-r--r--src/script_test.cc2
-rw-r--r--src/shader_compiler_test.cc18
-rw-r--r--src/tokenizer_test.cc6
-rw-r--r--src/type_parser_test.cc2
-rw-r--r--src/type_test.cc18
-rw-r--r--src/vkscript/parser.cc4
-rw-r--r--src/vkscript/parser_test.cc12
-rw-r--r--src/vulkan/buffer_backed_descriptor.cc48
-rw-r--r--src/vulkan/buffer_backed_descriptor.h5
-rw-r--r--src/vulkan/buffer_descriptor.cc1
-rw-r--r--src/vulkan/device.cc12
-rw-r--r--src/vulkan/device.h5
-rw-r--r--src/vulkan/engine_vulkan.cc11
-rw-r--r--src/vulkan/engine_vulkan_debugger.cc3
-rw-r--r--src/vulkan/image_descriptor.cc14
-rw-r--r--src/vulkan/pipeline.cc4
-rw-r--r--src/vulkan/sampler_descriptor.cc1
-rw-r--r--src/vulkan/transfer_buffer.cc1
-rw-r--r--src/vulkan/transfer_image.cc15
-rw-r--r--src/vulkan/vertex_buffer.cc31
-rw-r--r--src/vulkan/vertex_buffer.h9
-rw-r--r--src/vulkan/vertex_buffer_test.cc3
-rw-r--r--src/vulkan/vk-funcs-1-0.inc (renamed from src/vulkan/vk-funcs.inc)1
-rw-r--r--src/vulkan/vk-funcs-1-1.inc1
-rw-r--r--tests/cases/debugger_hlsl_basic_compute.amber3
-rw-r--r--tests/cases/debugger_hlsl_basic_fragment_with_legalization.amber102
-rw-r--r--tests/cases/debugger_hlsl_basic_vertex_with_legalization.amber128
-rw-r--r--tests/cases/debugger_hlsl_function_call.amber212
-rw-r--r--tests/cases/debugger_hlsl_shadowed_vars.amber6
-rw-r--r--tests/cases/draw_rectangles_depth_test_d24s8.amber135
-rw-r--r--tests/cases/draw_rectangles_depth_test_x8d24.amber135
-rw-r--r--tests/cases/draw_triangle_list_format.amber91
-rw-r--r--tests/cases/draw_triangle_list_offset.amber147
-rw-r--r--tests/cases/draw_triangle_list_stride.amber106
-rw-r--r--tests/cases/image_data.amber92
-rw-r--r--tests/cases/multiple_samplers.amber126
-rw-r--r--tests/cases/vertex_data_two_locations.amber84
-rwxr-xr-xtests/run_tests.py15
-rwxr-xr-xtools/roll-all2
-rwxr-xr-xtools/update_vk_wrappers.py64
69 files changed, 2490 insertions, 486 deletions
diff --git a/Android.bp b/Android.bp
index e216ebd..45d03c4 100644
--- a/Android.bp
+++ b/Android.bp
@@ -17,16 +17,15 @@ license {
],
license_text: [
"LICENSE",
- "license-checker.cfg",
],
}
genrule {
name: "deqp_amber_gen_vk_wrappers",
- out: ["vk-wrappers.inc", "vk-wrappers.h"],
- srcs: ["src/vulkan/vk-funcs.inc"],
+ out: ["vk-wrappers-1-0.inc", "vk-wrappers-1-0.h", "vk-wrappers-1-1.inc", "vk-wrappers-1-1.h"],
+ srcs: ["src/vulkan/vk-funcs-1-0.inc", "src/vulkan/vk-funcs-1-1.inc"],
tool_files: ["tools/update_vk_wrappers.py"],
- cmd: "$(location) $(genDir) $$(dirname $(location src/vulkan/vk-funcs.inc))/../..",
+ cmd: "$(location) $(genDir) $$(dirname $(location src/vulkan/vk-funcs-1-0.inc))/../..",
}
cc_library_static {
diff --git a/DEPS b/DEPS
index 20fb76d..ff7507f 100644
--- a/DEPS
+++ b/DEPS
@@ -9,22 +9,22 @@ vars = {
'nlohmann_git': 'https://github.com/nlohmann',
'swiftshader_git': 'https://swiftshader.googlesource.com',
- 'clspv_llvm_revision': 'b91a236ee1c3e9fa068df058164385732cb46bba',
- 'clspv_revision': '3a11614ee40907c6f9edd99bd7d23b123111e947',
+ 'clspv_llvm_revision': '7e30989dabce9ddbca0cbad7a8f25fb4e756d334',
+ 'clspv_revision': 'e0406e7053d1bb46b4bbeb57f0f2bbfca32f5612',
'cppdap_revision': '1fd23dda91e01550be1a421de307e6fedb2035a9',
'cpplint_revision': '26470f9ccb354ff2f6d098f831271a1833701b28',
- 'dxc_revision': '141a5c2ec5f77733f301f9f332bc3b0aefbc2c62',
- 'glslang_revision': 'f4f1d8a352ca1908943aea2ad8c54b39b4879080',
- 'googletest_revision': '3c95bf552405fd0cc63cea0ca2f6c4cd89c8d356',
+ 'dxc_revision': '489c2e4d32417cd6693db5673ab071d82e1f5974',
+ 'glslang_revision': '7f6559d2802d0653541060f0909e33d137b9c8ba',
+ 'googletest_revision': '0555b0eacbc56df1fd762c6aa87bb84be9e4ce7e',
'json_revision': '350ff4f7ced7c4117eae2fb93df02823c8021fcb',
'lodepng_revision': '7fdcc96a5e5864eee72911c3ca79b1d9f0d12292',
- 'shaderc_revision': '011139094ec790ff7f32ea2d80286255fc9ed18b',
- 'spirv_headers_revision': 'c43a43c7cc3af55910b9bec2a71e3e8a622443cf',
- 'spirv_tools_revision': '7e1825a59619f3decd9b46f25d457b1a8878ca89',
- 'swiftshader_revision': 'df17a76102dfabb3f1bd6e51449cece9f77b45e3',
- 'vulkan_headers_revision': '320af06cbdd29848e1d7100d9b8e4e517db1dfd5',
- 'vulkan_loader_revision': '970c132746b1d8bc2baeeb2bcdb5edf490b47f94',
- 'vulkan_validationlayers_revision': '8c5a10d952f4122898205854b61f9e8de46d2363',
+ 'shaderc_revision': '88f9156d7f6a2a30baed1ace196faa3bc5eccc05',
+ 'spirv_headers_revision': '5ab5c96198f30804a6a29961b8905f292a8ae600',
+ 'spirv_tools_revision': '1f2fcddd3963b9c29bf360daf7656c5977c2aadd',
+ 'swiftshader_revision': '04515da400d5fbc22d852af1369c4d46bd54991e',
+ 'vulkan_headers_revision': '11c6670b4a4f766ed4f1e777d1b3c3dc082dfa5f',
+ 'vulkan_loader_revision': 'be6ccb9ecaf77dfef59246a1e8502e99c8e1a511',
+ 'vulkan_validationlayers_revision': '0cb8cc8cfcb2b86a767c9516ac2d62edb4e38ebe',
}
deps = {
diff --git a/docs/amber_script.md b/docs/amber_script.md
index 6dd2443..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_ \
@@ -287,6 +284,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}
@@ -587,9 +592,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/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<std::string> optimizations;
+ /// Target environment for the shader compilation.
+ std::string target_env;
/// The shader SPIR-V if it was compiled by Amber
std::vector<uint32_t> shader_data;
};
diff --git a/license-checker.cfg b/license-checker.cfg
index 7b6ed30..72a470b 100644
--- a/license-checker.cfg
+++ b/license-checker.cfg
@@ -1,5 +1,6 @@
{
"licenses": [
+ "Apache-2.0",
"Apache-2.0-Header"
],
"paths": [
@@ -30,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/samples/amber.cc b/samples/amber.cc
index 0ea0e00..d037ba4 100644
--- a/samples/amber.cc
+++ b/samples/amber.cc
@@ -15,6 +15,7 @@
#include "amber/amber.h"
#include <stdio.h>
+
#include <algorithm>
#include <cassert>
#include <cstdio>
diff --git a/src/amberscript/parser.cc b/src/amberscript/parser.cc
index 1a5a197..50760f0 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<Format>(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;
@@ -1897,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();
@@ -2005,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;
@@ -2854,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());
}
@@ -2865,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_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..64f3948 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);
}
@@ -730,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) {
@@ -841,7 +858,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) {
@@ -871,16 +889,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);
}
@@ -926,6 +944,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
@@ -1312,9 +1637,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<FormatComponentType>(i));
}
@@ -950,12 +950,12 @@ END)";
const auto* data = buffer->GetValues<uint8_t>();
EXPECT_FLOAT_EQ(1.f, *reinterpret_cast<const float*>(data + 0));
- EXPECT_EQ(64,
+ EXPECT_EQ(64u,
*reinterpret_cast<const uint32_t*>(data + 4 /* sizeof(float) */));
- EXPECT_EQ(128,
+ EXPECT_EQ(128u,
*reinterpret_cast<const uint32_t*>(data + 16 /* 8 round -> 16 */));
- EXPECT_EQ(220, *reinterpret_cast<const uint32_t*>(
- data + 20 /* 8 round -> 16 + 4 */));
+ EXPECT_EQ(220u, *reinterpret_cast<const uint32_t*>(
+ data + 20 /* 8 round -> 16 + 4 */));
}
TEST_F(AmberScriptParserTest, BufferWithStructStd430) {
@@ -998,9 +998,9 @@ END)";
const auto* data = buffer->GetValues<uint8_t>();
EXPECT_FLOAT_EQ(1.f, *reinterpret_cast<const float*>(data + 0));
- EXPECT_EQ(64, *reinterpret_cast<const uint32_t*>(data + 4));
- EXPECT_EQ(128, *reinterpret_cast<const uint32_t*>(data + 8));
- EXPECT_EQ(220, *reinterpret_cast<const uint32_t*>(data + 12));
+ EXPECT_EQ(64u, *reinterpret_cast<const uint32_t*>(data + 4));
+ EXPECT_EQ(128u, *reinterpret_cast<const uint32_t*>(data + 8));
+ EXPECT_EQ(220u, *reinterpret_cast<const uint32_t*>(data + 12));
}
TEST_F(AmberScriptParserTest, BufferWithStructAndPaddingStd430) {
@@ -1043,9 +1043,9 @@ END)";
const auto* data = buffer->GetValues<uint8_t>();
EXPECT_FLOAT_EQ(1.f, *reinterpret_cast<const float*>(data + 8));
- EXPECT_EQ(64, *reinterpret_cast<const uint32_t*>(data + 16));
- EXPECT_EQ(128, *reinterpret_cast<const uint32_t*>(data + 28));
- EXPECT_EQ(220, *reinterpret_cast<const uint32_t*>(data + 36));
+ EXPECT_EQ(64u, *reinterpret_cast<const uint32_t*>(data + 16));
+ EXPECT_EQ(128u, *reinterpret_cast<const uint32_t*>(data + 28));
+ EXPECT_EQ(220u, *reinterpret_cast<const uint32_t*>(data + 36));
}
TEST_F(AmberScriptParserTest, BufferWithStructPartialInitialization) {
@@ -1101,9 +1101,9 @@ END)";
const auto* data = buffer->GetValues<uint8_t>();
EXPECT_FLOAT_EQ(1.f, *reinterpret_cast<const float*>(data + 0));
- EXPECT_FLOAT_EQ(64, *reinterpret_cast<const float*>(data + 16));
- EXPECT_FLOAT_EQ(128, *reinterpret_cast<const float*>(data + 20));
- EXPECT_FLOAT_EQ(220, *reinterpret_cast<const float*>(data + 24));
+ EXPECT_FLOAT_EQ(64u, *reinterpret_cast<const float*>(data + 16));
+ EXPECT_FLOAT_EQ(128u, *reinterpret_cast<const float*>(data + 20));
+ EXPECT_FLOAT_EQ(220u, *reinterpret_cast<const float*>(data + 24));
}
TEST_F(AmberScriptParserTest, InvalidBufferWidth) {
@@ -1178,9 +1178,9 @@ BUFFER buf DATA_TYPE vec4<float> 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..b7e8c59 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();
@@ -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<double>(0), probe->GetValues()[0].AsDouble());
+ EXPECT_EQ(static_cast<double>(1), probe->GetValues()[1].AsDouble());
+ EXPECT_EQ(static_cast<double>(2), probe->GetValues()[2].AsDouble());
+ EXPECT_EQ(static_cast<double>(3), probe->GetValues()[3].AsDouble());
+}
+
} // namespace amberscript
} // namespace amber
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..53c8ad7 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,66 @@ 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());
+}
+
+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<float>();
+ std::vector<float> 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
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 <limits>
#include <utility>
-#include <limits>
#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<uint64_t> 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<uint64_t> 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<uint64_t> 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<uint16_t>();
EXPECT_EQ(float16::FloatToHexFloat16(2.8f), v[0]);
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 <cstddef>
+
namespace amber {
/// A hash implementation for types that can trivially be up-cast to a size_t.
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/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/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<type::Struct>();
@@ -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<type::Struct>();
@@ -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<type::Struct>();
@@ -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<type::Struct>();
@@ -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<type::Struct>();
@@ -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<type::Struct>();
@@ -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<type::Struct>();
@@ -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<type::Struct>();
@@ -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<type::Struct>();
@@ -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<type::Struct>();
@@ -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/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 <cstdint>
+
namespace amber {
enum class ImageDimension : int8_t { kUnknown = -1, k1D = 0, k2D = 1, k3D = 2 };
diff --git a/src/pipeline.cc b/src/pipeline.cc
index 7df2401..55c6bae 100644
--- a/src/pipeline.cc
+++ b/src/pipeline.cc
@@ -423,18 +423,22 @@ 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");
- if (vtex.buffer == buf)
- return Result("vertex buffer may only be bound to a PIPELINE once");
}
vertex_buffers_.push_back(BufferInfo{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 {};
}
@@ -521,6 +525,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,
@@ -1015,6 +1020,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..ec38a3a 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;
@@ -198,6 +199,10 @@ class Pipeline {
uint32_t arg_no = 0;
BufferType type = BufferType::kUnknown;
InputRate input_rate = InputRate::kVertex;
+ Format* format;
+ uint32_t offset = 0;
+ uint32_t stride = 0;
+ Sampler* sampler = nullptr;
};
/// Information on a sampler attached to the pipeline.
@@ -313,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<Buffer>();
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<Format>(int_type.get());
+ p.AddVertexBuffer(vtex_buf.get(), 1, InputRate::kVertex, int_fmt.get(), 5,
+ 10);
auto idx_buf = MakeUnique<Buffer>();
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/script.cc b/src/script.cc
index 5193aab..7d7483f 100644
--- a/src/script.cc
+++ b/src/script.cc
@@ -32,10 +32,11 @@ std::vector<ShaderInfo> 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<ShaderInfo> Script::GetShaderInfo() const {
shader->GetName(),
shader->GetData(),
{},
+ shader->GetTargetEnv(),
{}});
}
}
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.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/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<uint32_t>();
- 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/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<Resource*> GetResources() = 0;
uint32_t GetDescriptorCount() override {
return static_cast<uint32_t>(amber_buffers_.size());
}
const std::vector<Buffer*>& 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<Resource*> GetResources() = 0;
private:
std::vector<Buffer*> 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/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/engine_vulkan.cc b/src/vulkan/engine_vulkan.cc
index 0e65298..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<VertexBuffer>(device_.get());
info.vertex_buffer->SetData(static_cast<uint8_t>(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()) {
@@ -253,6 +255,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());
@@ -501,7 +504,8 @@ Result EngineVulkan::DoDrawRect(const DrawRectCommand* command) {
buf->SetData(std::move(values));
auto vertex_buffer = MakeUnique<VertexBuffer>(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
@@ -588,7 +592,8 @@ Result EngineVulkan::DoDrawGrid(const DrawGridCommand* command) {
buf->SetData(std::move(values));
auto vertex_buffer = MakeUnique<VertexBuffer>(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/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 <thread> // NOLINT(build/c++11)
#include <unordered_map>
-#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 e1e9535..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"
@@ -125,18 +126,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..e0b875c 100644
--- a/src/vulkan/pipeline.cc
+++ b/src/vulkan/pipeline.cc
@@ -320,8 +320,8 @@ Result Pipeline::AddBufferDescriptor(const BufferCommand* cmd) {
auto image_desc = MakeUnique<ImageDescriptor>(
cmd->GetBuffer(), desc_type, device_, cmd->GetBaseMipLevel(),
cmd->GetDescriptorSet(), cmd->GetBinding());
- if (cmd->IsSampledImage() || cmd->IsCombinedImageSampler())
- image_desc->SetAmberSampler(cmd->GetBuffer()->GetSampler());
+ if (cmd->IsCombinedImageSampler())
+ image_desc->SetAmberSampler(cmd->GetSampler());
descriptors.push_back(std::move(image_desc));
} else {
auto buffer_desc = MakeUnique<BufferDescriptor>(
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/src/vulkan/transfer_image.cc b/src/vulkan/transfer_image.cc
index 60bd6fd..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),
@@ -342,10 +349,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;
diff --git a/src/vulkan/vertex_buffer.cc b/src/vulkan/vertex_buffer.cc
index 409c0f1..7503681 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<uint32_t>(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);
@@ -57,23 +61,28 @@ void VertexBuffer::BindToCommandBuffer(CommandBuffer* command) {
std::vector<VkBuffer> buffers;
std::vector<VkDeviceSize> 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<uint32_t>(transfer_buffers_.size()), buffers.data(),
- offsets.data());
+ command->GetVkCommandBuffer(), 0, static_cast<uint32_t>(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<TransferBuffer>(device_, bytes, nullptr));
Result r = transfer_buffers_.back()->Initialize(
@@ -85,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 2837a9e..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 <map>
#include <memory>
#include <vector>
@@ -40,7 +41,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<VkVertexInputAttributeDescription>& GetVkVertexInputAttr()
const {
@@ -63,6 +69,7 @@ class VertexBuffer {
std::vector<Buffer*> data_;
std::vector<VkVertexInputBindingDescription> vertex_binding_desc_;
std::vector<VkVertexInputAttributeDescription> vertex_attr_desc_;
+ std::map<Buffer*, VkBuffer> buffer_to_vk_buffer_;
};
} // namespace vulkan
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/src/vulkan/vk-funcs.inc b/src/vulkan/vk-funcs-1-0.inc
index fb7d3f6..22c37e8 100644
--- a/src/vulkan/vk-funcs.inc
+++ b/src/vulkan/vk-funcs-1-0.inc
@@ -56,7 +56,6 @@ 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)
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/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<int> 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/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<float> DATA
+-1.0 -1.0
+ 1.0 -1.0
+ 1.0 1.0
+-1.0 1.0
+END
+BUFFER texcoords DATA_TYPE vec2<float> 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<float> DATA
+-1.0 -1.0
+ 1.0 -1.0
+ 1.0 1.0
+-1.0 1.0
+END
+BUFFER texcoords DATA_TYPE vec2<float> 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/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
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
+
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<float> DATA
+-0.75 -0.75
+ 0.75 -0.75
+ 0.75 0.75
+-0.75 0.75
+END
+BUFFER texcoords DATA_TYPE vec2<float> 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
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
diff --git a/tests/run_tests.py b/tests/run_tests.py
index 8898491..1fb7eb6 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 = [
@@ -85,6 +89,13 @@ 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",
+ # Unsupported depth/stencil formats
+ "draw_rectangles_depth_test_d24s8.amber",
+ "draw_rectangles_depth_test_x8d24.amber",
]
OPENCL_CASES = [
@@ -105,6 +116,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 = [
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
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__':