mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 02:39:11 +00:00
Move TextureDimension to type/
This cl pulls TextureDimension out of ast/texture and into type/texture_dimension removing a type dependency on ast. Change-Id: Icf06ec32ee9051286f169ae9538c48416f513039 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/117603 Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
d54dabeab5
commit
3cbf3fc4c5
@@ -22,6 +22,7 @@
|
||||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/sem/builtin.h"
|
||||
#include "src/tint/sem/call.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
#include "src/tint/utils/map.h"
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
@@ -638,7 +639,7 @@ struct BuiltinPolyfill::State {
|
||||
};
|
||||
b.Func(name,
|
||||
utils::Vector{
|
||||
b.Param("t", b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("t", b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("s", b.ty.sampler(ast::SamplerKind::kSampler)),
|
||||
b.Param("coord", b.ty.vec2<f32>()),
|
||||
},
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "src/tint/sem/call.h"
|
||||
#include "src/tint/sem/function.h"
|
||||
#include "src/tint/sem/variable.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::MultiplanarExternalTexture);
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::MultiplanarExternalTexture::NewBindingPoints);
|
||||
@@ -140,7 +141,7 @@ struct MultiplanarExternalTexture::State {
|
||||
auto& syms = new_binding_symbols[sem_var];
|
||||
syms.plane_0 = ctx.Clone(global->symbol);
|
||||
syms.plane_1 = b.Symbols().New("ext_tex_plane_1");
|
||||
b.GlobalVar(syms.plane_1, b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32()),
|
||||
b.GlobalVar(syms.plane_1, b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32()),
|
||||
b.Group(AInt(bps.plane_1.group)), b.Binding(AInt(bps.plane_1.binding)));
|
||||
syms.params = b.Symbols().New("ext_tex_params");
|
||||
b.GlobalVar(syms.params, b.ty.type_name("ExternalTextureParams"),
|
||||
@@ -152,7 +153,7 @@ struct MultiplanarExternalTexture::State {
|
||||
const ast::Expression* cloned_initializer = ctx.Clone(global->initializer);
|
||||
|
||||
auto* replacement =
|
||||
b.Var(syms.plane_0, b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32()),
|
||||
b.Var(syms.plane_0, b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32()),
|
||||
cloned_initializer, cloned_attributes);
|
||||
ctx.Replace(global, replacement);
|
||||
}
|
||||
@@ -178,7 +179,7 @@ struct MultiplanarExternalTexture::State {
|
||||
syms.plane_1 = b.Symbols().New("ext_tex_plane_1");
|
||||
syms.params = b.Symbols().New("ext_tex_params");
|
||||
auto tex2d_f32 = [&] {
|
||||
return b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32());
|
||||
return b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32());
|
||||
};
|
||||
ctx.Replace(param, b.Param(syms.plane_0, tex2d_f32()));
|
||||
ctx.InsertAfter(fn->params, param, b.Param(syms.plane_1, tex2d_f32()));
|
||||
@@ -419,17 +420,18 @@ struct MultiplanarExternalTexture::State {
|
||||
texture_sample_external_sym = b.Symbols().New("textureSampleExternal");
|
||||
|
||||
// Emit the textureSampleExternal function.
|
||||
b.Func(
|
||||
texture_sample_external_sym,
|
||||
utils::Vector{
|
||||
b.Param("plane0", b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("plane1", b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("smp", b.ty.sampler(ast::SamplerKind::kSampler)),
|
||||
b.Param("coord", b.ty.vec2(b.ty.f32())),
|
||||
b.Param("params", b.ty.type_name(params_struct_sym)),
|
||||
},
|
||||
b.ty.vec4(b.ty.f32()),
|
||||
buildTextureBuiltinBody(sem::BuiltinType::kTextureSampleBaseClampToEdge));
|
||||
b.Func(texture_sample_external_sym,
|
||||
utils::Vector{
|
||||
b.Param("plane0",
|
||||
b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("plane1",
|
||||
b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("smp", b.ty.sampler(ast::SamplerKind::kSampler)),
|
||||
b.Param("coord", b.ty.vec2(b.ty.f32())),
|
||||
b.Param("params", b.ty.type_name(params_struct_sym)),
|
||||
},
|
||||
b.ty.vec4(b.ty.f32()),
|
||||
buildTextureBuiltinBody(sem::BuiltinType::kTextureSampleBaseClampToEdge));
|
||||
}
|
||||
|
||||
const ast::IdentifierExpression* exp = b.Expr(texture_sample_external_sym);
|
||||
@@ -467,16 +469,17 @@ struct MultiplanarExternalTexture::State {
|
||||
auto name = b.Symbols().New("textureLoadExternal");
|
||||
|
||||
// Emit the textureLoadExternal() function.
|
||||
b.Func(
|
||||
name,
|
||||
utils::Vector{
|
||||
b.Param("plane0", b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("plane1", b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("coord", CreateASTTypeFor(ctx, coord_ty)),
|
||||
b.Param("params", b.ty.type_name(params_struct_sym)),
|
||||
},
|
||||
b.ty.vec4(b.ty.f32()), //
|
||||
buildTextureBuiltinBody(sem::BuiltinType::kTextureLoad));
|
||||
b.Func(name,
|
||||
utils::Vector{
|
||||
b.Param("plane0",
|
||||
b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("plane1",
|
||||
b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32())),
|
||||
b.Param("coord", CreateASTTypeFor(ctx, coord_ty)),
|
||||
b.Param("params", b.ty.type_name(params_struct_sym)),
|
||||
},
|
||||
b.ty.vec4(b.ty.f32()), //
|
||||
buildTextureBuiltinBody(sem::BuiltinType::kTextureLoad));
|
||||
|
||||
return name;
|
||||
});
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "src/tint/program_builder.h"
|
||||
#include "src/tint/sem/function.h"
|
||||
#include "src/tint/sem/statement.h"
|
||||
#include "src/tint/type/texture_dimension.h"
|
||||
|
||||
TINT_INSTANTIATE_TYPEINFO(tint::transform::Texture1DTo2D);
|
||||
|
||||
@@ -36,7 +37,7 @@ bool ShouldRun(const Program* program) {
|
||||
auto texture = signature.Parameter(sem::ParameterUsage::kTexture);
|
||||
if (texture) {
|
||||
auto* tex = texture->Type()->As<type::Texture>();
|
||||
if (tex->dim() == ast::TextureDimension::k1d) {
|
||||
if (tex->dim() == type::TextureDimension::k1d) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -47,10 +48,10 @@ bool ShouldRun(const Program* program) {
|
||||
if (Switch(
|
||||
program->Sem().Get(var->type),
|
||||
[&](const type::SampledTexture* tex) {
|
||||
return tex->dim() == ast::TextureDimension::k1d;
|
||||
return tex->dim() == type::TextureDimension::k1d;
|
||||
},
|
||||
[&](const type::StorageTexture* storage_tex) {
|
||||
return storage_tex->dim() == ast::TextureDimension::k1d;
|
||||
return storage_tex->dim() == type::TextureDimension::k1d;
|
||||
})) {
|
||||
return true;
|
||||
}
|
||||
@@ -94,18 +95,18 @@ struct Texture1DTo2D::State {
|
||||
const ast::Variable* r = Switch(
|
||||
sem.Get(v->type),
|
||||
[&](const type::SampledTexture* tex) -> const ast::Variable* {
|
||||
if (tex->dim() == ast::TextureDimension::k1d) {
|
||||
if (tex->dim() == type::TextureDimension::k1d) {
|
||||
auto* type = ctx.dst->create<ast::SampledTexture>(
|
||||
ast::TextureDimension::k2d, CreateASTTypeFor(ctx, tex->type()));
|
||||
type::TextureDimension::k2d, CreateASTTypeFor(ctx, tex->type()));
|
||||
return create_var(v, type);
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
},
|
||||
[&](const type::StorageTexture* storage_tex) -> const ast::Variable* {
|
||||
if (storage_tex->dim() == ast::TextureDimension::k1d) {
|
||||
if (storage_tex->dim() == type::TextureDimension::k1d) {
|
||||
auto* type = ctx.dst->create<ast::StorageTexture>(
|
||||
ast::TextureDimension::k2d, storage_tex->texel_format(),
|
||||
type::TextureDimension::k2d, storage_tex->texel_format(),
|
||||
CreateASTTypeFor(ctx, storage_tex->type()), storage_tex->access());
|
||||
return create_var(v, type);
|
||||
} else {
|
||||
@@ -131,7 +132,7 @@ struct Texture1DTo2D::State {
|
||||
return nullptr;
|
||||
}
|
||||
auto* tex = texture->Type()->As<type::Texture>();
|
||||
if (tex->dim() != ast::TextureDimension::k1d) {
|
||||
if (tex->dim() != type::TextureDimension::k1d) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user