Add nonconstant-array-index-support shader caps bit.

This will be used to allow us to safely make shaders which index into
arrays using expressions which cannot be determined at compile-time.
(ES2 cannot do this.)

Change-Id: Id291aa69bfb7cbc366de17013ee19a9061db3bf2
Bug: skia:8401
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/457196
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2021-10-11 12:31:28 -04:00 committed by SkCQ
parent bfd6b09dc9
commit 108cb0cfa3
6 changed files with 15 additions and 2 deletions

View File

@ -54,6 +54,7 @@ GrShaderCaps::GrShaderCaps(const GrContextOptions& options) {
fExternalTextureSupport = false;
fVertexIDSupport = false;
fInfinitySupport = false;
fNonconstantArrayIndexSupport = false;
fBitManipulationSupport = false;
fFloatIs32Bits = true;
fHalfIs32Bits = false;
@ -139,6 +140,7 @@ void GrShaderCaps::dumpJSON(SkJSONWriter* writer) const {
writer->appendBool("External texture support", fExternalTextureSupport);
writer->appendBool("sk_VertexID support", fVertexIDSupport);
writer->appendBool("Infinity support", fInfinitySupport);
writer->appendBool("Non-constant array index support", fNonconstantArrayIndexSupport);
writer->appendBool("Bit manipulation support", fBitManipulationSupport);
writer->appendBool("float == fp32", fFloatIs32Bits);
writer->appendBool("half == fp32", fHalfIs32Bits);

View File

@ -82,6 +82,12 @@ public:
// isinf() is defined, and floating point infinities are handled according to IEEE standards.
bool infinitySupport() const { return fInfinitySupport; }
// Returns true if `expr` in `myArray[expr]` can be any integer expression. If false, `expr`
// must be a constant-index-expression as defined in the OpenGL ES2 specification, Appendix A.5.
bool nonconstantArrayIndexSupport() const {
return fNonconstantArrayIndexSupport;
}
// frexp(), ldexp(), findMSB(), findLSB().
bool bitManipulationSupport() const { return fBitManipulationSupport; }
@ -289,6 +295,7 @@ private:
bool fExternalTextureSupport : 1;
bool fVertexIDSupport : 1;
bool fInfinitySupport : 1;
bool fNonconstantArrayIndexSupport : 1;
bool fBitManipulationSupport : 1;
bool fFloatIs32Bits : 1;
bool fHalfIs32Bits : 1;

View File

@ -245,6 +245,7 @@ void GrD3DCaps::initShaderCaps(int vendorID, const D3D12_FEATURE_DATA_D3D12_OPTI
shaderCaps->fInverseHyperbolicSupport = false;
shaderCaps->fVertexIDSupport = true;
shaderCaps->fInfinitySupport = true;
shaderCaps->fNonconstantArrayIndexSupport = true;
shaderCaps->fBitManipulationSupport = true;
shaderCaps->fFloatIs32Bits = true;

View File

@ -972,10 +972,11 @@ void GrGLCaps::initGLSL(const GrGLContextInfo& ctxInfo, const GrGLInterface* gli
}
if (GR_IS_GR_GL(standard)) {
shaderCaps->fInfinitySupport = true;
shaderCaps->fInfinitySupport = shaderCaps->fNonconstantArrayIndexSupport = true;
} else if (GR_IS_GR_GL_ES(standard) || GR_IS_GR_WEBGL(standard)) {
// Desktop GLSL 3.30 == ES GLSL 3.00.
shaderCaps->fInfinitySupport = ctxInfo.glslGeneration() >= k330_GrGLSLGeneration;
shaderCaps->fInfinitySupport = shaderCaps->fNonconstantArrayIndexSupport =
(ctxInfo.glslGeneration() >= k330_GrGLSLGeneration);
}
if (GR_IS_GR_GL(standard)) {

View File

@ -514,6 +514,7 @@ void GrMtlCaps::initShaderCaps() {
shaderCaps->fInverseHyperbolicSupport = true;
shaderCaps->fVertexIDSupport = true;
shaderCaps->fInfinitySupport = true;
shaderCaps->fNonconstantArrayIndexSupport = true;
// Metal uses IEEE float and half floats so assuming those values here.
shaderCaps->fFloatIs32Bits = true;

View File

@ -709,6 +709,7 @@ void GrVkCaps::initShaderCaps(const VkPhysicalDeviceProperties& properties,
shaderCaps->fInverseHyperbolicSupport = true;
shaderCaps->fVertexIDSupport = true;
shaderCaps->fInfinitySupport = true;
shaderCaps->fNonconstantArrayIndexSupport = true;
shaderCaps->fBitManipulationSupport = true;
// Assume the minimum precisions mandated by the SPIR-V spec.