Add ExternalTextureOptions
This CL adds a `writer/ExternalTextureOptions` to allow providing external texture information to the generators. The generators are updated to have the option in their config, but do not use it yet. Bug: tint:1855 chromium:1421379 Change-Id: I99b122c5cae145e8527158f300da81743f89775a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/123160 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
55509fae00
commit
e95b59c34d
|
@ -659,6 +659,7 @@ libtint_source_set("libtint_sem_src") {
|
||||||
"sem/evaluation_stage.h",
|
"sem/evaluation_stage.h",
|
||||||
"sem/expression.cc",
|
"sem/expression.cc",
|
||||||
"sem/expression.h",
|
"sem/expression.h",
|
||||||
|
"sem/external_texture.h",
|
||||||
"sem/for_loop_statement.cc",
|
"sem/for_loop_statement.cc",
|
||||||
"sem/for_loop_statement.h",
|
"sem/for_loop_statement.h",
|
||||||
"sem/function.cc",
|
"sem/function.cc",
|
||||||
|
@ -899,6 +900,8 @@ libtint_source_set("libtint_writer_src") {
|
||||||
"writer/binding_point.h",
|
"writer/binding_point.h",
|
||||||
"writer/check_supported_extensions.cc",
|
"writer/check_supported_extensions.cc",
|
||||||
"writer/check_supported_extensions.h",
|
"writer/check_supported_extensions.h",
|
||||||
|
"writer/external_texture_options.cc",
|
||||||
|
"writer/external_texture_options.h",
|
||||||
"writer/flatten_bindings.cc",
|
"writer/flatten_bindings.cc",
|
||||||
"writer/flatten_bindings.h",
|
"writer/flatten_bindings.h",
|
||||||
"writer/float_to_string.cc",
|
"writer/float_to_string.cc",
|
||||||
|
|
|
@ -301,6 +301,7 @@ list(APPEND TINT_LIB_SRCS
|
||||||
sem/evaluation_stage.h
|
sem/evaluation_stage.h
|
||||||
sem/expression.cc
|
sem/expression.cc
|
||||||
sem/expression.h
|
sem/expression.h
|
||||||
|
sem/external_texture.h
|
||||||
sem/for_loop_statement.cc
|
sem/for_loop_statement.cc
|
||||||
sem/for_loop_statement.h
|
sem/for_loop_statement.h
|
||||||
sem/function_expression.cc
|
sem/function_expression.cc
|
||||||
|
@ -543,6 +544,8 @@ list(APPEND TINT_LIB_SRCS
|
||||||
writer/binding_point.h
|
writer/binding_point.h
|
||||||
writer/check_supported_extensions.cc
|
writer/check_supported_extensions.cc
|
||||||
writer/check_supported_extensions.h
|
writer/check_supported_extensions.h
|
||||||
|
writer/external_texture_options.cc
|
||||||
|
writer/external_texture_options.h
|
||||||
writer/flatten_bindings.cc
|
writer/flatten_bindings.cc
|
||||||
writer/flatten_bindings.h
|
writer/flatten_bindings.h
|
||||||
writer/float_to_string.cc
|
writer/float_to_string.cc
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright 2023 The Tint 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
|
||||||
|
//
|
||||||
|
// http://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.
|
||||||
|
|
||||||
|
#ifndef SRC_TINT_SEM_EXTERNAL_TEXTURE_H_
|
||||||
|
#define SRC_TINT_SEM_EXTERNAL_TEXTURE_H_
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include "src/tint/sem/binding_point.h"
|
||||||
|
|
||||||
|
namespace tint::sem::external_texture {
|
||||||
|
|
||||||
|
/// This struct identifies the binding groups and locations for new bindings to
|
||||||
|
/// use when transforming a texture_external instance.
|
||||||
|
struct BindingPoints {
|
||||||
|
/// The desired binding location of the texture_2d representing plane #1 when
|
||||||
|
/// a texture_external binding is expanded.
|
||||||
|
BindingPoint plane_1;
|
||||||
|
/// The desired binding location of the ExternalTextureParams uniform when a
|
||||||
|
/// texture_external binding is expanded.
|
||||||
|
BindingPoint params;
|
||||||
|
|
||||||
|
/// Reflect the fields of this class so that it can be used by tint::ForeachField()
|
||||||
|
TINT_REFLECT(plane_1, params);
|
||||||
|
};
|
||||||
|
|
||||||
|
/// BindingsMap is a map where the key is the binding location of a
|
||||||
|
/// texture_external and the value is a struct containing the desired
|
||||||
|
/// locations for new bindings expanded from the texture_external instance.
|
||||||
|
using BindingsMap = std::unordered_map<BindingPoint, BindingPoints>;
|
||||||
|
|
||||||
|
} // namespace tint::sem::external_texture
|
||||||
|
|
||||||
|
#endif // SRC_TINT_SEM_EXTERNAL_TEXTURE_H_
|
|
@ -21,6 +21,7 @@
|
||||||
#include "src/tint/ast/struct_member.h"
|
#include "src/tint/ast/struct_member.h"
|
||||||
#include "src/tint/builtin/function.h"
|
#include "src/tint/builtin/function.h"
|
||||||
#include "src/tint/sem/binding_point.h"
|
#include "src/tint/sem/binding_point.h"
|
||||||
|
#include "src/tint/sem/external_texture.h"
|
||||||
#include "src/tint/transform/transform.h"
|
#include "src/tint/transform/transform.h"
|
||||||
|
|
||||||
namespace tint::transform {
|
namespace tint::transform {
|
||||||
|
@ -40,22 +41,12 @@ class MultiplanarExternalTexture final : public Castable<MultiplanarExternalText
|
||||||
public:
|
public:
|
||||||
/// This struct identifies the binding groups and locations for new bindings to
|
/// This struct identifies the binding groups and locations for new bindings to
|
||||||
/// use when transforming a texture_external instance.
|
/// use when transforming a texture_external instance.
|
||||||
struct BindingPoints {
|
using BindingPoints = sem::external_texture::BindingPoints;
|
||||||
/// The desired binding location of the texture_2d representing plane #1 when
|
|
||||||
/// a texture_external binding is expanded.
|
|
||||||
sem::BindingPoint plane_1;
|
|
||||||
/// The desired binding location of the ExternalTextureParams uniform when a
|
|
||||||
/// texture_external binding is expanded.
|
|
||||||
sem::BindingPoint params;
|
|
||||||
|
|
||||||
/// Reflect the fields of this class so that it can be used by tint::ForeachField()
|
|
||||||
TINT_REFLECT(plane_1, params);
|
|
||||||
};
|
|
||||||
|
|
||||||
/// BindingsMap is a map where the key is the binding location of a
|
/// BindingsMap is a map where the key is the binding location of a
|
||||||
/// texture_external and the value is a struct containing the desired
|
/// texture_external and the value is a struct containing the desired
|
||||||
/// locations for new bindings expanded from the texture_external instance.
|
/// locations for new bindings expanded from the texture_external instance.
|
||||||
using BindingsMap = std::unordered_map<sem::BindingPoint, BindingPoints>;
|
using BindingsMap = sem::external_texture::BindingsMap;
|
||||||
|
|
||||||
/// NewBindingPoints is consumed by the MultiplanarExternalTexture transform.
|
/// NewBindingPoints is consumed by the MultiplanarExternalTexture transform.
|
||||||
/// Data holds information about location of each texture_external binding and
|
/// Data holds information about location of each texture_external binding and
|
||||||
|
|
|
@ -17,11 +17,15 @@
|
||||||
namespace tint::writer {
|
namespace tint::writer {
|
||||||
|
|
||||||
ArrayLengthFromUniformOptions::ArrayLengthFromUniformOptions() = default;
|
ArrayLengthFromUniformOptions::ArrayLengthFromUniformOptions() = default;
|
||||||
|
|
||||||
ArrayLengthFromUniformOptions::~ArrayLengthFromUniformOptions() = default;
|
ArrayLengthFromUniformOptions::~ArrayLengthFromUniformOptions() = default;
|
||||||
|
|
||||||
ArrayLengthFromUniformOptions::ArrayLengthFromUniformOptions(const ArrayLengthFromUniformOptions&) =
|
ArrayLengthFromUniformOptions::ArrayLengthFromUniformOptions(const ArrayLengthFromUniformOptions&) =
|
||||||
default;
|
default;
|
||||||
|
|
||||||
ArrayLengthFromUniformOptions& ArrayLengthFromUniformOptions::operator=(
|
ArrayLengthFromUniformOptions& ArrayLengthFromUniformOptions::operator=(
|
||||||
const ArrayLengthFromUniformOptions&) = default;
|
const ArrayLengthFromUniformOptions&) = default;
|
||||||
|
|
||||||
ArrayLengthFromUniformOptions::ArrayLengthFromUniformOptions(ArrayLengthFromUniformOptions&&) =
|
ArrayLengthFromUniformOptions::ArrayLengthFromUniformOptions(ArrayLengthFromUniformOptions&&) =
|
||||||
default;
|
default;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
// Copyright 2023 The Tint 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
|
||||||
|
//
|
||||||
|
// http://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.
|
||||||
|
|
||||||
|
#include "src/tint/writer/external_texture_options.h"
|
||||||
|
|
||||||
|
namespace tint::writer {
|
||||||
|
|
||||||
|
ExternalTextureOptions::ExternalTextureOptions() = default;
|
||||||
|
|
||||||
|
ExternalTextureOptions::~ExternalTextureOptions() = default;
|
||||||
|
|
||||||
|
ExternalTextureOptions::ExternalTextureOptions(const ExternalTextureOptions&) = default;
|
||||||
|
|
||||||
|
ExternalTextureOptions& ExternalTextureOptions::operator=(const ExternalTextureOptions&) = default;
|
||||||
|
|
||||||
|
ExternalTextureOptions::ExternalTextureOptions(ExternalTextureOptions&&) = default;
|
||||||
|
|
||||||
|
} // namespace tint::writer
|
|
@ -0,0 +1,57 @@
|
||||||
|
// Copyright 2023 The Tint 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
|
||||||
|
//
|
||||||
|
// http://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.
|
||||||
|
|
||||||
|
#ifndef SRC_TINT_WRITER_EXTERNAL_TEXTURE_OPTIONS_H_
|
||||||
|
#define SRC_TINT_WRITER_EXTERNAL_TEXTURE_OPTIONS_H_
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
#include "src/tint/sem/external_texture.h"
|
||||||
|
|
||||||
|
namespace tint::writer {
|
||||||
|
|
||||||
|
/// Options used to specify mappings of binding points for external textures.
|
||||||
|
class ExternalTextureOptions {
|
||||||
|
public:
|
||||||
|
/// This struct identifies the binding groups and locations for new bindings to
|
||||||
|
/// use when transforming a texture_external instance.
|
||||||
|
using BindingPoints = sem::external_texture::BindingPoints;
|
||||||
|
|
||||||
|
/// BindingsMap is a map where the key is the binding location of a
|
||||||
|
/// texture_external and the value is a struct containing the desired
|
||||||
|
/// locations for new bindings expanded from the texture_external instance.
|
||||||
|
using BindingsMap = sem::external_texture::BindingsMap;
|
||||||
|
|
||||||
|
/// Constructor
|
||||||
|
ExternalTextureOptions();
|
||||||
|
/// Destructor
|
||||||
|
~ExternalTextureOptions();
|
||||||
|
/// Copy constructor
|
||||||
|
ExternalTextureOptions(const ExternalTextureOptions&);
|
||||||
|
/// Copy assignment
|
||||||
|
/// @returns this ExternalTextureOptions
|
||||||
|
ExternalTextureOptions& operator=(const ExternalTextureOptions&);
|
||||||
|
/// Move constructor
|
||||||
|
ExternalTextureOptions(ExternalTextureOptions&&);
|
||||||
|
|
||||||
|
/// A map of new binding points to use.
|
||||||
|
BindingsMap bindings_map;
|
||||||
|
|
||||||
|
/// Reflect the fields of this class so that it can be used by tint::ForeachField()
|
||||||
|
TINT_REFLECT(bindings_map);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace tint::writer
|
||||||
|
|
||||||
|
#endif // SRC_TINT_WRITER_EXTERNAL_TEXTURE_OPTIONS_H_
|
|
@ -25,6 +25,7 @@
|
||||||
#include "src/tint/builtin/access.h"
|
#include "src/tint/builtin/access.h"
|
||||||
#include "src/tint/sem/binding_point.h"
|
#include "src/tint/sem/binding_point.h"
|
||||||
#include "src/tint/sem/sampler_texture_pair.h"
|
#include "src/tint/sem/sampler_texture_pair.h"
|
||||||
|
#include "src/tint/writer/external_texture_options.h"
|
||||||
#include "src/tint/writer/glsl/version.h"
|
#include "src/tint/writer/glsl/version.h"
|
||||||
#include "src/tint/writer/text.h"
|
#include "src/tint/writer/text.h"
|
||||||
|
|
||||||
|
@ -76,6 +77,9 @@ struct Options {
|
||||||
/// Set to 'true' to generates binding mappings for external textures
|
/// Set to 'true' to generates binding mappings for external textures
|
||||||
bool generate_external_texture_bindings = false;
|
bool generate_external_texture_bindings = false;
|
||||||
|
|
||||||
|
/// Options used in the binding mappings for external textures
|
||||||
|
ExternalTextureOptions external_texture_options = {};
|
||||||
|
|
||||||
/// The GLSL version to emit
|
/// The GLSL version to emit
|
||||||
Version version;
|
Version version;
|
||||||
|
|
||||||
|
@ -84,6 +88,7 @@ struct Options {
|
||||||
allow_collisions,
|
allow_collisions,
|
||||||
disable_workgroup_init,
|
disable_workgroup_init,
|
||||||
generate_external_texture_bindings,
|
generate_external_texture_bindings,
|
||||||
|
external_texture_options,
|
||||||
version);
|
version);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "src/tint/sem/binding_point.h"
|
#include "src/tint/sem/binding_point.h"
|
||||||
#include "src/tint/utils/bitset.h"
|
#include "src/tint/utils/bitset.h"
|
||||||
#include "src/tint/writer/array_length_from_uniform_options.h"
|
#include "src/tint/writer/array_length_from_uniform_options.h"
|
||||||
|
#include "src/tint/writer/external_texture_options.h"
|
||||||
#include "src/tint/writer/text.h"
|
#include "src/tint/writer/text.h"
|
||||||
|
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
|
@ -61,6 +62,9 @@ struct Options {
|
||||||
/// Set to 'true' to generates binding mappings for external textures
|
/// Set to 'true' to generates binding mappings for external textures
|
||||||
bool generate_external_texture_bindings = false;
|
bool generate_external_texture_bindings = false;
|
||||||
|
|
||||||
|
/// Options used in the binding mappings for external textures
|
||||||
|
ExternalTextureOptions external_texture_options = {};
|
||||||
|
|
||||||
/// Options used to specify a mapping of binding points to indices into a UBO
|
/// Options used to specify a mapping of binding points to indices into a UBO
|
||||||
/// from which to load buffer sizes.
|
/// from which to load buffer sizes.
|
||||||
ArrayLengthFromUniformOptions array_length_from_uniform = {};
|
ArrayLengthFromUniformOptions array_length_from_uniform = {};
|
||||||
|
@ -77,6 +81,7 @@ struct Options {
|
||||||
root_constant_binding_point,
|
root_constant_binding_point,
|
||||||
disable_workgroup_init,
|
disable_workgroup_init,
|
||||||
generate_external_texture_bindings,
|
generate_external_texture_bindings,
|
||||||
|
external_texture_options,
|
||||||
array_length_from_uniform);
|
array_length_from_uniform);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include "src/tint/reflection.h"
|
#include "src/tint/reflection.h"
|
||||||
#include "src/tint/writer/array_length_from_uniform_options.h"
|
#include "src/tint/writer/array_length_from_uniform_options.h"
|
||||||
|
#include "src/tint/writer/external_texture_options.h"
|
||||||
#include "src/tint/writer/text.h"
|
#include "src/tint/writer/text.h"
|
||||||
|
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
|
@ -65,6 +66,9 @@ struct Options {
|
||||||
/// Set to 'true' to generates binding mappings for external textures
|
/// Set to 'true' to generates binding mappings for external textures
|
||||||
bool generate_external_texture_bindings = false;
|
bool generate_external_texture_bindings = false;
|
||||||
|
|
||||||
|
/// Options used in the binding mappings for external textures
|
||||||
|
ExternalTextureOptions external_texture_options = {};
|
||||||
|
|
||||||
/// Options used to specify a mapping of binding points to indices into a UBO
|
/// Options used to specify a mapping of binding points to indices into a UBO
|
||||||
/// from which to load buffer sizes.
|
/// from which to load buffer sizes.
|
||||||
ArrayLengthFromUniformOptions array_length_from_uniform = {};
|
ArrayLengthFromUniformOptions array_length_from_uniform = {};
|
||||||
|
@ -76,6 +80,7 @@ struct Options {
|
||||||
emit_vertex_point_size,
|
emit_vertex_point_size,
|
||||||
disable_workgroup_init,
|
disable_workgroup_init,
|
||||||
generate_external_texture_bindings,
|
generate_external_texture_bindings,
|
||||||
|
external_texture_options,
|
||||||
array_length_from_uniform);
|
array_length_from_uniform);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "src/tint/reflection.h"
|
#include "src/tint/reflection.h"
|
||||||
|
#include "src/tint/writer/external_texture_options.h"
|
||||||
#include "src/tint/writer/writer.h"
|
#include "src/tint/writer/writer.h"
|
||||||
|
|
||||||
// Forward declarations
|
// Forward declarations
|
||||||
|
@ -48,6 +49,9 @@ struct Options {
|
||||||
/// Set to 'true' to generates binding mappings for external textures
|
/// Set to 'true' to generates binding mappings for external textures
|
||||||
bool generate_external_texture_bindings = false;
|
bool generate_external_texture_bindings = false;
|
||||||
|
|
||||||
|
/// Options used in the binding mappings for external textures
|
||||||
|
ExternalTextureOptions external_texture_options = {};
|
||||||
|
|
||||||
/// Set to `true` to initialize workgroup memory with OpConstantNull when
|
/// Set to `true` to initialize workgroup memory with OpConstantNull when
|
||||||
/// VK_KHR_zero_initialize_workgroup_memory is enabled.
|
/// VK_KHR_zero_initialize_workgroup_memory is enabled.
|
||||||
bool use_zero_initialize_workgroup_memory_extension = false;
|
bool use_zero_initialize_workgroup_memory_extension = false;
|
||||||
|
@ -57,6 +61,7 @@ struct Options {
|
||||||
emit_vertex_point_size,
|
emit_vertex_point_size,
|
||||||
disable_workgroup_init,
|
disable_workgroup_init,
|
||||||
generate_external_texture_bindings,
|
generate_external_texture_bindings,
|
||||||
|
external_texture_options,
|
||||||
use_zero_initialize_workgroup_memory_extension);
|
use_zero_initialize_workgroup_memory_extension);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue