mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 02:39:11 +00:00
Move sampler to type.
This CL moves the sampler from sem to type and updates the namespace. Bug: tint:1718 Change-Id: I22d228df5d24e154dbebecb43e7c6730475e08d2 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113283 Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
4595fb7989
commit
5ee58b60a8
@@ -584,11 +584,11 @@ bool match_sampler(MatchState&, const type::Type* ty) {
|
||||
if (ty->Is<Any>()) {
|
||||
return true;
|
||||
}
|
||||
return ty->Is([](const sem::Sampler* s) { return s->kind() == ast::SamplerKind::kSampler; });
|
||||
return ty->Is([](const type::Sampler* s) { return s->kind() == ast::SamplerKind::kSampler; });
|
||||
}
|
||||
|
||||
const sem::Sampler* build_sampler(MatchState& state) {
|
||||
return state.builder.create<sem::Sampler>(ast::SamplerKind::kSampler);
|
||||
const type::Sampler* build_sampler(MatchState& state) {
|
||||
return state.builder.create<type::Sampler>(ast::SamplerKind::kSampler);
|
||||
}
|
||||
|
||||
bool match_sampler_comparison(MatchState&, const type::Type* ty) {
|
||||
@@ -596,11 +596,11 @@ bool match_sampler_comparison(MatchState&, const type::Type* ty) {
|
||||
return true;
|
||||
}
|
||||
return ty->Is(
|
||||
[](const sem::Sampler* s) { return s->kind() == ast::SamplerKind::kComparisonSampler; });
|
||||
[](const type::Sampler* s) { return s->kind() == ast::SamplerKind::kComparisonSampler; });
|
||||
}
|
||||
|
||||
const sem::Sampler* build_sampler_comparison(MatchState& state) {
|
||||
return state.builder.create<sem::Sampler>(ast::SamplerKind::kComparisonSampler);
|
||||
const type::Sampler* build_sampler_comparison(MatchState& state) {
|
||||
return state.builder.create<type::Sampler>(ast::SamplerKind::kComparisonSampler);
|
||||
}
|
||||
|
||||
bool match_texture(MatchState&,
|
||||
|
||||
@@ -280,7 +280,7 @@ TEST_F(IntrinsicTableTest, MatchSampler) {
|
||||
auto* vec2_f32 = create<sem::Vector>(f32, 2u);
|
||||
auto* vec4_f32 = create<sem::Vector>(f32, 4u);
|
||||
auto* tex = create<type::SampledTexture>(ast::TextureDimension::k2d, f32);
|
||||
auto* sampler = create<sem::Sampler>(ast::SamplerKind::kSampler);
|
||||
auto* sampler = create<type::Sampler>(ast::SamplerKind::kSampler);
|
||||
auto result = table->Lookup(BuiltinType::kTextureSample, utils::Vector{tex, sampler, vec2_f32},
|
||||
sem::EvaluationStage::kConstant, Source{});
|
||||
ASSERT_NE(result.sem, nullptr) << Diagnostics().str();
|
||||
|
||||
@@ -69,7 +69,6 @@
|
||||
#include "src/tint/sem/module.h"
|
||||
#include "src/tint/sem/pointer.h"
|
||||
#include "src/tint/sem/reference.h"
|
||||
#include "src/tint/sem/sampler.h"
|
||||
#include "src/tint/sem/statement.h"
|
||||
#include "src/tint/sem/struct.h"
|
||||
#include "src/tint/sem/switch_statement.h"
|
||||
@@ -81,6 +80,7 @@
|
||||
#include "src/tint/type/depth_texture.h"
|
||||
#include "src/tint/type/multisampled_texture.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/sampler.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/utils/defer.h"
|
||||
#include "src/tint/utils/math.h"
|
||||
@@ -278,7 +278,7 @@ type::Type* Resolver::Type(const ast::Type* ty) {
|
||||
}
|
||||
return nullptr;
|
||||
},
|
||||
[&](const ast::Sampler* t) { return builder_->create<sem::Sampler>(t->kind); },
|
||||
[&](const ast::Sampler* t) { return builder_->create<type::Sampler>(t->kind); },
|
||||
[&](const ast::SampledTexture* t) -> type::SampledTexture* {
|
||||
if (auto* el = Type(t->type)) {
|
||||
auto* sem = builder_->create<type::SampledTexture>(t->dim, el);
|
||||
|
||||
@@ -60,7 +60,6 @@
|
||||
#include "src/tint/sem/member_accessor_expression.h"
|
||||
#include "src/tint/sem/pointer.h"
|
||||
#include "src/tint/sem/reference.h"
|
||||
#include "src/tint/sem/sampler.h"
|
||||
#include "src/tint/sem/statement.h"
|
||||
#include "src/tint/sem/struct.h"
|
||||
#include "src/tint/sem/switch_statement.h"
|
||||
@@ -72,6 +71,7 @@
|
||||
#include "src/tint/type/depth_texture.h"
|
||||
#include "src/tint/type/multisampled_texture.h"
|
||||
#include "src/tint/type/sampled_texture.h"
|
||||
#include "src/tint/type/sampler.h"
|
||||
#include "src/tint/type/storage_texture.h"
|
||||
#include "src/tint/utils/defer.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
@@ -231,7 +231,7 @@ bool Validator::IsHostShareable(const type::Type* type) const {
|
||||
|
||||
// https://gpuweb.github.io/gpuweb/wgsl.html#storable-types
|
||||
bool Validator::IsStorable(const type::Type* type) const {
|
||||
return IsPlain(type) || type->IsAnyOf<type::Texture, sem::Sampler>();
|
||||
return IsPlain(type) || type->IsAnyOf<type::Texture, type::Sampler>();
|
||||
}
|
||||
|
||||
const ast::Statement* Validator::ClosestContinuing(bool stop_at_loop,
|
||||
@@ -832,7 +832,7 @@ bool Validator::Parameter(const ast::Function* func, const sem::Variable* var) c
|
||||
AddError("type of function parameter must be constructible", decl->type->source);
|
||||
return false;
|
||||
}
|
||||
} else if (!var->Type()->IsAnyOf<type::Texture, sem::Sampler, sem::Pointer>()) {
|
||||
} else if (!var->Type()->IsAnyOf<type::Texture, type::Sampler, sem::Pointer>()) {
|
||||
AddError("type of function parameter cannot be " + sem_.TypeNameOf(var->Type()),
|
||||
decl->source);
|
||||
return false;
|
||||
@@ -2266,7 +2266,7 @@ bool Validator::Assignment(const ast::Statement* a, const type::Type* rhs_ty) co
|
||||
// https://www.w3.org/TR/WGSL/#phony-assignment-section
|
||||
auto* ty = rhs_ty->UnwrapRef();
|
||||
if (!ty->IsConstructible() &&
|
||||
!ty->IsAnyOf<sem::Pointer, type::Texture, sem::Sampler, sem::AbstractNumeric>()) {
|
||||
!ty->IsAnyOf<sem::Pointer, type::Texture, type::Sampler, sem::AbstractNumeric>()) {
|
||||
AddError("cannot assign '" + sem_.TypeNameOf(rhs_ty) +
|
||||
"' to '_'. '_' can only be assigned a constructible, pointer, texture or "
|
||||
"sampler type",
|
||||
|
||||
Reference in New Issue
Block a user