Support signed integer attributes on QRHI
Previous UIntAttributes feature is renamed as IntAttributes. Change-Id: I4b4a87a0eebf37291da832605f7bee8fb2d4e62b Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
parent
0148c6925e
commit
2a7d6e2779
@ -591,12 +591,12 @@ Q_LOGGING_CATEGORY(QRHI_LOG_INFO, "qt.rhi.general")
|
||||
unsupported with OpenGL ES 2.0, while it will likely be supported everywhere
|
||||
else.
|
||||
|
||||
\value UIntAttributes Indicates that specifying input attributes with an unsigned
|
||||
integer type for a shader pipeline is supported. When not supported, build()
|
||||
will succeed but just show a warning message and the values of unsigned int
|
||||
type attributes will be broken. In practice this feature will be unsupported
|
||||
with OpenGL ES 2.0 and OpenGL 2.x, while it will likely be supported
|
||||
everywhere else.
|
||||
\value IntAttributes Indicates that specifying input attributes with
|
||||
signed and unsigned integer types for a shader pipeline is supported. When
|
||||
not supported, build() will succeed but just show a warning message and the
|
||||
values of the target attributes will be broken. In practice this feature
|
||||
will be unsupported with OpenGL ES 2.0 and OpenGL 2.x, while it will likely
|
||||
be supported everywhere else.
|
||||
|
||||
\value ScreenSpaceDerivatives Indicates that functions such as dFdx(),
|
||||
dFdy(), and fwidth() are supported in shaders.
|
||||
@ -1188,6 +1188,14 @@ QDebug operator<<(QDebug dbg, const QRhiVertexInputBinding &b)
|
||||
\value UNormByte4 Four component normalized unsigned byte vector
|
||||
\value UNormByte2 Two component normalized unsigned byte vector
|
||||
\value UNormByte Normalized unsigned byte
|
||||
\value UInt4 Four component unsigned integer vector
|
||||
\value UInt3 Three component unsigned integer vector
|
||||
\value UInt2 Two component unsigned integer vector
|
||||
\value UInt Unsigned integer
|
||||
\value SInt4 Four component signed integer vector
|
||||
\value SInt3 Three component signed integer vector
|
||||
\value SInt2 Two component signed integer vector
|
||||
\value SInt Signed integer
|
||||
*/
|
||||
|
||||
/*!
|
||||
|
@ -204,7 +204,11 @@ public:
|
||||
UInt4,
|
||||
UInt3,
|
||||
UInt2,
|
||||
UInt
|
||||
UInt,
|
||||
SInt4,
|
||||
SInt3,
|
||||
SInt2,
|
||||
SInt
|
||||
};
|
||||
|
||||
QRhiVertexInputAttribute() = default;
|
||||
@ -1470,7 +1474,7 @@ public:
|
||||
ReadBackNonBaseMipLevel,
|
||||
TexelFetch,
|
||||
RenderToNonBaseMipLevel,
|
||||
UIntAttributes,
|
||||
IntAttributes,
|
||||
ScreenSpaceDerivatives,
|
||||
ReadBackAnyTextureFormat
|
||||
};
|
||||
|
@ -525,7 +525,7 @@ bool QRhiD3D11::isFeatureSupported(QRhi::Feature feature) const
|
||||
return true;
|
||||
case QRhi::RenderToNonBaseMipLevel:
|
||||
return true;
|
||||
case QRhi::UIntAttributes:
|
||||
case QRhi::IntAttributes:
|
||||
return true;
|
||||
case QRhi::ScreenSpaceDerivatives:
|
||||
return true;
|
||||
@ -3591,6 +3591,14 @@ static inline DXGI_FORMAT toD3DAttributeFormat(QRhiVertexInputAttribute::Format
|
||||
return DXGI_FORMAT_R32G32_UINT;
|
||||
case QRhiVertexInputAttribute::UInt:
|
||||
return DXGI_FORMAT_R32_UINT;
|
||||
case QRhiVertexInputAttribute::SInt4:
|
||||
return DXGI_FORMAT_R32G32B32A32_SINT;
|
||||
case QRhiVertexInputAttribute::SInt3:
|
||||
return DXGI_FORMAT_R32G32B32_SINT;
|
||||
case QRhiVertexInputAttribute::SInt2:
|
||||
return DXGI_FORMAT_R32G32_SINT;
|
||||
case QRhiVertexInputAttribute::SInt:
|
||||
return DXGI_FORMAT_R32_SINT;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
return DXGI_FORMAT_R32G32B32A32_FLOAT;
|
||||
|
@ -553,7 +553,7 @@ bool QRhiGles2::create(QRhi::Flags flags)
|
||||
caps.nonBaseLevelFramebufferTexture = true;
|
||||
|
||||
caps.texelFetch = caps.ctxMajor >= 3; // 3.0 or ES 3.0
|
||||
caps.uintAttributes = caps.ctxMajor >= 3; // 3.0 or ES 3.0
|
||||
caps.intAttributes = caps.ctxMajor >= 3; // 3.0 or ES 3.0
|
||||
caps.screenSpaceDerivatives = f->hasOpenGLExtension(QOpenGLExtensions::StandardDerivatives);
|
||||
|
||||
// TO DO: We could also check for ARB_texture_multisample but it is not
|
||||
@ -928,8 +928,8 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const
|
||||
return caps.texelFetch;
|
||||
case QRhi::RenderToNonBaseMipLevel:
|
||||
return caps.nonBaseLevelFramebufferTexture;
|
||||
case QRhi::UIntAttributes:
|
||||
return caps.uintAttributes;
|
||||
case QRhi::IntAttributes:
|
||||
return caps.intAttributes;
|
||||
case QRhi::ScreenSpaceDerivatives:
|
||||
return caps.screenSpaceDerivatives;
|
||||
case QRhi::ReadBackAnyTextureFormat:
|
||||
@ -2253,18 +2253,34 @@ void QRhiGles2::executeCommandBuffer(QRhiCommandBuffer *cb)
|
||||
type = GL_UNSIGNED_INT;
|
||||
size = 1;
|
||||
break;
|
||||
case QRhiVertexInputAttribute::SInt4:
|
||||
type = GL_INT;
|
||||
size = 4;
|
||||
break;
|
||||
case QRhiVertexInputAttribute::SInt3:
|
||||
type = GL_INT;
|
||||
size = 3;
|
||||
break;
|
||||
case QRhiVertexInputAttribute::SInt2:
|
||||
type = GL_INT;
|
||||
size = 2;
|
||||
break;
|
||||
case QRhiVertexInputAttribute::SInt:
|
||||
type = GL_INT;
|
||||
size = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const int locationIdx = it->location();
|
||||
quint32 ofs = it->offset() + cmd.args.bindVertexBuffer.offset;
|
||||
if (type == GL_UNSIGNED_INT) {
|
||||
if (caps.uintAttributes) {
|
||||
if (type == GL_UNSIGNED_INT || type == GL_INT) {
|
||||
if (caps.intAttributes) {
|
||||
f->glVertexAttribIPointer(GLuint(locationIdx), size, type, stride,
|
||||
reinterpret_cast<const GLvoid *>(quintptr(ofs)));
|
||||
} else {
|
||||
qWarning("Current RHI backend does not support UIntAttributes. Check supported features.");
|
||||
qWarning("Current RHI backend does not support IntAttributes. Check supported features.");
|
||||
// This is a trick to disable this attribute
|
||||
if (locationIdx < TRACKED_ATTRIB_COUNT)
|
||||
enabledAttribArrays[locationIdx] = true;
|
||||
|
@ -880,7 +880,7 @@ public:
|
||||
properMapBuffer(false),
|
||||
nonBaseLevelFramebufferTexture(false),
|
||||
texelFetch(false),
|
||||
uintAttributes(true),
|
||||
intAttributes(true),
|
||||
screenSpaceDerivatives(false)
|
||||
{ }
|
||||
int ctxMajor;
|
||||
@ -921,7 +921,7 @@ public:
|
||||
uint properMapBuffer : 1;
|
||||
uint nonBaseLevelFramebufferTexture : 1;
|
||||
uint texelFetch : 1;
|
||||
uint uintAttributes : 1;
|
||||
uint intAttributes : 1;
|
||||
uint screenSpaceDerivatives : 1;
|
||||
} caps;
|
||||
QGles2SwapChain *currentSwapChain = nullptr;
|
||||
|
@ -562,7 +562,7 @@ bool QRhiMetal::isFeatureSupported(QRhi::Feature feature) const
|
||||
return true;
|
||||
case QRhi::RenderToNonBaseMipLevel:
|
||||
return true;
|
||||
case QRhi::UIntAttributes:
|
||||
case QRhi::IntAttributes:
|
||||
return true;
|
||||
case QRhi::ScreenSpaceDerivatives:
|
||||
return true;
|
||||
@ -3090,6 +3090,14 @@ static inline MTLVertexFormat toMetalAttributeFormat(QRhiVertexInputAttribute::F
|
||||
return MTLVertexFormatUInt2;
|
||||
case QRhiVertexInputAttribute::UInt:
|
||||
return MTLVertexFormatUInt;
|
||||
case QRhiVertexInputAttribute::SInt4:
|
||||
return MTLVertexFormatInt4;
|
||||
case QRhiVertexInputAttribute::SInt3:
|
||||
return MTLVertexFormatInt3;
|
||||
case QRhiVertexInputAttribute::SInt2:
|
||||
return MTLVertexFormatInt2;
|
||||
case QRhiVertexInputAttribute::SInt:
|
||||
return MTLVertexFormatInt;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
return MTLVertexFormatFloat4;
|
||||
|
@ -4099,7 +4099,7 @@ bool QRhiVulkan::isFeatureSupported(QRhi::Feature feature) const
|
||||
return true;
|
||||
case QRhi::RenderToNonBaseMipLevel:
|
||||
return true;
|
||||
case QRhi::UIntAttributes:
|
||||
case QRhi::IntAttributes:
|
||||
return true;
|
||||
case QRhi::ScreenSpaceDerivatives:
|
||||
return true;
|
||||
@ -4958,6 +4958,14 @@ static inline VkFormat toVkAttributeFormat(QRhiVertexInputAttribute::Format form
|
||||
return VK_FORMAT_R32G32_UINT;
|
||||
case QRhiVertexInputAttribute::UInt:
|
||||
return VK_FORMAT_R32_UINT;
|
||||
case QRhiVertexInputAttribute::SInt4:
|
||||
return VK_FORMAT_R32G32B32A32_SINT;
|
||||
case QRhiVertexInputAttribute::SInt3:
|
||||
return VK_FORMAT_R32G32B32_SINT;
|
||||
case QRhiVertexInputAttribute::SInt2:
|
||||
return VK_FORMAT_R32G32_SINT;
|
||||
case QRhiVertexInputAttribute::SInt:
|
||||
return VK_FORMAT_R32_SINT;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
return VK_FORMAT_R32G32B32A32_SFLOAT;
|
||||
|
Loading…
x
Reference in New Issue
Block a user