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:
parent
3d3a510071
commit
c6a8752e76
@ -186,7 +186,7 @@ uint32_t get_ubo_offset(uint32_t* currentOffset, SkSLType type, int arrayCount)
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
GrGLSLUniformHandler::UniformHandle GrSPIRVUniformHandler::internalAddUniformArray(
|
GrGLSLUniformHandler::UniformHandle GrSPIRVUniformHandler::internalAddUniformArray(
|
||||||
const GrFragmentProcessor* owner,
|
const GrProcessor* owner,
|
||||||
uint32_t visibility,
|
uint32_t visibility,
|
||||||
SkSLType type,
|
SkSLType type,
|
||||||
const char* name,
|
const char* name,
|
||||||
|
@ -54,7 +54,7 @@ private:
|
|||||||
const char* samplerVariable(SamplerHandle handle) const override;
|
const char* samplerVariable(SamplerHandle handle) const override;
|
||||||
skgpu::Swizzle samplerSwizzle(SamplerHandle handle) const override;
|
skgpu::Swizzle samplerSwizzle(SamplerHandle handle) const override;
|
||||||
void appendUniformDecls(GrShaderFlags visibility, SkString*) const override;
|
void appendUniformDecls(GrShaderFlags visibility, SkString*) const override;
|
||||||
UniformHandle internalAddUniformArray(const GrFragmentProcessor* owner,
|
UniformHandle internalAddUniformArray(const GrProcessor* owner,
|
||||||
uint32_t visibility,
|
uint32_t visibility,
|
||||||
SkSLType type,
|
SkSLType type,
|
||||||
const char* name,
|
const char* name,
|
||||||
|
@ -26,7 +26,7 @@ bool valid_name(const char* name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray(
|
GrGLSLUniformHandler::UniformHandle GrGLUniformHandler::internalAddUniformArray(
|
||||||
const GrFragmentProcessor* owner,
|
const GrProcessor* owner,
|
||||||
uint32_t visibility,
|
uint32_t visibility,
|
||||||
SkSLType type,
|
SkSLType type,
|
||||||
const char* name,
|
const char* name,
|
||||||
|
@ -44,7 +44,7 @@ private:
|
|||||||
, fUniforms(kUniformsPerBlock)
|
, fUniforms(kUniformsPerBlock)
|
||||||
, fSamplers(kUniformsPerBlock) {}
|
, fSamplers(kUniformsPerBlock) {}
|
||||||
|
|
||||||
UniformHandle internalAddUniformArray(const GrFragmentProcessor* owner,
|
UniformHandle internalAddUniformArray(const GrProcessor* owner,
|
||||||
uint32_t visibility,
|
uint32_t visibility,
|
||||||
SkSLType type,
|
SkSLType type,
|
||||||
const char* name,
|
const char* name,
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "src/gpu/glsl/GrGLSL.h"
|
#include "src/gpu/glsl/GrGLSL.h"
|
||||||
#include "src/gpu/glsl/GrGLSLShaderBuilder.h"
|
#include "src/gpu/glsl/GrGLSLShaderBuilder.h"
|
||||||
|
|
||||||
GrShaderVar GrGLSLUniformHandler::getUniformMapping(const GrFragmentProcessor& owner,
|
GrShaderVar GrGLSLUniformHandler::getUniformMapping(const GrProcessor& owner,
|
||||||
SkString rawName) const {
|
SkString rawName) const {
|
||||||
for (int i = this->numUniforms() - 1; i >= 0; i--) {
|
for (int i = this->numUniforms() - 1; i >= 0; i--) {
|
||||||
const UniformInfo& u = this->uniform(i);
|
const UniformInfo& u = this->uniform(i);
|
||||||
@ -21,7 +21,7 @@ GrShaderVar GrGLSLUniformHandler::getUniformMapping(const GrFragmentProcessor& o
|
|||||||
return GrShaderVar();
|
return GrShaderVar();
|
||||||
}
|
}
|
||||||
|
|
||||||
GrShaderVar GrGLSLUniformHandler::liftUniformToVertexShader(const GrFragmentProcessor& owner,
|
GrShaderVar GrGLSLUniformHandler::liftUniformToVertexShader(const GrProcessor& owner,
|
||||||
SkString rawName) {
|
SkString rawName) {
|
||||||
for (int i = this->numUniforms() - 1; i >= 0; i--) {
|
for (int i = this->numUniforms() - 1; i >= 0; i--) {
|
||||||
UniformInfo& u = this->uniform(i);
|
UniformInfo& u = this->uniform(i);
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
class GrGLSLProgramBuilder;
|
class GrGLSLProgramBuilder;
|
||||||
class GrGLSLShaderBuilder;
|
class GrGLSLShaderBuilder;
|
||||||
|
class GrProcessor;
|
||||||
class GrSamplerState;
|
class GrSamplerState;
|
||||||
class GrSurfaceProxy;
|
class GrSurfaceProxy;
|
||||||
|
|
||||||
@ -32,10 +33,10 @@ struct GrGLSLBuiltinUniformHandles {
|
|||||||
class GrGLSLUniformHandler {
|
class GrGLSLUniformHandler {
|
||||||
public:
|
public:
|
||||||
struct UniformInfo {
|
struct UniformInfo {
|
||||||
GrShaderVar fVariable;
|
GrShaderVar fVariable;
|
||||||
uint32_t fVisibility;
|
uint32_t fVisibility;
|
||||||
const GrFragmentProcessor* fOwner;
|
const GrProcessor* fOwner;
|
||||||
SkString fRawName;
|
SkString fRawName;
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual ~GrGLSLUniformHandler() {}
|
virtual ~GrGLSLUniformHandler() {}
|
||||||
@ -50,7 +51,7 @@ public:
|
|||||||
supported at this time. The actual uniform name will be mangled. If outName is not nullptr
|
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
|
then it will refer to the final uniform name after return. Use the addUniformArray variant
|
||||||
to add an array of uniforms. */
|
to add an array of uniforms. */
|
||||||
UniformHandle addUniform(const GrFragmentProcessor* owner,
|
UniformHandle addUniform(const GrProcessor* owner,
|
||||||
uint32_t visibility,
|
uint32_t visibility,
|
||||||
SkSLType type,
|
SkSLType type,
|
||||||
const char* name,
|
const char* name,
|
||||||
@ -59,7 +60,7 @@ public:
|
|||||||
return this->addUniformArray(owner, visibility, type, name, 0, outName);
|
return this->addUniformArray(owner, visibility, type, name, 0, outName);
|
||||||
}
|
}
|
||||||
|
|
||||||
UniformHandle addUniformArray(const GrFragmentProcessor* owner,
|
UniformHandle addUniformArray(const GrProcessor* owner,
|
||||||
uint32_t visibility,
|
uint32_t visibility,
|
||||||
SkSLType type,
|
SkSLType type,
|
||||||
const char* name,
|
const char* name,
|
||||||
@ -85,11 +86,11 @@ public:
|
|||||||
|
|
||||||
// Looks up a uniform that was added by 'owner' with the given 'rawName' (pre-mangling).
|
// 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.
|
// 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
|
// Like getUniformMapping(), but if the uniform is found it also marks it as accessible in
|
||||||
// the vertex shader.
|
// the vertex shader.
|
||||||
GrShaderVar liftUniformToVertexShader(const GrFragmentProcessor& owner, SkString rawName);
|
GrShaderVar liftUniformToVertexShader(const GrProcessor& owner, SkString rawName);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit GrGLSLUniformHandler(GrGLSLProgramBuilder* program) : fProgramBuilder(program) {}
|
explicit GrGLSLUniformHandler(GrGLSLProgramBuilder* program) : fProgramBuilder(program) {}
|
||||||
@ -118,7 +119,7 @@ private:
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual UniformHandle internalAddUniformArray(const GrFragmentProcessor* owner,
|
virtual UniformHandle internalAddUniformArray(const GrProcessor* owner,
|
||||||
uint32_t visibility,
|
uint32_t visibility,
|
||||||
SkSLType type,
|
SkSLType type,
|
||||||
const char* name,
|
const char* name,
|
||||||
|
@ -62,7 +62,7 @@ private:
|
|||||||
, fCurrentUBOMaxAlignment(0x0) {
|
, fCurrentUBOMaxAlignment(0x0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
UniformHandle internalAddUniformArray(const GrFragmentProcessor* owner,
|
UniformHandle internalAddUniformArray(const GrProcessor* owner,
|
||||||
uint32_t visibility,
|
uint32_t visibility,
|
||||||
SkSLType type,
|
SkSLType type,
|
||||||
const char* name,
|
const char* name,
|
||||||
|
@ -178,7 +178,7 @@ static uint32_t get_ubo_aligned_offset(uint32_t* currentOffset,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GrGLSLUniformHandler::UniformHandle GrMtlUniformHandler::internalAddUniformArray(
|
GrGLSLUniformHandler::UniformHandle GrMtlUniformHandler::internalAddUniformArray(
|
||||||
const GrFragmentProcessor* owner,
|
const GrProcessor* owner,
|
||||||
uint32_t visibility,
|
uint32_t visibility,
|
||||||
SkSLType type,
|
SkSLType type,
|
||||||
const char* name,
|
const char* name,
|
||||||
|
@ -198,7 +198,7 @@ GrVkUniformHandler::~GrVkUniformHandler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GrGLSLUniformHandler::UniformHandle GrVkUniformHandler::internalAddUniformArray(
|
GrGLSLUniformHandler::UniformHandle GrVkUniformHandler::internalAddUniformArray(
|
||||||
const GrFragmentProcessor* owner,
|
const GrProcessor* owner,
|
||||||
uint32_t visibility,
|
uint32_t visibility,
|
||||||
SkSLType type,
|
SkSLType type,
|
||||||
const char* name,
|
const char* name,
|
||||||
|
@ -102,7 +102,7 @@ private:
|
|||||||
, fCurrentOffsets{0, 0} {
|
, fCurrentOffsets{0, 0} {
|
||||||
}
|
}
|
||||||
|
|
||||||
UniformHandle internalAddUniformArray(const GrFragmentProcessor* owner,
|
UniformHandle internalAddUniformArray(const GrProcessor* owner,
|
||||||
uint32_t visibility,
|
uint32_t visibility,
|
||||||
SkSLType type,
|
SkSLType type,
|
||||||
const char* name,
|
const char* name,
|
||||||
|
Loading…
Reference in New Issue
Block a user