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()
// Put the gpu mem allocator statistics to the profiling stream after doing
// all the init. (where applicable)
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()
......
......@@ -694,6 +694,11 @@ bool QRhi::isFeatureSupported(QRhi::Feature feature) const
return d->isFeatureSupported(feature);
}
int QRhi::resourceSizeLimit(ResourceSizeLimit limit) const
{
return d->resourceSizeLimit(limit);
}
const QRhiNativeHandles *QRhi::nativeHandles()
{
return d->nativeHandles();
......
......@@ -1116,6 +1116,11 @@ public:
MultisampleRenderBuffer
};
enum ResourceSizeLimit {
TextureSizeMin = 1,
TextureSizeMax
};
~QRhi();
static QRhi *create(Implementation impl, QRhiInitParams *params, Flags flags = Flags());
......@@ -1255,6 +1260,7 @@ public:
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags = QRhiTexture::Flags()) const;
bool isFeatureSupported(QRhi::Feature feature) const;
int resourceSizeLimit(ResourceSizeLimit limit) const;
// Returns a ptr to a QRhi<backend>NativeHandles struct.
// Ownership of the native objects is not transfered.
......
......@@ -132,7 +132,8 @@ public:
virtual bool isYUpInFramebuffer() const = 0;
virtual QMatrix4x4 clipSpaceCorrMatrix() 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 void sendVMemStatsToProfiler();
......
......@@ -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()
{
return &nativeHandlesStruct;
......@@ -1655,7 +1668,7 @@ bool QD3D11Texture::prepareBuild(QSize *adjustedSize)
if (tex)
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 isCube = m_flags.testFlag(CubeMap);
const bool hasMipMaps = m_flags.testFlag(MipMapped);
......
......@@ -502,6 +502,7 @@ public:
QMatrix4x4 clipSpaceCorrMatrix() const override;
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override;
bool isFeatureSupported(QRhi::Feature feature) const override;
int resourceSizeLimit(QRhi::ResourceSizeLimit limit) const override;
const QRhiNativeHandles *nativeHandles() override;
void enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates);
......
......@@ -117,6 +117,8 @@ bool QRhiGles2::create(QRhi::Flags flags)
caps.msaaRenderBuffer = f->hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)
&& f->hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit);
f->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &caps.maxTextureSize);
nativeHandlesStruct.context = ctx;
return true;
......@@ -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()
{
return &nativeHandlesStruct;
......@@ -1666,7 +1681,7 @@ bool QGles2Texture::prepareBuild(QSize *adjustedSize)
if (!rhiD->ensureContext())
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)
&& (!isPowerOfTwo(size.width()) || !isPowerOfTwo(size.height())))
{
......
......@@ -511,6 +511,7 @@ public:
QMatrix4x4 clipSpaceCorrMatrix() const override;
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override;
bool isFeatureSupported(QRhi::Feature feature) const override;
int resourceSizeLimit(QRhi::ResourceSizeLimit limit) const override;
const QRhiNativeHandles *nativeHandles() override;
bool ensureContext(QSurface *surface = nullptr) const;
......@@ -529,6 +530,7 @@ public:
// Multisample fb and blit are supported (GLES 3.0 or OpenGL 3.x). Not
// the same as multisample textures!
bool msaaRenderBuffer = false;
int maxTextureSize = 2048;
} caps;
bool inFrame = false;
int finishedFrameCount = 0;
......
......@@ -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()
{
return &nativeHandlesStruct;
......@@ -1549,7 +1562,7 @@ bool QMetalTexture::prepareBuild(QSize *adjustedSize)
if (d->tex)
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 hasMipMaps = m_flags.testFlag(MipMapped);
......
......@@ -326,6 +326,7 @@ public:
QMatrix4x4 clipSpaceCorrMatrix() const override;
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override;
bool isFeatureSupported(QRhi::Feature feature) const override;
int resourceSizeLimit(QRhi::ResourceSizeLimit limit) const override;
const QRhiNativeHandles *nativeHandles() override;
void executeDeferredReleases(bool forced = false);
......
......@@ -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()
{
return &nativeHandlesStruct;
......@@ -3462,7 +3475,7 @@ bool QVkTexture::prepareBuild(QSize *adjustedSize)
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 hasMipMaps = m_flags.testFlag(MipMapped);
......
......@@ -397,6 +397,7 @@ public:
QMatrix4x4 clipSpaceCorrMatrix() const override;
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override;
bool isFeatureSupported(QRhi::Feature feature) const override;
int resourceSizeLimit(QRhi::ResourceSizeLimit limit) const override;
const QRhiNativeHandles *nativeHandles() override;
void sendVMemStatsToProfiler() override;
......
......@@ -2,8 +2,8 @@ prof report api (fed by a cbor stream)
vk, gl: tex and other prof
vk, gl: debug: object names
vk, gl: debug: markers (begin, end, msg)
mtl: max texture size
prof: report rb buf
max texture size stuff
multiwindow_threaded should demo pulling out the device and importing to another rhi
mtl: reduce set*
advanced blend modes
......@@ -53,6 +53,7 @@ dxc for d3d as an alternative to fxc?
hlsl -> dxc -> spirv -> spirv-cross hmmm...
+++ done
max texture size stuff
d3d: tex and other prof
plainqwindow examples should be reorganized into one (using examplefw)
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