summaryrefslogtreecommitdiffstats
path: root/src/gui/rhi
diff options
context:
space:
mode:
authorInho Lee <inho.lee@qt.io>2020-09-16 14:38:58 +0200
committerInho Lee <inho.lee@qt.io>2020-09-21 11:36:14 +0200
commit2a7d6e2779bf0c7915396a8af0e1048d254debc3 (patch)
treea0f02b0039d9c437432152c22e593c4a6f816779 /src/gui/rhi
parent0148c6925ec3b6b9a9d2f57ae44fea292a6625e1 (diff)
Support signed integer attributes on QRHI
Previous UIntAttributes feature is renamed as IntAttributes. Change-Id: I4b4a87a0eebf37291da832605f7bee8fb2d4e62b Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/gui/rhi')
-rw-r--r--src/gui/rhi/qrhi.cpp20
-rw-r--r--src/gui/rhi/qrhi_p.h8
-rw-r--r--src/gui/rhi/qrhid3d11.cpp10
-rw-r--r--src/gui/rhi/qrhigles2.cpp28
-rw-r--r--src/gui/rhi/qrhigles2_p_p.h4
-rw-r--r--src/gui/rhi/qrhimetal.mm10
-rw-r--r--src/gui/rhi/qrhivulkan.cpp10
7 files changed, 71 insertions, 19 deletions
diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp
index 794e6a6891..6cc2b48922 100644
--- a/src/gui/rhi/qrhi.cpp
+++ b/src/gui/rhi/qrhi.cpp
@@ -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
*/
/*!
diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h
index 1e3540fa1f..d8e54fc9aa 100644
--- a/src/gui/rhi/qrhi_p.h
+++ b/src/gui/rhi/qrhi_p.h
@@ -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
};
diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp
index be79b26b9c..b9829ed263 100644
--- a/src/gui/rhi/qrhid3d11.cpp
+++ b/src/gui/rhi/qrhid3d11.cpp
@@ -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;
diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp
index 4440182264..39c01b1144 100644
--- a/src/gui/rhi/qrhigles2.cpp
+++ b/src/gui/rhi/qrhigles2.cpp
@@ -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;
diff --git a/src/gui/rhi/qrhigles2_p_p.h b/src/gui/rhi/qrhigles2_p_p.h
index 1410e6ac38..1f46d424a4 100644
--- a/src/gui/rhi/qrhigles2_p_p.h
+++ b/src/gui/rhi/qrhigles2_p_p.h
@@ -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;
diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm
index 2736377c78..a770c72a99 100644
--- a/src/gui/rhi/qrhimetal.mm
+++ b/src/gui/rhi/qrhimetal.mm
@@ -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;
diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp
index e4ad562805..64609671ab 100644
--- a/src/gui/rhi/qrhivulkan.cpp
+++ b/src/gui/rhi/qrhivulkan.cpp
@@ -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;