rhi: Enable sampler address mode W in the API
Internally this is already supported by all backends. The frontend was just not exposing addressW, instead defaulting to the (arbitrarily chosen) ClampToEdge. Add the parameter to newSampler(), but make it optional, defaulting to the more natural Repeat (because that's what one would get with OpenGL for WRAP_R by default) Change-Id: I0b991d8b649db37d4da86ac8e98ab7845601cf67 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
This commit is contained in:
parent
037369cc4d
commit
a5be18cc7d
@ -2297,11 +2297,10 @@ bool QRhiTexture::buildFrom(QRhiTexture::NativeTexture src)
|
||||
*/
|
||||
QRhiSampler::QRhiSampler(QRhiImplementation *rhi,
|
||||
Filter magFilter_, Filter minFilter_, Filter mipmapMode_,
|
||||
AddressMode u_, AddressMode v_)
|
||||
AddressMode u_, AddressMode v_, AddressMode w_)
|
||||
: QRhiResource(rhi),
|
||||
m_magFilter(magFilter_), m_minFilter(minFilter_), m_mipmapMode(mipmapMode_),
|
||||
m_addressU(u_), m_addressV(v_),
|
||||
m_addressW(QRhiSampler::ClampToEdge),
|
||||
m_addressU(u_), m_addressV(v_), m_addressW(w_),
|
||||
m_compareOp(QRhiSampler::Never)
|
||||
{
|
||||
}
|
||||
@ -5321,16 +5320,19 @@ QRhiTexture *QRhi::newTexture(QRhiTexture::Format format,
|
||||
|
||||
/*!
|
||||
\return a new sampler with the specified magnification filter \a magFilter,
|
||||
minification filter \a minFilter, mipmapping mode \a mipmapMpde, and S/T
|
||||
addressing modes \a u and \a v.
|
||||
minification filter \a minFilter, mipmapping mode \a mipmapMode, and the
|
||||
addressing (wrap) modes \a addressU, \a addressV, and \a addressW.
|
||||
|
||||
\sa QRhiResource::release()
|
||||
*/
|
||||
QRhiSampler *QRhi::newSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter,
|
||||
QRhiSampler *QRhi::newSampler(QRhiSampler::Filter magFilter,
|
||||
QRhiSampler::Filter minFilter,
|
||||
QRhiSampler::Filter mipmapMode,
|
||||
QRhiSampler:: AddressMode u, QRhiSampler::AddressMode v)
|
||||
QRhiSampler::AddressMode addressU,
|
||||
QRhiSampler::AddressMode addressV,
|
||||
QRhiSampler::AddressMode addressW)
|
||||
{
|
||||
return d->createSampler(magFilter, minFilter, mipmapMode, u, v);
|
||||
return d->createSampler(magFilter, minFilter, mipmapMode, addressU, addressV, addressW);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -850,7 +850,7 @@ public:
|
||||
protected:
|
||||
QRhiSampler(QRhiImplementation *rhi,
|
||||
Filter magFilter_, Filter minFilter_, Filter mipmapMode_,
|
||||
AddressMode u_, AddressMode v_);
|
||||
AddressMode u_, AddressMode v_, AddressMode w_);
|
||||
Filter m_magFilter;
|
||||
Filter m_minFilter;
|
||||
Filter m_mipmapMode;
|
||||
@ -1474,9 +1474,12 @@ public:
|
||||
int sampleCount = 1,
|
||||
QRhiTexture::Flags flags = QRhiTexture::Flags());
|
||||
|
||||
QRhiSampler *newSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter,
|
||||
QRhiSampler *newSampler(QRhiSampler::Filter magFilter,
|
||||
QRhiSampler::Filter minFilter,
|
||||
QRhiSampler::Filter mipmapMode,
|
||||
QRhiSampler::AddressMode u, QRhiSampler::AddressMode v);
|
||||
QRhiSampler::AddressMode addressU,
|
||||
QRhiSampler::AddressMode addressV,
|
||||
QRhiSampler::AddressMode addressW = QRhiSampler::Repeat);
|
||||
|
||||
QRhiTextureRenderTarget *newTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc,
|
||||
QRhiTextureRenderTarget::Flags flags = QRhiTextureRenderTarget::Flags());
|
||||
|
@ -85,9 +85,12 @@ public:
|
||||
const QSize &pixelSize,
|
||||
int sampleCount,
|
||||
QRhiTexture::Flags flags) = 0;
|
||||
virtual QRhiSampler *createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter,
|
||||
virtual QRhiSampler *createSampler(QRhiSampler::Filter magFilter,
|
||||
QRhiSampler::Filter minFilter,
|
||||
QRhiSampler::Filter mipmapMode,
|
||||
QRhiSampler:: AddressMode u, QRhiSampler::AddressMode v) = 0;
|
||||
QRhiSampler:: AddressMode u,
|
||||
QRhiSampler::AddressMode v,
|
||||
QRhiSampler::AddressMode w) = 0;
|
||||
|
||||
virtual QRhiTextureRenderTarget *createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc,
|
||||
QRhiTextureRenderTarget::Flags flags) = 0;
|
||||
|
@ -527,9 +527,9 @@ QRhiTexture *QRhiD3D11::createTexture(QRhiTexture::Format format, const QSize &p
|
||||
|
||||
QRhiSampler *QRhiD3D11::createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter,
|
||||
QRhiSampler::Filter mipmapMode,
|
||||
QRhiSampler::AddressMode u, QRhiSampler::AddressMode v)
|
||||
QRhiSampler::AddressMode u, QRhiSampler::AddressMode v, QRhiSampler::AddressMode w)
|
||||
{
|
||||
return new QD3D11Sampler(this, magFilter, minFilter, mipmapMode, u, v);
|
||||
return new QD3D11Sampler(this, magFilter, minFilter, mipmapMode, u, v, w);
|
||||
}
|
||||
|
||||
QRhiTextureRenderTarget *QRhiD3D11::createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc,
|
||||
@ -2768,8 +2768,8 @@ ID3D11UnorderedAccessView *QD3D11Texture::unorderedAccessViewForLevel(int level)
|
||||
}
|
||||
|
||||
QD3D11Sampler::QD3D11Sampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode,
|
||||
AddressMode u, AddressMode v)
|
||||
: QRhiSampler(rhi, magFilter, minFilter, mipmapMode, u, v)
|
||||
AddressMode u, AddressMode v, AddressMode w)
|
||||
: QRhiSampler(rhi, magFilter, minFilter, mipmapMode, u, v, w)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ struct QD3D11Texture : public QRhiTexture
|
||||
struct QD3D11Sampler : public QRhiSampler
|
||||
{
|
||||
QD3D11Sampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode,
|
||||
AddressMode u, AddressMode v);
|
||||
AddressMode u, AddressMode v, AddressMode w);
|
||||
~QD3D11Sampler();
|
||||
void release() override;
|
||||
bool build() override;
|
||||
@ -559,9 +559,12 @@ public:
|
||||
const QSize &pixelSize,
|
||||
int sampleCount,
|
||||
QRhiTexture::Flags flags) override;
|
||||
QRhiSampler *createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter,
|
||||
QRhiSampler *createSampler(QRhiSampler::Filter magFilter,
|
||||
QRhiSampler::Filter minFilter,
|
||||
QRhiSampler::Filter mipmapMode,
|
||||
QRhiSampler:: AddressMode u, QRhiSampler::AddressMode v) override;
|
||||
QRhiSampler:: AddressMode u,
|
||||
QRhiSampler::AddressMode v,
|
||||
QRhiSampler::AddressMode w) override;
|
||||
|
||||
QRhiTextureRenderTarget *createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc,
|
||||
QRhiTextureRenderTarget::Flags flags) override;
|
||||
|
@ -838,9 +838,9 @@ QRhiTexture *QRhiGles2::createTexture(QRhiTexture::Format format, const QSize &p
|
||||
|
||||
QRhiSampler *QRhiGles2::createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter,
|
||||
QRhiSampler::Filter mipmapMode,
|
||||
QRhiSampler::AddressMode u, QRhiSampler::AddressMode v)
|
||||
QRhiSampler::AddressMode u, QRhiSampler::AddressMode v, QRhiSampler::AddressMode w)
|
||||
{
|
||||
return new QGles2Sampler(this, magFilter, minFilter, mipmapMode, u, v);
|
||||
return new QGles2Sampler(this, magFilter, minFilter, mipmapMode, u, v, w);
|
||||
}
|
||||
|
||||
QRhiTextureRenderTarget *QRhiGles2::createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc,
|
||||
@ -3626,8 +3626,8 @@ QRhiTexture::NativeTexture QGles2Texture::nativeTexture()
|
||||
}
|
||||
|
||||
QGles2Sampler::QGles2Sampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode,
|
||||
AddressMode u, AddressMode v)
|
||||
: QRhiSampler(rhi, magFilter, minFilter, mipmapMode, u, v)
|
||||
AddressMode u, AddressMode v, AddressMode w)
|
||||
: QRhiSampler(rhi, magFilter, minFilter, mipmapMode, u, v, w)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ struct QGles2Texture : public QRhiTexture
|
||||
struct QGles2Sampler : public QRhiSampler
|
||||
{
|
||||
QGles2Sampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode,
|
||||
AddressMode u, AddressMode v);
|
||||
AddressMode u, AddressMode v, AddressMode w);
|
||||
~QGles2Sampler();
|
||||
void release() override;
|
||||
bool build() override;
|
||||
@ -613,9 +613,12 @@ public:
|
||||
const QSize &pixelSize,
|
||||
int sampleCount,
|
||||
QRhiTexture::Flags flags) override;
|
||||
QRhiSampler *createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter,
|
||||
QRhiSampler *createSampler(QRhiSampler::Filter magFilter,
|
||||
QRhiSampler::Filter minFilter,
|
||||
QRhiSampler::Filter mipmapMode,
|
||||
QRhiSampler:: AddressMode u, QRhiSampler::AddressMode v) override;
|
||||
QRhiSampler:: AddressMode u,
|
||||
QRhiSampler::AddressMode v,
|
||||
QRhiSampler::AddressMode w) override;
|
||||
|
||||
QRhiTextureRenderTarget *createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc,
|
||||
QRhiTextureRenderTarget::Flags flags) override;
|
||||
|
@ -626,9 +626,9 @@ QRhiTexture *QRhiMetal::createTexture(QRhiTexture::Format format, const QSize &p
|
||||
|
||||
QRhiSampler *QRhiMetal::createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter,
|
||||
QRhiSampler::Filter mipmapMode,
|
||||
QRhiSampler::AddressMode u, QRhiSampler::AddressMode v)
|
||||
QRhiSampler::AddressMode u, QRhiSampler::AddressMode v, QRhiSampler::AddressMode w)
|
||||
{
|
||||
return new QMetalSampler(this, magFilter, minFilter, mipmapMode, u, v);
|
||||
return new QMetalSampler(this, magFilter, minFilter, mipmapMode, u, v, w);
|
||||
}
|
||||
|
||||
QRhiTextureRenderTarget *QRhiMetal::createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc,
|
||||
@ -2548,8 +2548,8 @@ id<MTLTexture> QMetalTextureData::viewForLevel(int level)
|
||||
}
|
||||
|
||||
QMetalSampler::QMetalSampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode,
|
||||
AddressMode u, AddressMode v)
|
||||
: QRhiSampler(rhi, magFilter, minFilter, mipmapMode, u, v),
|
||||
AddressMode u, AddressMode v, AddressMode w)
|
||||
: QRhiSampler(rhi, magFilter, minFilter, mipmapMode, u, v, w),
|
||||
d(new QMetalSamplerData)
|
||||
{
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ struct QMetalSamplerData;
|
||||
struct QMetalSampler : public QRhiSampler
|
||||
{
|
||||
QMetalSampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode,
|
||||
AddressMode u, AddressMode v);
|
||||
AddressMode u, AddressMode v, AddressMode w);
|
||||
~QMetalSampler();
|
||||
void release() override;
|
||||
bool build() override;
|
||||
@ -349,9 +349,12 @@ public:
|
||||
const QSize &pixelSize,
|
||||
int sampleCount,
|
||||
QRhiTexture::Flags flags) override;
|
||||
QRhiSampler *createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter,
|
||||
QRhiSampler *createSampler(QRhiSampler::Filter magFilter,
|
||||
QRhiSampler::Filter minFilter,
|
||||
QRhiSampler::Filter mipmapMode,
|
||||
QRhiSampler:: AddressMode u, QRhiSampler::AddressMode v) override;
|
||||
QRhiSampler:: AddressMode u,
|
||||
QRhiSampler::AddressMode v,
|
||||
QRhiSampler::AddressMode w) override;
|
||||
|
||||
QRhiTextureRenderTarget *createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc,
|
||||
QRhiTextureRenderTarget::Flags flags) override;
|
||||
|
@ -193,9 +193,9 @@ QRhiTexture *QRhiNull::createTexture(QRhiTexture::Format format, const QSize &pi
|
||||
|
||||
QRhiSampler *QRhiNull::createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter,
|
||||
QRhiSampler::Filter mipmapMode,
|
||||
QRhiSampler::AddressMode u, QRhiSampler::AddressMode v)
|
||||
QRhiSampler::AddressMode u, QRhiSampler::AddressMode v, QRhiSampler::AddressMode w)
|
||||
{
|
||||
return new QNullSampler(this, magFilter, minFilter, mipmapMode, u, v);
|
||||
return new QNullSampler(this, magFilter, minFilter, mipmapMode, u, v, w);
|
||||
}
|
||||
|
||||
QRhiTextureRenderTarget *QRhiNull::createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc,
|
||||
@ -645,8 +645,8 @@ bool QNullTexture::buildFrom(QRhiTexture::NativeTexture src)
|
||||
}
|
||||
|
||||
QNullSampler::QNullSampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode,
|
||||
AddressMode u, AddressMode v)
|
||||
: QRhiSampler(rhi, magFilter, minFilter, mipmapMode, u, v)
|
||||
AddressMode u, AddressMode v, AddressMode w)
|
||||
: QRhiSampler(rhi, magFilter, minFilter, mipmapMode, u, v, w)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ struct QNullTexture : public QRhiTexture
|
||||
struct QNullSampler : public QRhiSampler
|
||||
{
|
||||
QNullSampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode,
|
||||
AddressMode u, AddressMode v);
|
||||
AddressMode u, AddressMode v, AddressMode w);
|
||||
~QNullSampler();
|
||||
void release() override;
|
||||
bool build() override;
|
||||
@ -212,9 +212,12 @@ public:
|
||||
const QSize &pixelSize,
|
||||
int sampleCount,
|
||||
QRhiTexture::Flags flags) override;
|
||||
QRhiSampler *createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter,
|
||||
QRhiSampler *createSampler(QRhiSampler::Filter magFilter,
|
||||
QRhiSampler::Filter minFilter,
|
||||
QRhiSampler::Filter mipmapMode,
|
||||
QRhiSampler:: AddressMode u, QRhiSampler::AddressMode v) override;
|
||||
QRhiSampler:: AddressMode u,
|
||||
QRhiSampler::AddressMode v,
|
||||
QRhiSampler::AddressMode w) override;
|
||||
|
||||
QRhiTextureRenderTarget *createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc,
|
||||
QRhiTextureRenderTarget::Flags flags) override;
|
||||
|
@ -4046,9 +4046,9 @@ QRhiTexture *QRhiVulkan::createTexture(QRhiTexture::Format format, const QSize &
|
||||
|
||||
QRhiSampler *QRhiVulkan::createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter,
|
||||
QRhiSampler::Filter mipmapMode,
|
||||
QRhiSampler::AddressMode u, QRhiSampler::AddressMode v)
|
||||
QRhiSampler::AddressMode u, QRhiSampler::AddressMode v, QRhiSampler::AddressMode w)
|
||||
{
|
||||
return new QVkSampler(this, magFilter, minFilter, mipmapMode, u, v);
|
||||
return new QVkSampler(this, magFilter, minFilter, mipmapMode, u, v, w);
|
||||
}
|
||||
|
||||
QRhiTextureRenderTarget *QRhiVulkan::createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc,
|
||||
@ -5543,8 +5543,8 @@ VkImageView QVkTexture::imageViewForLevel(int level)
|
||||
}
|
||||
|
||||
QVkSampler::QVkSampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode,
|
||||
AddressMode u, AddressMode v)
|
||||
: QRhiSampler(rhi, magFilter, minFilter, mipmapMode, u, v)
|
||||
AddressMode u, AddressMode v, AddressMode w)
|
||||
: QRhiSampler(rhi, magFilter, minFilter, mipmapMode, u, v, w)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ struct QVkTexture : public QRhiTexture
|
||||
struct QVkSampler : public QRhiSampler
|
||||
{
|
||||
QVkSampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode,
|
||||
AddressMode u, AddressMode v);
|
||||
AddressMode u, AddressMode v, AddressMode w);
|
||||
~QVkSampler();
|
||||
void release() override;
|
||||
bool build() override;
|
||||
@ -657,9 +657,12 @@ public:
|
||||
const QSize &pixelSize,
|
||||
int sampleCount,
|
||||
QRhiTexture::Flags flags) override;
|
||||
QRhiSampler *createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter,
|
||||
QRhiSampler *createSampler(QRhiSampler::Filter magFilter,
|
||||
QRhiSampler::Filter minFilter,
|
||||
QRhiSampler::Filter mipmapMode,
|
||||
QRhiSampler:: AddressMode u, QRhiSampler::AddressMode v) override;
|
||||
QRhiSampler:: AddressMode u,
|
||||
QRhiSampler::AddressMode v,
|
||||
QRhiSampler::AddressMode w) override;
|
||||
|
||||
QRhiTextureRenderTarget *createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc,
|
||||
QRhiTextureRenderTarget::Flags flags) override;
|
||||
|
Loading…
Reference in New Issue
Block a user