[spirv-writer] Generate sampler type
Change-Id: I587cf7430711d8009becf76f7630091f32ed3490 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/27840 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: dan sinclair <dsinclair@chromium.org> Commit-Queue: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
11eda3cc3e
commit
18a54647b7
|
@ -1927,6 +1927,8 @@ uint32_t Builder::GenerateTypeIfNeeded(ast::type::Type* type) {
|
||||||
if (!GenerateTextureType(type->AsTexture(), result)) {
|
if (!GenerateTextureType(type->AsTexture(), result)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
} else if (type->IsSampler()) {
|
||||||
|
push_type(spv::Op::OpTypeSampler, {result});
|
||||||
} else {
|
} else {
|
||||||
error_ = "unable to convert type: " + type->type_name();
|
error_ = "unable to convert type: " + type->type_name();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "src/ast/type/matrix_type.h"
|
#include "src/ast/type/matrix_type.h"
|
||||||
#include "src/ast/type/pointer_type.h"
|
#include "src/ast/type/pointer_type.h"
|
||||||
#include "src/ast/type/sampled_texture_type.h"
|
#include "src/ast/type/sampled_texture_type.h"
|
||||||
|
#include "src/ast/type/sampler_type.h"
|
||||||
#include "src/ast/type/storage_texture_type.h"
|
#include "src/ast/type/storage_texture_type.h"
|
||||||
#include "src/ast/type/struct_type.h"
|
#include "src/ast/type/struct_type.h"
|
||||||
#include "src/ast/type/texture_type.h"
|
#include "src/ast/type/texture_type.h"
|
||||||
|
@ -1162,6 +1163,30 @@ INSTANTIATE_TEST_SUITE_P(BuilderTest_Type,
|
||||||
ast::type::ImageFormat::kR8Snorm,
|
ast::type::ImageFormat::kR8Snorm,
|
||||||
ast::type::ImageFormat::kR8Unorm));
|
ast::type::ImageFormat::kR8Unorm));
|
||||||
|
|
||||||
|
TEST_F(BuilderTest_Type, Sampler) {
|
||||||
|
ast::type::SamplerType sampler(ast::type::SamplerKind::kSampler);
|
||||||
|
|
||||||
|
ast::Module mod;
|
||||||
|
Builder b(&mod);
|
||||||
|
EXPECT_EQ(b.GenerateTypeIfNeeded(&sampler), 1u);
|
||||||
|
EXPECT_EQ(b.GenerateTypeIfNeeded(&sampler), 1u);
|
||||||
|
ASSERT_FALSE(b.has_error()) << b.error();
|
||||||
|
|
||||||
|
EXPECT_EQ(DumpInstructions(b.types()), "%1 = OpTypeSampler\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(BuilderTest_Type, ComparisonSampler) {
|
||||||
|
ast::type::SamplerType sampler(ast::type::SamplerKind::kComparisonSampler);
|
||||||
|
|
||||||
|
ast::Module mod;
|
||||||
|
Builder b(&mod);
|
||||||
|
EXPECT_EQ(b.GenerateTypeIfNeeded(&sampler), 1u);
|
||||||
|
EXPECT_EQ(b.GenerateTypeIfNeeded(&sampler), 1u);
|
||||||
|
ASSERT_FALSE(b.has_error()) << b.error();
|
||||||
|
|
||||||
|
EXPECT_EQ(DumpInstructions(b.types()), "%1 = OpTypeSampler\n");
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace spirv
|
} // namespace spirv
|
||||||
} // namespace writer
|
} // namespace writer
|
||||||
|
|
Loading…
Reference in New Issue