Commit 922bb6b3 authored by Laszlo Agocs's avatar Laszlo Agocs

Add a way to query texture (2D) limits

parent 43d7e48f
...@@ -142,6 +142,12 @@ void Window::customInit() ...@@ -142,6 +142,12 @@ void Window::customInit()
// Put the gpu mem allocator statistics to the profiling stream after doing // Put the gpu mem allocator statistics to the profiling stream after doing
// all the init. (where applicable) // all the init. (where applicable)
m_r->profiler()->addVMemAllocatorStats(); m_r->profiler()->addVMemAllocatorStats();
// Check some features/limits.
qDebug("isFeatureSupported(MultisampleTexture): %d", m_r->isFeatureSupported(QRhi::MultisampleTexture));
qDebug("isFeatureSupported(MultisampleRenderBuffer): %d", m_r->isFeatureSupported(QRhi::MultisampleRenderBuffer));
qDebug("Min 2D texture width/height: %d", m_r->resourceSizeLimit(QRhi::TextureSizeMin));
qDebug("Max 2D texture width/height: %d", m_r->resourceSizeLimit(QRhi::TextureSizeMax));
} }
void Window::customRelease() void Window::customRelease()
......
...@@ -694,6 +694,11 @@ bool QRhi::isFeatureSupported(QRhi::Feature feature) const ...@@ -694,6 +694,11 @@ bool QRhi::isFeatureSupported(QRhi::Feature feature) const
return d->isFeatureSupported(feature); return d->isFeatureSupported(feature);
} }
int QRhi::resourceSizeLimit(ResourceSizeLimit limit) const
{
return d->resourceSizeLimit(limit);
}
const QRhiNativeHandles *QRhi::nativeHandles() const QRhiNativeHandles *QRhi::nativeHandles()
{ {
return d->nativeHandles(); return d->nativeHandles();
......
...@@ -1116,6 +1116,11 @@ public: ...@@ -1116,6 +1116,11 @@ public:
MultisampleRenderBuffer MultisampleRenderBuffer
}; };
enum ResourceSizeLimit {
TextureSizeMin = 1,
TextureSizeMax
};
~QRhi(); ~QRhi();
static QRhi *create(Implementation impl, QRhiInitParams *params, Flags flags = Flags()); static QRhi *create(Implementation impl, QRhiInitParams *params, Flags flags = Flags());
...@@ -1255,6 +1260,7 @@ public: ...@@ -1255,6 +1260,7 @@ public:
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags = QRhiTexture::Flags()) const; bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags = QRhiTexture::Flags()) const;
bool isFeatureSupported(QRhi::Feature feature) const; bool isFeatureSupported(QRhi::Feature feature) const;
int resourceSizeLimit(ResourceSizeLimit limit) const;
// Returns a ptr to a QRhi<backend>NativeHandles struct. // Returns a ptr to a QRhi<backend>NativeHandles struct.
// Ownership of the native objects is not transfered. // Ownership of the native objects is not transfered.
......
...@@ -132,7 +132,8 @@ public: ...@@ -132,7 +132,8 @@ public:
virtual bool isYUpInFramebuffer() const = 0; virtual bool isYUpInFramebuffer() const = 0;
virtual QMatrix4x4 clipSpaceCorrMatrix() const = 0; virtual QMatrix4x4 clipSpaceCorrMatrix() const = 0;
virtual bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const = 0; virtual bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const = 0;
virtual bool isFeatureSupported(QRhi::Feature) const = 0; virtual bool isFeatureSupported(QRhi::Feature feature) const = 0;
virtual int resourceSizeLimit(QRhi::ResourceSizeLimit limit) const = 0;
virtual const QRhiNativeHandles *nativeHandles() = 0; virtual const QRhiNativeHandles *nativeHandles() = 0;
virtual void sendVMemStatsToProfiler(); virtual void sendVMemStatsToProfiler();
......
...@@ -267,6 +267,19 @@ bool QRhiD3D11::isFeatureSupported(QRhi::Feature feature) const ...@@ -267,6 +267,19 @@ bool QRhiD3D11::isFeatureSupported(QRhi::Feature feature) const
} }
} }
int QRhiD3D11::resourceSizeLimit(QRhi::ResourceSizeLimit limit) const
{
switch (limit) {
case QRhi::TextureSizeMin:
return 1;
case QRhi::TextureSizeMax:
return D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION;
default:
Q_UNREACHABLE();
return 0;
}
}
const QRhiNativeHandles *QRhiD3D11::nativeHandles() const QRhiNativeHandles *QRhiD3D11::nativeHandles()
{ {
return &nativeHandlesStruct; return &nativeHandlesStruct;
...@@ -1655,7 +1668,7 @@ bool QD3D11Texture::prepareBuild(QSize *adjustedSize) ...@@ -1655,7 +1668,7 @@ bool QD3D11Texture::prepareBuild(QSize *adjustedSize)
if (tex) if (tex)
release(); release();
const QSize size = m_pixelSize.isEmpty() ? QSize(16, 16) : m_pixelSize; const QSize size = m_pixelSize.isEmpty() ? QSize(1, 1) : m_pixelSize;
const bool isDepth = isDepthTextureFormat(m_format); const bool isDepth = isDepthTextureFormat(m_format);
const bool isCube = m_flags.testFlag(CubeMap); const bool isCube = m_flags.testFlag(CubeMap);
const bool hasMipMaps = m_flags.testFlag(MipMapped); const bool hasMipMaps = m_flags.testFlag(MipMapped);
......
...@@ -502,6 +502,7 @@ public: ...@@ -502,6 +502,7 @@ public:
QMatrix4x4 clipSpaceCorrMatrix() const override; QMatrix4x4 clipSpaceCorrMatrix() const override;
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override; bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override;
bool isFeatureSupported(QRhi::Feature feature) const override; bool isFeatureSupported(QRhi::Feature feature) const override;
int resourceSizeLimit(QRhi::ResourceSizeLimit limit) const override;
const QRhiNativeHandles *nativeHandles() override; const QRhiNativeHandles *nativeHandles() override;
void enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates); void enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates);
......
...@@ -117,6 +117,8 @@ bool QRhiGles2::create(QRhi::Flags flags) ...@@ -117,6 +117,8 @@ bool QRhiGles2::create(QRhi::Flags flags)
caps.msaaRenderBuffer = f->hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample) caps.msaaRenderBuffer = f->hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)
&& f->hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit); && f->hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit);
f->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &caps.maxTextureSize);
nativeHandlesStruct.context = ctx; nativeHandlesStruct.context = ctx;
return true; return true;
...@@ -267,6 +269,19 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const ...@@ -267,6 +269,19 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const
} }
} }
int QRhiGles2::resourceSizeLimit(QRhi::ResourceSizeLimit limit) const
{
switch (limit) {
case QRhi::TextureSizeMin:
return 1;
case QRhi::TextureSizeMax:
return caps.maxTextureSize;
default:
Q_UNREACHABLE();
return 0;
}
}
const QRhiNativeHandles *QRhiGles2::nativeHandles() const QRhiNativeHandles *QRhiGles2::nativeHandles()
{ {
return &nativeHandlesStruct; return &nativeHandlesStruct;
...@@ -1666,7 +1681,7 @@ bool QGles2Texture::prepareBuild(QSize *adjustedSize) ...@@ -1666,7 +1681,7 @@ bool QGles2Texture::prepareBuild(QSize *adjustedSize)
if (!rhiD->ensureContext()) if (!rhiD->ensureContext())
return false; return false;
QSize size = m_pixelSize.isEmpty() ? QSize(16, 16) : m_pixelSize; QSize size = m_pixelSize.isEmpty() ? QSize(1, 1) : m_pixelSize;
if (!rhiD->f->hasOpenGLFeature(QOpenGLFunctions::NPOTTextures) if (!rhiD->f->hasOpenGLFeature(QOpenGLFunctions::NPOTTextures)
&& (!isPowerOfTwo(size.width()) || !isPowerOfTwo(size.height()))) && (!isPowerOfTwo(size.width()) || !isPowerOfTwo(size.height())))
{ {
......
...@@ -511,6 +511,7 @@ public: ...@@ -511,6 +511,7 @@ public:
QMatrix4x4 clipSpaceCorrMatrix() const override; QMatrix4x4 clipSpaceCorrMatrix() const override;
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override; bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override;
bool isFeatureSupported(QRhi::Feature feature) const override; bool isFeatureSupported(QRhi::Feature feature) const override;
int resourceSizeLimit(QRhi::ResourceSizeLimit limit) const override;
const QRhiNativeHandles *nativeHandles() override; const QRhiNativeHandles *nativeHandles() override;
bool ensureContext(QSurface *surface = nullptr) const; bool ensureContext(QSurface *surface = nullptr) const;
...@@ -529,6 +530,7 @@ public: ...@@ -529,6 +530,7 @@ public:
// Multisample fb and blit are supported (GLES 3.0 or OpenGL 3.x). Not // Multisample fb and blit are supported (GLES 3.0 or OpenGL 3.x). Not
// the same as multisample textures! // the same as multisample textures!
bool msaaRenderBuffer = false; bool msaaRenderBuffer = false;
int maxTextureSize = 2048;
} caps; } caps;
bool inFrame = false; bool inFrame = false;
int finishedFrameCount = 0; int finishedFrameCount = 0;
......
...@@ -342,6 +342,19 @@ bool QRhiMetal::isFeatureSupported(QRhi::Feature feature) const ...@@ -342,6 +342,19 @@ bool QRhiMetal::isFeatureSupported(QRhi::Feature feature) const
} }
} }
int QRhiMetal::resourceSizeLimit(QRhi::ResourceSizeLimit limit) const
{
switch (limit) {
case QRhi::TextureSizeMin:
return 1;
case QRhi::TextureSizeMax:
return 16384; // ###
default:
Q_UNREACHABLE();
return 0;
}
}
const QRhiNativeHandles *QRhiMetal::nativeHandles() const QRhiNativeHandles *QRhiMetal::nativeHandles()
{ {
return &nativeHandlesStruct; return &nativeHandlesStruct;
...@@ -1549,7 +1562,7 @@ bool QMetalTexture::prepareBuild(QSize *adjustedSize) ...@@ -1549,7 +1562,7 @@ bool QMetalTexture::prepareBuild(QSize *adjustedSize)
if (d->tex) if (d->tex)
release(); release();
const QSize size = m_pixelSize.isEmpty() ? QSize(16, 16) : m_pixelSize; const QSize size = m_pixelSize.isEmpty() ? QSize(1, 1) : m_pixelSize;
const bool isCube = m_flags.testFlag(CubeMap); const bool isCube = m_flags.testFlag(CubeMap);
const bool hasMipMaps = m_flags.testFlag(MipMapped); const bool hasMipMaps = m_flags.testFlag(MipMapped);
......
...@@ -326,6 +326,7 @@ public: ...@@ -326,6 +326,7 @@ public:
QMatrix4x4 clipSpaceCorrMatrix() const override; QMatrix4x4 clipSpaceCorrMatrix() const override;
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override; bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override;
bool isFeatureSupported(QRhi::Feature feature) const override; bool isFeatureSupported(QRhi::Feature feature) const override;
int resourceSizeLimit(QRhi::ResourceSizeLimit limit) const override;
const QRhiNativeHandles *nativeHandles() override; const QRhiNativeHandles *nativeHandles() override;
void executeDeferredReleases(bool forced = false); void executeDeferredReleases(bool forced = false);
......
...@@ -2641,6 +2641,19 @@ bool QRhiVulkan::isFeatureSupported(QRhi::Feature feature) const ...@@ -2641,6 +2641,19 @@ bool QRhiVulkan::isFeatureSupported(QRhi::Feature feature) const
} }
} }
int QRhiVulkan::resourceSizeLimit(QRhi::ResourceSizeLimit limit) const
{
switch (limit) {
case QRhi::TextureSizeMin:
return 1;
case QRhi::TextureSizeMax:
return physDevProperties.limits.maxImageDimension2D;
default:
Q_UNREACHABLE();
return 0;
}
}
const QRhiNativeHandles *QRhiVulkan::nativeHandles() const QRhiNativeHandles *QRhiVulkan::nativeHandles()
{ {
return &nativeHandlesStruct; return &nativeHandlesStruct;
...@@ -3462,7 +3475,7 @@ bool QVkTexture::prepareBuild(QSize *adjustedSize) ...@@ -3462,7 +3475,7 @@ bool QVkTexture::prepareBuild(QSize *adjustedSize)
return false; return false;
} }
const QSize size = m_pixelSize.isEmpty() ? QSize(16, 16) : m_pixelSize; const QSize size = m_pixelSize.isEmpty() ? QSize(1, 1) : m_pixelSize;
const bool isCube = m_flags.testFlag(CubeMap); const bool isCube = m_flags.testFlag(CubeMap);
const bool hasMipMaps = m_flags.testFlag(MipMapped); const bool hasMipMaps = m_flags.testFlag(MipMapped);
......
...@@ -397,6 +397,7 @@ public: ...@@ -397,6 +397,7 @@ public:
QMatrix4x4 clipSpaceCorrMatrix() const override; QMatrix4x4 clipSpaceCorrMatrix() const override;
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override; bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override;
bool isFeatureSupported(QRhi::Feature feature) const override; bool isFeatureSupported(QRhi::Feature feature) const override;
int resourceSizeLimit(QRhi::ResourceSizeLimit limit) const override;
const QRhiNativeHandles *nativeHandles() override; const QRhiNativeHandles *nativeHandles() override;
void sendVMemStatsToProfiler() override; void sendVMemStatsToProfiler() override;
......
...@@ -2,8 +2,8 @@ prof report api (fed by a cbor stream) ...@@ -2,8 +2,8 @@ prof report api (fed by a cbor stream)
vk, gl: tex and other prof vk, gl: tex and other prof
vk, gl: debug: object names vk, gl: debug: object names
vk, gl: debug: markers (begin, end, msg) vk, gl: debug: markers (begin, end, msg)
mtl: max texture size
prof: report rb buf prof: report rb buf
max texture size stuff
multiwindow_threaded should demo pulling out the device and importing to another rhi multiwindow_threaded should demo pulling out the device and importing to another rhi
mtl: reduce set* mtl: reduce set*
advanced blend modes advanced blend modes
...@@ -53,6 +53,7 @@ dxc for d3d as an alternative to fxc? ...@@ -53,6 +53,7 @@ dxc for d3d as an alternative to fxc?
hlsl -> dxc -> spirv -> spirv-cross hmmm... hlsl -> dxc -> spirv -> spirv-cross hmmm...
+++ done +++ done
max texture size stuff
d3d: tex and other prof d3d: tex and other prof
plainqwindow examples should be reorganized into one (using examplefw) plainqwindow examples should be reorganized into one (using examplefw)
d3d: debug markers, object names d3d: debug markers, object names
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment