Allow any GrProcessor to be a Uniform owner.

The `owner` field was previously restricted to GrFragmentProcessor,
which excludes other GrProcessor classes like GrXferProcessors from
using the uniform handlers.

Change-Id: I465190334f0fb1e27393108ab7b18d2d3089e69c
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/526461
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
John Stiles 2022-03-31 22:20:47 -04:00 committed by SkCQ
parent 3d3a510071
commit c6a8752e76
10 changed files with 20 additions and 19 deletions

View File

@ -186,7 +186,7 @@ uint32_t get_ubo_offset(uint32_t* currentOffset, SkSLType type, int arrayCount)
} // namespace
GrGLSLUniformHandler::UniformHandle GrSPIRVUniformHandler::internalAddUniformArray(
const GrFragmentProcessor* owner,
const GrProcessor* owner,
uint32_t visibility,
SkSLType type,
const char* name,

View File

@ -54,7 +54,7 @@ private:
const char* samplerVariable(SamplerHandle handle) const override;
skgpu::Swizzle samplerSwizzle(SamplerHandle handle) const override;
void appendUniformDecls(GrShaderFlags visibility, SkString*) const override;
UniformHandle internalAddUniformArray(const GrFragmentProcessor* owner,
UniformHandle internalAddUniformArray(const GrProcessor* owner,
uint32_t visibility,
SkSLType type,
const char* name,

View File

@ -26,7 +26,7 @@ bool valid_name(const char* name) {
}
GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray(
const GrFragmentProcessor* owner,
const GrProcessor* owner,
uint32_t visibility,
SkSLType type,
const char* name,

View File

@ -44,7 +44,7 @@ private:
, fUniforms(kUniformsPerBlock)
, fSamplers(kUniformsPerBlock) {}
UniformHandle internalAddUniformArray(const GrFragmentProcessor* owner,
UniformHandle internalAddUniformArray(const GrProcessor* owner,
uint32_t visibility,
SkSLType type,
const char* name,

View File

@ -10,7 +10,7 @@
#include "src/gpu/glsl/GrGLSL.h"
#include "src/gpu/glsl/GrGLSLShaderBuilder.h"
GrShaderVar GrGLSLUniformHandler::getUniformMapping(const GrFragmentProcessor& owner,
GrShaderVar GrGLSLUniformHandler::getUniformMapping(const GrProcessor& owner,
SkString rawName) const {
for (int i = this->numUniforms() - 1; i >= 0; i--) {
const UniformInfo& u = this->uniform(i);
@ -21,7 +21,7 @@ GrShaderVar GrGLSLUniformHandler::getUniformMapping(const GrFragmentProcessor& o
return GrShaderVar();
}
GrShaderVar GrGLSLUniformHandler::liftUniformToVertexShader(const GrFragmentProcessor& owner,
GrShaderVar GrGLSLUniformHandler::liftUniformToVertexShader(const GrProcessor& owner,
SkString rawName) {
for (int i = this->numUniforms() - 1; i >= 0; i--) {
UniformInfo& u = this->uniform(i);

View File

@ -17,6 +17,7 @@
class GrGLSLProgramBuilder;
class GrGLSLShaderBuilder;
class GrProcessor;
class GrSamplerState;
class GrSurfaceProxy;
@ -32,10 +33,10 @@ struct GrGLSLBuiltinUniformHandles {
class GrGLSLUniformHandler {
public:
struct UniformInfo {
GrShaderVar fVariable;
uint32_t fVisibility;
const GrFragmentProcessor* fOwner;
SkString fRawName;
GrShaderVar fVariable;
uint32_t fVisibility;
const GrProcessor* fOwner;
SkString fRawName;
};
virtual ~GrGLSLUniformHandler() {}
@ -50,7 +51,7 @@ public:
supported at this time. The actual uniform name will be mangled. If outName is not nullptr
then it will refer to the final uniform name after return. Use the addUniformArray variant
to add an array of uniforms. */
UniformHandle addUniform(const GrFragmentProcessor* owner,
UniformHandle addUniform(const GrProcessor* owner,
uint32_t visibility,
SkSLType type,
const char* name,
@ -59,7 +60,7 @@ public:
return this->addUniformArray(owner, visibility, type, name, 0, outName);
}
UniformHandle addUniformArray(const GrFragmentProcessor* owner,
UniformHandle addUniformArray(const GrProcessor* owner,
uint32_t visibility,
SkSLType type,
const char* name,
@ -85,11 +86,11 @@ public:
// Looks up a uniform that was added by 'owner' with the given 'rawName' (pre-mangling).
// If there is no such uniform, a variable with type kVoid is returned.
GrShaderVar getUniformMapping(const GrFragmentProcessor& owner, SkString rawName) const;
GrShaderVar getUniformMapping(const GrProcessor& owner, SkString rawName) const;
// Like getUniformMapping(), but if the uniform is found it also marks it as accessible in
// the vertex shader.
GrShaderVar liftUniformToVertexShader(const GrFragmentProcessor& owner, SkString rawName);
GrShaderVar liftUniformToVertexShader(const GrProcessor& owner, SkString rawName);
protected:
explicit GrGLSLUniformHandler(GrGLSLProgramBuilder* program) : fProgramBuilder(program) {}
@ -118,7 +119,7 @@ private:
return {};
}
virtual UniformHandle internalAddUniformArray(const GrFragmentProcessor* owner,
virtual UniformHandle internalAddUniformArray(const GrProcessor* owner,
uint32_t visibility,
SkSLType type,
const char* name,

View File

@ -62,7 +62,7 @@ private:
, fCurrentUBOMaxAlignment(0x0) {
}
UniformHandle internalAddUniformArray(const GrFragmentProcessor* owner,
UniformHandle internalAddUniformArray(const GrProcessor* owner,
uint32_t visibility,
SkSLType type,
const char* name,

View File

@ -178,7 +178,7 @@ static uint32_t get_ubo_aligned_offset(uint32_t* currentOffset,
}
GrGLSLUniformHandler::UniformHandle GrMtlUniformHandler::internalAddUniformArray(
const GrFragmentProcessor* owner,
const GrProcessor* owner,
uint32_t visibility,
SkSLType type,
const char* name,

View File

@ -198,7 +198,7 @@ GrVkUniformHandler::~GrVkUniformHandler() {
}
GrGLSLUniformHandler::UniformHandle GrVkUniformHandler::internalAddUniformArray(
const GrFragmentProcessor* owner,
const GrProcessor* owner,
uint32_t visibility,
SkSLType type,
const char* name,

View File

@ -102,7 +102,7 @@ private:
, fCurrentOffsets{0, 0} {
}
UniformHandle internalAddUniformArray(const GrFragmentProcessor* owner,
UniformHandle internalAddUniformArray(const GrProcessor* owner,
uint32_t visibility,
SkSLType type,
const char* name,