mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 08:27:05 +00:00
Add EmitVertexPointSizeTransform
EmitVertexPointSizeTransform is a Transformer that adds a PointSize builtin global output variable to the module which is assigned 1.0 as the new first statement for all vertex stage entry points. If the module does not contain a vertex pipeline stage entry point then then this transformer is a no-op. Bug: tint:321 Change-Id: I0e01236339d9fa1ceab3622af0931a1199c33b99 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/34561 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
685cb02ea8
commit
76d12f0f5a
@@ -59,6 +59,9 @@ std::ostream& operator<<(std::ostream& out, Builtin builtin) {
|
||||
out << "global_invocation_id";
|
||||
break;
|
||||
}
|
||||
case Builtin::kPointSize: {
|
||||
out << "pointsize";
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,11 @@ enum class Builtin {
|
||||
kFragDepth,
|
||||
kLocalInvocationId,
|
||||
kLocalInvocationIdx,
|
||||
kGlobalInvocationId
|
||||
kGlobalInvocationId,
|
||||
|
||||
// Below are not currently WGSL builtins, but are included in this enum as
|
||||
// they are used by certain backends.
|
||||
kPointSize,
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, Builtin builtin);
|
||||
|
||||
@@ -65,6 +65,15 @@ Function* Module::FindFunctionByNameAndStage(const std::string& name,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Module::HasStage(ast::PipelineStage stage) const {
|
||||
for (auto* func : functions_) {
|
||||
if (func->pipeline_stage() == stage) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Module::IsValid() const {
|
||||
for (auto* var : global_variables_) {
|
||||
if (var == nullptr || !var->IsValid()) {
|
||||
|
||||
@@ -83,6 +83,10 @@ class Module {
|
||||
/// @returns the associated function or nullptr if none exists
|
||||
Function* FindFunctionByNameAndStage(const std::string& name,
|
||||
PipelineStage stage) const;
|
||||
/// @param stage the pipeline stage
|
||||
/// @returns true if the module contains an entrypoint function with the given
|
||||
/// stage
|
||||
bool HasStage(PipelineStage stage) const;
|
||||
|
||||
/// @returns true if all required fields in the AST are present.
|
||||
bool IsValid() const;
|
||||
|
||||
Reference in New Issue
Block a user