mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 00:17:03 +00:00
Implement texture_depth_multisampled_2d
Implemented for all readers and writers. Cleaned up some verbose code in sem::Function and the Inspector in the process. Fixed: tint:1032 Change-Id: Ia6f2f59e6d2e511c89160b97be990e8b7c9828d9 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/59664 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: David Neto <dneto@google.com> Reviewed-by: James Price <jrprice@google.com> Commit-Queue: Ben Clayton <bclayton@google.com> Auto-Submit: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Tint LUCI CQ
parent
d12379a405
commit
fd35aa8e47
@@ -29,6 +29,7 @@
|
||||
#include "src/ast/uint_literal.h"
|
||||
#include "src/sem/array.h"
|
||||
#include "src/sem/call.h"
|
||||
#include "src/sem/depth_multisampled_texture_type.h"
|
||||
#include "src/sem/f32_type.h"
|
||||
#include "src/sem/function.h"
|
||||
#include "src/sem/i32_type.h"
|
||||
@@ -319,27 +320,22 @@ std::vector<ResourceBinding> Inspector::GetResourceBindings(
|
||||
}
|
||||
|
||||
std::vector<ResourceBinding> result;
|
||||
|
||||
AppendResourceBindings(&result,
|
||||
GetUniformBufferResourceBindings(entry_point));
|
||||
AppendResourceBindings(&result,
|
||||
GetStorageBufferResourceBindings(entry_point));
|
||||
AppendResourceBindings(&result,
|
||||
GetReadOnlyStorageBufferResourceBindings(entry_point));
|
||||
AppendResourceBindings(&result, GetSamplerResourceBindings(entry_point));
|
||||
AppendResourceBindings(&result,
|
||||
GetComparisonSamplerResourceBindings(entry_point));
|
||||
AppendResourceBindings(&result,
|
||||
GetSampledTextureResourceBindings(entry_point));
|
||||
AppendResourceBindings(&result,
|
||||
GetMultisampledTextureResourceBindings(entry_point));
|
||||
AppendResourceBindings(
|
||||
&result, GetReadOnlyStorageTextureResourceBindings(entry_point));
|
||||
AppendResourceBindings(
|
||||
&result, GetWriteOnlyStorageTextureResourceBindings(entry_point));
|
||||
AppendResourceBindings(&result, GetDepthTextureResourceBindings(entry_point));
|
||||
AppendResourceBindings(&result,
|
||||
GetExternalTextureResourceBindings(entry_point));
|
||||
for (auto fn : {
|
||||
&Inspector::GetUniformBufferResourceBindings,
|
||||
&Inspector::GetStorageBufferResourceBindings,
|
||||
&Inspector::GetReadOnlyStorageBufferResourceBindings,
|
||||
&Inspector::GetSamplerResourceBindings,
|
||||
&Inspector::GetComparisonSamplerResourceBindings,
|
||||
&Inspector::GetSampledTextureResourceBindings,
|
||||
&Inspector::GetMultisampledTextureResourceBindings,
|
||||
&Inspector::GetReadOnlyStorageTextureResourceBindings,
|
||||
&Inspector::GetWriteOnlyStorageTextureResourceBindings,
|
||||
&Inspector::GetDepthTextureResourceBindings,
|
||||
&Inspector::GetDepthMultisampledTextureResourceBindings,
|
||||
&Inspector::GetExternalTextureResourceBindings,
|
||||
}) {
|
||||
AppendResourceBindings(&result, (this->*fn)(entry_point));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -465,8 +461,10 @@ Inspector::GetWriteOnlyStorageTextureResourceBindings(
|
||||
return GetStorageTextureResourceBindingsImpl(entry_point, false);
|
||||
}
|
||||
|
||||
std::vector<ResourceBinding> Inspector::GetDepthTextureResourceBindings(
|
||||
const std::string& entry_point) {
|
||||
std::vector<ResourceBinding> Inspector::GetTextureResourceBindings(
|
||||
const std::string& entry_point,
|
||||
const tint::TypeInfo& texture_type,
|
||||
ResourceBinding::ResourceType resource_type) {
|
||||
auto* func = FindEntryPointByName(entry_point);
|
||||
if (!func) {
|
||||
return {};
|
||||
@@ -474,18 +472,18 @@ std::vector<ResourceBinding> Inspector::GetDepthTextureResourceBindings(
|
||||
|
||||
std::vector<ResourceBinding> result;
|
||||
auto* func_sem = program_->Sem().Get(func);
|
||||
for (auto& ref : func_sem->ReferencedDepthTextureVariables()) {
|
||||
for (auto& ref : func_sem->ReferencedVariablesOfType(texture_type)) {
|
||||
auto* var = ref.first;
|
||||
auto binding_info = ref.second;
|
||||
|
||||
ResourceBinding entry;
|
||||
entry.resource_type = ResourceBinding::ResourceType::kDepthTexture;
|
||||
entry.resource_type = resource_type;
|
||||
entry.bind_group = binding_info.group->value();
|
||||
entry.binding = binding_info.binding->value();
|
||||
|
||||
auto* texture_type = var->Type()->UnwrapRef()->As<sem::Texture>();
|
||||
entry.dim = TypeTextureDimensionToResourceBindingTextureDimension(
|
||||
texture_type->dim());
|
||||
auto* tex = var->Type()->UnwrapRef()->As<sem::Texture>();
|
||||
entry.dim =
|
||||
TypeTextureDimensionToResourceBindingTextureDimension(tex->dim());
|
||||
|
||||
result.push_back(entry);
|
||||
}
|
||||
@@ -493,31 +491,26 @@ std::vector<ResourceBinding> Inspector::GetDepthTextureResourceBindings(
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<ResourceBinding> Inspector::GetDepthTextureResourceBindings(
|
||||
const std::string& entry_point) {
|
||||
return GetTextureResourceBindings(
|
||||
entry_point, TypeInfo::Of<sem::DepthTexture>(),
|
||||
ResourceBinding::ResourceType::kDepthTexture);
|
||||
}
|
||||
|
||||
std::vector<ResourceBinding>
|
||||
Inspector::GetDepthMultisampledTextureResourceBindings(
|
||||
const std::string& entry_point) {
|
||||
return GetTextureResourceBindings(
|
||||
entry_point, TypeInfo::Of<sem::DepthMultisampledTexture>(),
|
||||
ResourceBinding::ResourceType::kDepthMultisampledTexture);
|
||||
}
|
||||
|
||||
std::vector<ResourceBinding> Inspector::GetExternalTextureResourceBindings(
|
||||
const std::string& entry_point) {
|
||||
auto* func = FindEntryPointByName(entry_point);
|
||||
if (!func) {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<ResourceBinding> result;
|
||||
auto* func_sem = program_->Sem().Get(func);
|
||||
for (auto& ref : func_sem->ReferencedExternalTextureVariables()) {
|
||||
auto* var = ref.first;
|
||||
auto binding_info = ref.second;
|
||||
|
||||
ResourceBinding entry;
|
||||
entry.resource_type = ResourceBinding::ResourceType::kExternalTexture;
|
||||
entry.bind_group = binding_info.group->value();
|
||||
entry.binding = binding_info.binding->value();
|
||||
|
||||
auto* texture_type = var->Type()->UnwrapRef()->As<sem::Texture>();
|
||||
entry.dim = TypeTextureDimensionToResourceBindingTextureDimension(
|
||||
texture_type->dim());
|
||||
|
||||
result.push_back(entry);
|
||||
}
|
||||
return result;
|
||||
return GetTextureResourceBindings(
|
||||
entry_point, TypeInfo::Of<sem::ExternalTexture>(),
|
||||
ResourceBinding::ResourceType::kExternalTexture);
|
||||
}
|
||||
|
||||
std::vector<SamplerTexturePair> Inspector::GetSamplerTextureUses(
|
||||
@@ -734,7 +727,7 @@ std::vector<ResourceBinding> Inspector::GetStorageTextureResourceBindingsImpl(
|
||||
|
||||
auto* func_sem = program_->Sem().Get(func);
|
||||
std::vector<ResourceBinding> result;
|
||||
for (auto& ref : func_sem->ReferencedStorageTextureVariables()) {
|
||||
for (auto& ref : func_sem->ReferencedVariablesOfType<sem::StorageTexture>()) {
|
||||
auto* var = ref.first;
|
||||
auto binding_info = ref.second;
|
||||
|
||||
|
||||
@@ -121,6 +121,11 @@ class Inspector {
|
||||
std::vector<ResourceBinding> GetDepthTextureResourceBindings(
|
||||
const std::string& entry_point);
|
||||
|
||||
/// @param entry_point name of the entry point to get information about.
|
||||
/// @returns vector of all of the bindings for depth textures.
|
||||
std::vector<ResourceBinding> GetDepthMultisampledTextureResourceBindings(
|
||||
const std::string& entry_point);
|
||||
|
||||
/// @param entry_point name of the entry point to get information about.
|
||||
/// @returns vector of all of the bindings for external textures.
|
||||
std::vector<ResourceBinding> GetExternalTextureResourceBindings(
|
||||
@@ -167,6 +172,18 @@ class Inspector {
|
||||
bool ContainsSampleMaskBuiltin(sem::Type* type,
|
||||
const ast::DecorationList& decorations) const;
|
||||
|
||||
/// Gathers all the texture resource bindings of the given type for the given
|
||||
/// entry point.
|
||||
/// @param entry_point name of the entry point to get information about.
|
||||
/// @param texture_type the type of the textures to gather.
|
||||
/// @param resource_type the ResourceBinding::ResourceType for the given
|
||||
/// texture type.
|
||||
/// @returns vector of all of the bindings for depth textures.
|
||||
std::vector<ResourceBinding> GetTextureResourceBindings(
|
||||
const std::string& entry_point,
|
||||
const tint::TypeInfo& texture_type,
|
||||
ResourceBinding::ResourceType resource_type);
|
||||
|
||||
/// @param entry_point name of the entry point to get information about.
|
||||
/// @param read_only if true get only read-only bindings, if false get
|
||||
/// write-only bindings.
|
||||
|
||||
@@ -116,6 +116,10 @@ class InspectorGetDepthTextureResourceBindingsTestWithParam
|
||||
: public InspectorBuilder,
|
||||
public testing::TestWithParam<GetDepthTextureTestParams> {};
|
||||
|
||||
class InspectorGetDepthMultisampledTextureResourceBindingsTest
|
||||
: public InspectorBuilder,
|
||||
public testing::Test {};
|
||||
|
||||
typedef std::tuple<ast::TextureDimension, ResourceBinding::TextureDimension>
|
||||
DimensionParams;
|
||||
typedef std::tuple<ast::ImageFormat,
|
||||
@@ -1005,22 +1009,26 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
|
||||
{{0, ty.i32()}});
|
||||
|
||||
auto* s_texture_type =
|
||||
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
|
||||
AddSampledTexture("s_texture", s_texture_type, 2, 0);
|
||||
ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
AddResource("s_texture", s_texture_type, 2, 0);
|
||||
AddSampler("s_var", 3, 0);
|
||||
AddGlobalVariable("s_coords", ty.f32());
|
||||
MakeSamplerReferenceBodyFunction("s_func", "s_texture", "s_var", "s_coords",
|
||||
ty.f32(), {});
|
||||
|
||||
auto* cs_depth_texture_type =
|
||||
MakeDepthTextureType(ast::TextureDimension::k2d);
|
||||
AddDepthTexture("cs_texture", cs_depth_texture_type, 3, 1);
|
||||
auto* cs_depth_texture_type = ty.depth_texture(ast::TextureDimension::k2d);
|
||||
AddResource("cs_texture", cs_depth_texture_type, 3, 1);
|
||||
AddComparisonSampler("cs_var", 3, 2);
|
||||
AddGlobalVariable("cs_coords", ty.vec2<f32>());
|
||||
AddGlobalVariable("cs_depth", ty.f32());
|
||||
MakeComparisonSamplerReferenceBodyFunction(
|
||||
"cs_func", "cs_texture", "cs_var", "cs_coords", "cs_depth", ty.f32(), {});
|
||||
|
||||
auto* depth_ms_texture_type =
|
||||
ty.depth_multisampled_texture(ast::TextureDimension::k2d);
|
||||
AddResource("depth_ms_texture", depth_ms_texture_type, 3, 3);
|
||||
Func("depth_ms_func", {}, ty.void_(), {Ignore("depth_ms_texture")});
|
||||
|
||||
auto* st_type = MakeStorageTextureTypes(ast::TextureDimension::k2d,
|
||||
ast::ImageFormat::kR32Uint, false);
|
||||
AddStorageTexture("st_var", st_type, 4, 0);
|
||||
@@ -1033,7 +1041,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
|
||||
|
||||
MakeCallerBodyFunction("ep_func",
|
||||
{"ub_func", "sb_func", "rosb_func", "s_func",
|
||||
"cs_func", "st_func", "rost_func"},
|
||||
"cs_func", "depth_ms_func", "st_func", "rost_func"},
|
||||
ast::DecorationList{
|
||||
Stage(ast::PipelineStage::kFragment),
|
||||
});
|
||||
@@ -1042,7 +1050,7 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
|
||||
|
||||
auto result = inspector.GetResourceBindings("ep_func");
|
||||
ASSERT_FALSE(inspector.has_error()) << inspector.error();
|
||||
ASSERT_EQ(9u, result.size());
|
||||
ASSERT_EQ(10u, result.size());
|
||||
|
||||
EXPECT_EQ(ResourceBinding::ResourceType::kUniformBuffer,
|
||||
result[0].resource_type);
|
||||
@@ -1087,6 +1095,11 @@ TEST_F(InspectorGetResourceBindingsTest, Simple) {
|
||||
result[8].resource_type);
|
||||
EXPECT_EQ(3u, result[8].bind_group);
|
||||
EXPECT_EQ(1u, result[8].binding);
|
||||
|
||||
EXPECT_EQ(ResourceBinding::ResourceType::kDepthMultisampledTexture,
|
||||
result[9].resource_type);
|
||||
EXPECT_EQ(3u, result[9].bind_group);
|
||||
EXPECT_EQ(3u, result[9].binding);
|
||||
}
|
||||
|
||||
TEST_F(InspectorGetUniformBufferResourceBindingsTest, MissingEntryPoint) {
|
||||
@@ -1663,8 +1676,8 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) {
|
||||
|
||||
TEST_F(InspectorGetSamplerResourceBindingsTest, Simple) {
|
||||
auto* sampled_texture_type =
|
||||
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
|
||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||
ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
AddResource("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.f32());
|
||||
|
||||
@@ -1700,8 +1713,8 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, NoSampler) {
|
||||
|
||||
TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) {
|
||||
auto* sampled_texture_type =
|
||||
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
|
||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||
ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
AddResource("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.f32());
|
||||
|
||||
@@ -1726,8 +1739,8 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) {
|
||||
|
||||
TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) {
|
||||
auto* sampled_texture_type =
|
||||
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
|
||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||
ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
AddResource("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.f32());
|
||||
|
||||
@@ -1744,8 +1757,8 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) {
|
||||
}
|
||||
|
||||
TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) {
|
||||
auto* depth_texture_type = MakeDepthTextureType(ast::TextureDimension::k2d);
|
||||
AddDepthTexture("foo_texture", depth_texture_type, 0, 0);
|
||||
auto* depth_texture_type = ty.depth_texture(ast::TextureDimension::k2d);
|
||||
AddResource("foo_texture", depth_texture_type, 0, 0);
|
||||
AddComparisonSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
||||
AddGlobalVariable("foo_depth", ty.f32());
|
||||
@@ -1765,8 +1778,8 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) {
|
||||
}
|
||||
|
||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, Simple) {
|
||||
auto* depth_texture_type = MakeDepthTextureType(ast::TextureDimension::k2d);
|
||||
AddDepthTexture("foo_texture", depth_texture_type, 0, 0);
|
||||
auto* depth_texture_type = ty.depth_texture(ast::TextureDimension::k2d);
|
||||
AddResource("foo_texture", depth_texture_type, 0, 0);
|
||||
AddComparisonSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
||||
AddGlobalVariable("foo_depth", ty.f32());
|
||||
@@ -1803,8 +1816,8 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, NoSampler) {
|
||||
}
|
||||
|
||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) {
|
||||
auto* depth_texture_type = MakeDepthTextureType(ast::TextureDimension::k2d);
|
||||
AddDepthTexture("foo_texture", depth_texture_type, 0, 0);
|
||||
auto* depth_texture_type = ty.depth_texture(ast::TextureDimension::k2d);
|
||||
AddResource("foo_texture", depth_texture_type, 0, 0);
|
||||
AddComparisonSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
||||
AddGlobalVariable("foo_depth", ty.f32());
|
||||
@@ -1831,8 +1844,8 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) {
|
||||
}
|
||||
|
||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) {
|
||||
auto* depth_texture_type = MakeDepthTextureType(ast::TextureDimension::k2d);
|
||||
AddDepthTexture("foo_texture", depth_texture_type, 0, 0);
|
||||
auto* depth_texture_type = ty.depth_texture(ast::TextureDimension::k2d);
|
||||
AddResource("foo_texture", depth_texture_type, 0, 0);
|
||||
AddComparisonSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.vec2<f32>());
|
||||
AddGlobalVariable("foo_depth", ty.f32());
|
||||
@@ -1851,8 +1864,8 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) {
|
||||
|
||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, SkipsSamplers) {
|
||||
auto* sampled_texture_type =
|
||||
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
|
||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||
ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
AddResource("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.f32());
|
||||
|
||||
@@ -1884,9 +1897,9 @@ TEST_F(InspectorGetSampledTextureResourceBindingsTest, Empty) {
|
||||
}
|
||||
|
||||
TEST_P(InspectorGetSampledTextureResourceBindingsTestWithParam, textureSample) {
|
||||
auto* sampled_texture_type = MakeSampledTextureType(
|
||||
auto* sampled_texture_type = ty.sampled_texture(
|
||||
GetParam().type_dim, GetBaseType(GetParam().sampled_kind));
|
||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddResource("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
auto* coord_type = GetCoordsType(GetParam().type_dim, ty.f32());
|
||||
AddGlobalVariable("foo_coords", coord_type);
|
||||
@@ -1942,9 +1955,9 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
|
||||
TEST_P(InspectorGetSampledArrayTextureResourceBindingsTestWithParam,
|
||||
textureSample) {
|
||||
auto* sampled_texture_type = MakeSampledTextureType(
|
||||
auto* sampled_texture_type = ty.sampled_texture(
|
||||
GetParam().type_dim, GetBaseType(GetParam().sampled_kind));
|
||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddResource("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
auto* coord_type = GetCoordsType(GetParam().type_dim, ty.f32());
|
||||
AddGlobalVariable("foo_coords", coord_type);
|
||||
@@ -1986,9 +1999,9 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
|
||||
TEST_P(InspectorGetMultisampledTextureResourceBindingsTestWithParam,
|
||||
textureLoad) {
|
||||
auto* multisampled_texture_type = MakeMultisampledTextureType(
|
||||
auto* multisampled_texture_type = ty.multisampled_texture(
|
||||
GetParam().type_dim, GetBaseType(GetParam().sampled_kind));
|
||||
AddMultisampledTexture("foo_texture", multisampled_texture_type, 0, 0);
|
||||
AddResource("foo_texture", multisampled_texture_type, 0, 0);
|
||||
auto* coord_type = GetCoordsType(GetParam().type_dim, ty.i32());
|
||||
AddGlobalVariable("foo_coords", coord_type);
|
||||
AddGlobalVariable("foo_sample_index", ty.i32());
|
||||
@@ -2055,9 +2068,9 @@ TEST_F(InspectorGetMultisampledArrayTextureResourceBindingsTest, Empty) {
|
||||
|
||||
TEST_P(InspectorGetMultisampledArrayTextureResourceBindingsTestWithParam,
|
||||
DISABLED_textureSample) {
|
||||
auto* multisampled_texture_type = MakeMultisampledTextureType(
|
||||
auto* multisampled_texture_type = ty.multisampled_texture(
|
||||
GetParam().type_dim, GetBaseType(GetParam().sampled_kind));
|
||||
AddMultisampledTexture("foo_texture", multisampled_texture_type, 0, 0);
|
||||
AddResource("foo_texture", multisampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
auto* coord_type = GetCoordsType(GetParam().type_dim, ty.f32());
|
||||
AddGlobalVariable("foo_coords", coord_type);
|
||||
@@ -2247,13 +2260,12 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
|
||||
TEST_P(InspectorGetDepthTextureResourceBindingsTestWithParam,
|
||||
textureDimensions) {
|
||||
auto* depth_texture_type = MakeDepthTextureType(GetParam().type_dim);
|
||||
AddDepthTexture("dt", depth_texture_type, 0, 0);
|
||||
AddGlobalVariable("dt_level", ty.i32());
|
||||
auto* depth_texture_type = ty.depth_texture(GetParam().type_dim);
|
||||
AddResource("dt", depth_texture_type, 0, 0);
|
||||
|
||||
Func("ep", ast::VariableList(), ty.void_(),
|
||||
ast::StatementList{
|
||||
Ignore(Call("textureDimensions", "dt", "dt_level")),
|
||||
Ignore(Call("textureDimensions", "dt")),
|
||||
},
|
||||
ast::DecorationList{
|
||||
Stage(ast::PipelineStage::kFragment),
|
||||
@@ -2289,9 +2301,36 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
ast::TextureDimension::kCubeArray,
|
||||
inspector::ResourceBinding::TextureDimension::kCubeArray}));
|
||||
|
||||
TEST_F(InspectorGetDepthMultisampledTextureResourceBindingsTest,
|
||||
textureDimensions) {
|
||||
auto* depth_ms_texture_type =
|
||||
ty.depth_multisampled_texture(ast::TextureDimension::k2d);
|
||||
AddResource("tex", depth_ms_texture_type, 0, 0);
|
||||
|
||||
Func("ep", ast::VariableList(), ty.void_(),
|
||||
ast::StatementList{
|
||||
Ignore(Call("textureDimensions", "tex")),
|
||||
},
|
||||
ast::DecorationList{
|
||||
Stage(ast::PipelineStage::kFragment),
|
||||
});
|
||||
|
||||
Inspector& inspector = Build();
|
||||
|
||||
auto result = inspector.GetDepthMultisampledTextureResourceBindings("ep");
|
||||
ASSERT_FALSE(inspector.has_error()) << inspector.error();
|
||||
|
||||
EXPECT_EQ(ResourceBinding::ResourceType::kDepthMultisampledTexture,
|
||||
result[0].resource_type);
|
||||
ASSERT_EQ(1u, result.size());
|
||||
EXPECT_EQ(0u, result[0].bind_group);
|
||||
EXPECT_EQ(0u, result[0].binding);
|
||||
EXPECT_EQ(ResourceBinding::TextureDimension::k2d, result[0].dim);
|
||||
}
|
||||
|
||||
TEST_F(InspectorGetExternalTextureResourceBindingsTest, Simple) {
|
||||
auto* external_texture_type = MakeExternalTextureType();
|
||||
AddExternalTexture("et", external_texture_type, 0, 0);
|
||||
auto* external_texture_type = ty.external_texture();
|
||||
AddResource("et", external_texture_type, 0, 0);
|
||||
|
||||
Func("ep", ast::VariableList(), ty.void_(),
|
||||
ast::StatementList{
|
||||
@@ -2328,8 +2367,8 @@ TEST_F(InspectorGetSamplerTextureUsesTest, None) {
|
||||
|
||||
TEST_F(InspectorGetSamplerTextureUsesTest, Simple) {
|
||||
auto* sampled_texture_type =
|
||||
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
|
||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 10);
|
||||
ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
AddResource("foo_texture", sampled_texture_type, 0, 10);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.f32());
|
||||
|
||||
@@ -2354,8 +2393,8 @@ TEST_F(InspectorGetSamplerTextureUsesTest, Simple) {
|
||||
|
||||
TEST_F(InspectorGetSamplerTextureUsesTest, MultipleCalls) {
|
||||
auto* sampled_texture_type =
|
||||
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
|
||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 10);
|
||||
ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
AddResource("foo_texture", sampled_texture_type, 0, 10);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.f32());
|
||||
|
||||
@@ -2378,8 +2417,8 @@ TEST_F(InspectorGetSamplerTextureUsesTest, MultipleCalls) {
|
||||
|
||||
TEST_F(InspectorGetSamplerTextureUsesTest, InFunction) {
|
||||
auto* sampled_texture_type =
|
||||
MakeSampledTextureType(ast::TextureDimension::k1d, ty.f32());
|
||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||
ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
|
||||
AddResource("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.f32());
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ struct ResourceBinding {
|
||||
kReadOnlyStorageTexture,
|
||||
kWriteOnlyStorageTexture,
|
||||
kDepthTexture,
|
||||
kDepthMultisampledTexture,
|
||||
kExternalTexture
|
||||
};
|
||||
|
||||
|
||||
@@ -207,42 +207,10 @@ void InspectorBuilder::AddComparisonSampler(const std::string& name,
|
||||
});
|
||||
}
|
||||
|
||||
ast::SampledTexture* InspectorBuilder::MakeSampledTextureType(
|
||||
ast::TextureDimension dim,
|
||||
ast::Type* type) {
|
||||
return ty.sampled_texture(dim, type);
|
||||
}
|
||||
|
||||
ast::DepthTexture* InspectorBuilder::MakeDepthTextureType(
|
||||
ast::TextureDimension dim) {
|
||||
return ty.depth_texture(dim);
|
||||
}
|
||||
|
||||
ast::MultisampledTexture* InspectorBuilder::MakeMultisampledTextureType(
|
||||
ast::TextureDimension dim,
|
||||
ast::Type* type) {
|
||||
return ty.multisampled_texture(dim, type);
|
||||
}
|
||||
|
||||
ast::ExternalTexture* InspectorBuilder::MakeExternalTextureType() {
|
||||
return ty.external_texture();
|
||||
}
|
||||
|
||||
void InspectorBuilder::AddSampledTexture(const std::string& name,
|
||||
ast::Type* type,
|
||||
uint32_t group,
|
||||
uint32_t binding) {
|
||||
Global(name, type,
|
||||
ast::DecorationList{
|
||||
create<ast::BindingDecoration>(binding),
|
||||
create<ast::GroupDecoration>(group),
|
||||
});
|
||||
}
|
||||
|
||||
void InspectorBuilder::AddMultisampledTexture(const std::string& name,
|
||||
ast::Type* type,
|
||||
uint32_t group,
|
||||
uint32_t binding) {
|
||||
void InspectorBuilder::AddResource(const std::string& name,
|
||||
ast::Type* type,
|
||||
uint32_t group,
|
||||
uint32_t binding) {
|
||||
Global(name, type,
|
||||
ast::DecorationList{
|
||||
create<ast::BindingDecoration>(binding),
|
||||
@@ -255,28 +223,6 @@ void InspectorBuilder::AddGlobalVariable(const std::string& name,
|
||||
Global(name, type, ast::StorageClass::kPrivate);
|
||||
}
|
||||
|
||||
void InspectorBuilder::AddDepthTexture(const std::string& name,
|
||||
ast::Type* type,
|
||||
uint32_t group,
|
||||
uint32_t binding) {
|
||||
Global(name, type,
|
||||
ast::DecorationList{
|
||||
create<ast::BindingDecoration>(binding),
|
||||
create<ast::GroupDecoration>(group),
|
||||
});
|
||||
}
|
||||
|
||||
void InspectorBuilder::AddExternalTexture(const std::string& name,
|
||||
ast::Type* type,
|
||||
uint32_t group,
|
||||
uint32_t binding) {
|
||||
Global(name, type,
|
||||
ast::DecorationList{
|
||||
create<ast::BindingDecoration>(binding),
|
||||
create<ast::GroupDecoration>(group),
|
||||
});
|
||||
}
|
||||
|
||||
ast::Function* InspectorBuilder::MakeSamplerReferenceBodyFunction(
|
||||
const std::string& func_name,
|
||||
const std::string& texture_name,
|
||||
|
||||
@@ -256,75 +256,21 @@ class InspectorBuilder : public ProgramBuilder {
|
||||
uint32_t group,
|
||||
uint32_t binding);
|
||||
|
||||
/// Generates a SampledTexture appropriate for the params
|
||||
/// @param dim the dimensions of the texture
|
||||
/// @param type the data type of the sampled texture
|
||||
/// @returns the generated SampleTextureType
|
||||
ast::SampledTexture* MakeSampledTextureType(ast::TextureDimension dim,
|
||||
ast::Type* type);
|
||||
|
||||
/// Generates a DepthTexture appropriate for the params
|
||||
/// @param dim the dimensions of the texture
|
||||
/// @returns the generated DepthTexture
|
||||
ast::DepthTexture* MakeDepthTextureType(ast::TextureDimension dim);
|
||||
|
||||
/// Generates a MultisampledTexture appropriate for the params
|
||||
/// @param dim the dimensions of the texture
|
||||
/// @param type the data type of the sampled texture
|
||||
/// @returns the generated SampleTextureType
|
||||
ast::MultisampledTexture* MakeMultisampledTextureType(
|
||||
ast::TextureDimension dim,
|
||||
ast::Type* type);
|
||||
|
||||
/// Generates an ExternalTexture appropriate for the params
|
||||
/// @returns the generated ExternalTexture
|
||||
ast::ExternalTexture* MakeExternalTextureType();
|
||||
|
||||
/// Adds a sampled texture variable to the program
|
||||
/// Adds a sampler or texture variable to the program
|
||||
/// @param name the name of the variable
|
||||
/// @param type the type to use
|
||||
/// @param group the binding/group to use for the sampled texture
|
||||
/// @param binding the binding number to use for the sampled texture
|
||||
void AddSampledTexture(const std::string& name,
|
||||
ast::Type* type,
|
||||
uint32_t group,
|
||||
uint32_t binding);
|
||||
|
||||
/// Adds a multi-sampled texture variable to the program
|
||||
/// @param name the name of the variable
|
||||
/// @param type the type to use
|
||||
/// @param group the binding/group to use for the multi-sampled texture
|
||||
/// @param binding the binding number to use for the multi-sampled texture
|
||||
void AddMultisampledTexture(const std::string& name,
|
||||
ast::Type* type,
|
||||
uint32_t group,
|
||||
uint32_t binding);
|
||||
/// @param group the binding/group to use for the resource
|
||||
/// @param binding the binding number to use for the resource
|
||||
void AddResource(const std::string& name,
|
||||
ast::Type* type,
|
||||
uint32_t group,
|
||||
uint32_t binding);
|
||||
|
||||
/// Add a module scope private variable to the progames
|
||||
/// @param name the name of the variable
|
||||
/// @param type the type to use
|
||||
void AddGlobalVariable(const std::string& name, ast::Type* type);
|
||||
|
||||
/// Adds a depth texture variable to the program
|
||||
/// @param name the name of the variable
|
||||
/// @param type the type to use
|
||||
/// @param group the binding/group to use for the depth texture
|
||||
/// @param binding the binding number to use for the depth texture
|
||||
void AddDepthTexture(const std::string& name,
|
||||
ast::Type* type,
|
||||
uint32_t group,
|
||||
uint32_t binding);
|
||||
|
||||
/// Adds an external texture variable to the program
|
||||
/// @param name the name of the variable
|
||||
/// @param type the type to use
|
||||
/// @param group the binding/group to use for the external texture
|
||||
/// @param binding the binding number to use for the external texture
|
||||
void AddExternalTexture(const std::string& name,
|
||||
ast::Type* type,
|
||||
uint32_t group,
|
||||
uint32_t binding);
|
||||
|
||||
/// Generates a function that references a specific sampler variable
|
||||
/// @param func_name name of the function created
|
||||
/// @param texture_name name of the texture to be sampled
|
||||
|
||||
Reference in New Issue
Block a user