Pass the primProc and uniformHandler to tessellation shader back doors
Change-Id: I96e9fbaa2369b8b7c59bfcd6db7e09d23055d20e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/298771 Reviewed-by: John Stiles <johnstiles@google.com> Commit-Queue: Chris Dalton <csmartdalton@google.com>
This commit is contained in:
parent
34878824fc
commit
54c9093bb5
@ -92,16 +92,21 @@ private:
|
||||
return new Impl;
|
||||
}
|
||||
|
||||
SkString getTessControlShaderGLSL(const char* versionAndExtensionDecls,
|
||||
SkString getTessControlShaderGLSL(const GrGLSLPrimitiveProcessor*,
|
||||
const char* versionAndExtensionDecls,
|
||||
const GrGLSLUniformHandler&,
|
||||
const GrShaderCaps&) const override;
|
||||
SkString getTessEvaluationShaderGLSL(const char* versionAndExtensionDecls,
|
||||
SkString getTessEvaluationShaderGLSL(const GrGLSLPrimitiveProcessor*,
|
||||
const char* versionAndExtensionDecls,
|
||||
const GrGLSLUniformHandler&,
|
||||
const GrShaderCaps&) const override;
|
||||
|
||||
const SkMatrix fViewMatrix;
|
||||
};
|
||||
|
||||
SkString TessellationTestTriShader::getTessControlShaderGLSL(
|
||||
const char* versionAndExtensionDecls, const GrShaderCaps&) const {
|
||||
const GrGLSLPrimitiveProcessor*, const char* versionAndExtensionDecls,
|
||||
const GrGLSLUniformHandler&, const GrShaderCaps&) const {
|
||||
SkString code(versionAndExtensionDecls);
|
||||
code.append(R"(
|
||||
layout(vertices = 3) out;
|
||||
@ -119,7 +124,8 @@ SkString TessellationTestTriShader::getTessControlShaderGLSL(
|
||||
}
|
||||
|
||||
SkString TessellationTestTriShader::getTessEvaluationShaderGLSL(
|
||||
const char* versionAndExtensionDecls, const GrShaderCaps&) const {
|
||||
const GrGLSLPrimitiveProcessor*, const char* versionAndExtensionDecls,
|
||||
const GrGLSLUniformHandler&, const GrShaderCaps&) const {
|
||||
SkString code(versionAndExtensionDecls);
|
||||
code.append(R"(
|
||||
layout(triangles, equal_spacing, cw) in;
|
||||
@ -204,16 +210,21 @@ private:
|
||||
return new Impl;
|
||||
}
|
||||
|
||||
SkString getTessControlShaderGLSL(const char* versionAndExtensionDecls,
|
||||
SkString getTessControlShaderGLSL(const GrGLSLPrimitiveProcessor*,
|
||||
const char* versionAndExtensionDecls,
|
||||
const GrGLSLUniformHandler&,
|
||||
const GrShaderCaps&) const override;
|
||||
SkString getTessEvaluationShaderGLSL(const char* versionAndExtensionDecls,
|
||||
SkString getTessEvaluationShaderGLSL(const GrGLSLPrimitiveProcessor*,
|
||||
const char* versionAndExtensionDecls,
|
||||
const GrGLSLUniformHandler&,
|
||||
const GrShaderCaps&) const override;
|
||||
|
||||
const SkMatrix fViewMatrix;
|
||||
};
|
||||
|
||||
SkString TessellationTestRectShader::getTessControlShaderGLSL(
|
||||
const char* versionAndExtensionDecls, const GrShaderCaps& caps) const {
|
||||
const GrGLSLPrimitiveProcessor*, const char* versionAndExtensionDecls,
|
||||
const GrGLSLUniformHandler&, const GrShaderCaps& caps) const {
|
||||
SkString code(versionAndExtensionDecls);
|
||||
code.append(R"(
|
||||
layout(vertices = 1) out;
|
||||
@ -235,7 +246,8 @@ SkString TessellationTestRectShader::getTessControlShaderGLSL(
|
||||
}
|
||||
|
||||
SkString TessellationTestRectShader::getTessEvaluationShaderGLSL(
|
||||
const char* versionAndExtensionDecls, const GrShaderCaps& caps) const {
|
||||
const GrGLSLPrimitiveProcessor*, const char* versionAndExtensionDecls,
|
||||
const GrGLSLUniformHandler&, const GrShaderCaps& caps) const {
|
||||
SkString code(versionAndExtensionDecls);
|
||||
code.appendf(R"(
|
||||
layout(quads, equal_spacing, cw) in;
|
||||
|
@ -36,6 +36,7 @@ class GrCoordTransform;
|
||||
*/
|
||||
|
||||
class GrGLSLPrimitiveProcessor;
|
||||
class GrGLSLUniformHandler;
|
||||
|
||||
/**
|
||||
* GrPrimitiveProcessor defines an interface which all subclasses must implement. All
|
||||
@ -215,11 +216,15 @@ public:
|
||||
|
||||
// We use these methods as a temporary back door to inject OpenGL tessellation code. Once
|
||||
// tessellation is supported by SkSL we can remove these.
|
||||
virtual SkString getTessControlShaderGLSL(const char* versionAndExtensionDecls,
|
||||
virtual SkString getTessControlShaderGLSL(const GrGLSLPrimitiveProcessor*,
|
||||
const char* versionAndExtensionDecls,
|
||||
const GrGLSLUniformHandler&,
|
||||
const GrShaderCaps&) const {
|
||||
SK_ABORT("Not implemented.");
|
||||
}
|
||||
virtual SkString getTessEvaluationShaderGLSL(const char* versionAndExtensionDecls,
|
||||
virtual SkString getTessEvaluationShaderGLSL(const GrGLSLPrimitiveProcessor*,
|
||||
const char* versionAndExtensionDecls,
|
||||
const GrGLSLUniformHandler&,
|
||||
const GrShaderCaps&) const {
|
||||
SK_ABORT("Not implemented.");
|
||||
}
|
||||
|
@ -391,7 +391,8 @@ sk_sp<GrGLProgram> GrGLProgramBuilder::finalize(const GrGLPrecompiledProgram* pr
|
||||
}
|
||||
|
||||
SkString tessControlShader = primProc.getTessControlShaderGLSL(
|
||||
versionAndExtensionDecls.c_str(), *this->shaderCaps());
|
||||
fGeometryProcessor.get(), versionAndExtensionDecls.c_str(), fUniformHandler,
|
||||
*this->shaderCaps());
|
||||
if (!this->compileAndAttachShaders(tessControlShader.c_str(), programID,
|
||||
GR_GL_TESS_CONTROL_SHADER, &shadersToDelete,
|
||||
errorHandler)) {
|
||||
@ -400,7 +401,8 @@ sk_sp<GrGLProgram> GrGLProgramBuilder::finalize(const GrGLPrecompiledProgram* pr
|
||||
}
|
||||
|
||||
SkString tessEvaluationShader = primProc.getTessEvaluationShaderGLSL(
|
||||
versionAndExtensionDecls.c_str(), *this->shaderCaps());
|
||||
fGeometryProcessor.get(), versionAndExtensionDecls.c_str(), fUniformHandler,
|
||||
*this->shaderCaps());
|
||||
if (!this->compileAndAttachShaders(tessEvaluationShader.c_str(), programID,
|
||||
GR_GL_TESS_EVALUATION_SHADER, &shadersToDelete,
|
||||
errorHandler)) {
|
||||
|
@ -76,7 +76,9 @@ GrGLSLPrimitiveProcessor* GrStencilPathShader::createGLSLInstance(const GrShader
|
||||
return new Impl;
|
||||
}
|
||||
|
||||
SkString GrTessellateCubicShader::getTessControlShaderGLSL(const char* versionAndExtensionDecls,
|
||||
SkString GrTessellateCubicShader::getTessControlShaderGLSL(const GrGLSLPrimitiveProcessor*,
|
||||
const char* versionAndExtensionDecls,
|
||||
const GrGLSLUniformHandler&,
|
||||
const GrShaderCaps&) const {
|
||||
SkString code(versionAndExtensionDecls);
|
||||
code.append(kWangsFormulaCubicFn);
|
||||
@ -116,8 +118,9 @@ SkString GrTessellateCubicShader::getTessControlShaderGLSL(const char* versionAn
|
||||
return code;
|
||||
}
|
||||
|
||||
SkString GrTessellateCubicShader::getTessEvaluationShaderGLSL(const char* versionAndExtensionDecls,
|
||||
const GrShaderCaps&) const {
|
||||
SkString GrTessellateCubicShader::getTessEvaluationShaderGLSL(
|
||||
const GrGLSLPrimitiveProcessor*, const char* versionAndExtensionDecls,
|
||||
const GrGLSLUniformHandler&, const GrShaderCaps&) const {
|
||||
SkString code(versionAndExtensionDecls);
|
||||
code.append(kEvalCubicFn);
|
||||
code.append(R"(
|
||||
@ -148,7 +151,9 @@ SkString GrTessellateCubicShader::getTessEvaluationShaderGLSL(const char* versio
|
||||
return code;
|
||||
}
|
||||
|
||||
SkString GrTessellateWedgeShader::getTessControlShaderGLSL(const char* versionAndExtensionDecls,
|
||||
SkString GrTessellateWedgeShader::getTessControlShaderGLSL(const GrGLSLPrimitiveProcessor*,
|
||||
const char* versionAndExtensionDecls,
|
||||
const GrGLSLUniformHandler&,
|
||||
const GrShaderCaps&) const {
|
||||
SkString code(versionAndExtensionDecls);
|
||||
code.append(kWangsFormulaCubicFn);
|
||||
@ -184,8 +189,9 @@ SkString GrTessellateWedgeShader::getTessControlShaderGLSL(const char* versionAn
|
||||
return code;
|
||||
}
|
||||
|
||||
SkString GrTessellateWedgeShader::getTessEvaluationShaderGLSL(const char* versionAndExtensionDecls,
|
||||
const GrShaderCaps&) const {
|
||||
SkString GrTessellateWedgeShader::getTessEvaluationShaderGLSL(
|
||||
const GrGLSLPrimitiveProcessor*, const char* versionAndExtensionDecls,
|
||||
const GrGLSLUniformHandler&, const GrShaderCaps&) const {
|
||||
SkString code(versionAndExtensionDecls);
|
||||
code.append(kEvalCubicFn);
|
||||
code.append(R"(
|
||||
@ -231,21 +237,21 @@ sk_sp<const GrGpuBuffer> GrMiddleOutCubicShader::FindOrMakeMiddleOutIndexBuffer(
|
||||
|
||||
// One explicit triangle at index 0, and one middle-out cubic with kMaxResolveLevel line
|
||||
// segments beginning at index 3.
|
||||
constexpr static int indexCount = 3 + NumVerticesAtResolveLevel(kMaxResolveLevel);
|
||||
constexpr static int kIndexCount = 3 + NumVerticesAtResolveLevel(kMaxResolveLevel);
|
||||
auto buffer = resourceProvider->createBuffer(
|
||||
indexCount * sizeof(uint16_t), GrGpuBufferType::kIndex, kStatic_GrAccessPattern);
|
||||
kIndexCount * sizeof(uint16_t), GrGpuBufferType::kIndex, kStatic_GrAccessPattern);
|
||||
if (!buffer) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// We shouldn't bin and/or cache static buffers.
|
||||
SkASSERT(buffer->size() == indexCount * sizeof(uint16_t));
|
||||
SkASSERT(buffer->size() == kIndexCount * sizeof(uint16_t));
|
||||
SkASSERT(!buffer->resourcePriv().getScratchKey().isValid());
|
||||
auto indexData = static_cast<uint16_t*>(buffer->map());
|
||||
SkAutoTMalloc<uint16_t> stagingBuffer;
|
||||
if (!indexData) {
|
||||
SkASSERT(!buffer->isMapped());
|
||||
indexData = stagingBuffer.reset(indexCount);
|
||||
indexData = stagingBuffer.reset(kIndexCount);
|
||||
}
|
||||
|
||||
// Indices 0,1,2 contain special values that emit points P0, P1, and P2 respectively. (When the
|
||||
@ -268,12 +274,12 @@ sk_sp<const GrGpuBuffer> GrMiddleOutCubicShader::FindOrMakeMiddleOutIndexBuffer(
|
||||
indexData[i++] = (T += advance);
|
||||
} while (T != (1 << kMaxResolveLevel));
|
||||
}
|
||||
SkASSERT(i == indexCount);
|
||||
SkASSERT(i == kIndexCount);
|
||||
|
||||
if (buffer->isMapped()) {
|
||||
buffer->unmap();
|
||||
} else {
|
||||
buffer->updateData(stagingBuffer, indexCount * sizeof(uint16_t));
|
||||
buffer->updateData(stagingBuffer, kIndexCount * sizeof(uint16_t));
|
||||
}
|
||||
buffer->resourcePriv().setUniqueKey(gMiddleOutIndexBufferKey);
|
||||
return std::move(buffer);
|
||||
|
@ -52,9 +52,13 @@ public:
|
||||
const char* name() const override { return "tessellate_GrTessellateCubicShader"; }
|
||||
|
||||
private:
|
||||
SkString getTessControlShaderGLSL(const char* versionAndExtensionDecls,
|
||||
SkString getTessControlShaderGLSL(const GrGLSLPrimitiveProcessor*,
|
||||
const char* versionAndExtensionDecls,
|
||||
const GrGLSLUniformHandler&,
|
||||
const GrShaderCaps&) const override;
|
||||
SkString getTessEvaluationShaderGLSL(const char* versionAndExtensionDecls,
|
||||
SkString getTessEvaluationShaderGLSL(const GrGLSLPrimitiveProcessor*,
|
||||
const char* versionAndExtensionDecls,
|
||||
const GrGLSLUniformHandler&,
|
||||
const GrShaderCaps&) const override;
|
||||
};
|
||||
|
||||
@ -71,9 +75,13 @@ public:
|
||||
const char* name() const override { return "tessellate_GrTessellateWedgeShader"; }
|
||||
|
||||
private:
|
||||
SkString getTessControlShaderGLSL(const char* versionAndExtensionDecls,
|
||||
SkString getTessControlShaderGLSL(const GrGLSLPrimitiveProcessor*,
|
||||
const char* versionAndExtensionDecls,
|
||||
const GrGLSLUniformHandler&,
|
||||
const GrShaderCaps&) const override;
|
||||
SkString getTessEvaluationShaderGLSL(const char* versionAndExtensionDecls,
|
||||
SkString getTessEvaluationShaderGLSL(const GrGLSLPrimitiveProcessor*,
|
||||
const char* versionAndExtensionDecls,
|
||||
const GrGLSLUniformHandler&,
|
||||
const GrShaderCaps&) const override;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user