diff options
Diffstat (limited to 'src/gui/rhi/qrhid3d11.cpp')
-rw-r--r-- | src/gui/rhi/qrhid3d11.cpp | 76 |
1 files changed, 23 insertions, 53 deletions
diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 5e576e9c6a..75b90b6995 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -108,17 +108,6 @@ QT_BEGIN_NAMESPACE \c{ID3D11Device *} and \c{ID3D11DeviceContext *}. */ -/*! - \class QRhiD3D11TextureNativeHandles - \internal - \inmodule QtGui - \brief Holds the D3D texture object that is backing a QRhiTexture instance. - - \note The class uses \c{void *} as the type since including the COM-based - \c{d3d11.h} headers is not acceptable here. The actual type is - \c{ID3D11Texture2D *}. - */ - // help mingw with its ancient sdk headers #ifndef DXGI_ADAPTER_FLAG_SOFTWARE #define DXGI_ADAPTER_FLAG_SOFTWARE 2 @@ -538,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, @@ -641,9 +630,7 @@ void QRhiD3D11::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QD3D11Texture *texD = QRHI_RES(QD3D11Texture, b->u.simage.tex); @@ -655,9 +642,7 @@ void QRhiD3D11::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QD3D11Buffer *bufD = QRHI_RES(QD3D11Buffer, b->u.sbuf.buf); @@ -1117,6 +1102,10 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex return DXGI_FORMAT_R16G16B16A16_FLOAT; case QRhiTexture::RGBA32F: return DXGI_FORMAT_R32G32B32A32_FLOAT; + case QRhiTexture::R16F: + return DXGI_FORMAT_R16_FLOAT; + case QRhiTexture::R32F: + return DXGI_FORMAT_R32_FLOAT; case QRhiTexture::D16: return DXGI_FORMAT_R16_TYPELESS; @@ -1139,39 +1128,24 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex return srgb ? DXGI_FORMAT_BC7_UNORM_SRGB : DXGI_FORMAT_BC7_UNORM; case QRhiTexture::ETC2_RGB8: - Q_FALLTHROUGH(); case QRhiTexture::ETC2_RGB8A1: - Q_FALLTHROUGH(); case QRhiTexture::ETC2_RGBA8: qWarning("QRhiD3D11 does not support ETC2 textures"); return DXGI_FORMAT_R8G8B8A8_UNORM; case QRhiTexture::ASTC_4x4: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_5x4: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_5x5: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_6x5: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_6x6: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_8x5: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_8x6: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_8x8: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_10x5: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_10x6: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_10x8: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_10x10: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_12x10: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_12x12: qWarning("QRhiD3D11 does not support ASTC textures"); return DXGI_FORMAT_R8G8B8A8_UNORM; @@ -1212,7 +1186,6 @@ static inline bool isDepthTextureFormat(QRhiTexture::Format format) { switch (format) { case QRhiTexture::Format::D16: - Q_FALLTHROUGH(); case QRhiTexture::Format::D32F: return true; @@ -1878,9 +1851,7 @@ void QRhiD3D11::updateShaderResourceBindings(QD3D11ShaderResourceBindings *srbD) } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QD3D11Texture *texD = QRHI_RES(QD3D11Texture, b->u.simage.tex); @@ -1896,9 +1867,7 @@ void QRhiD3D11::updateShaderResourceBindings(QD3D11ShaderResourceBindings *srbD) } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QD3D11Buffer *bufD = QRHI_RES(QD3D11Buffer, b->u.sbuf.buf); @@ -2674,8 +2643,6 @@ bool QD3D11Texture::finishBuild() return false; } - nativeHandlesStruct.texture = tex; - generation += 1; return true; } @@ -2741,16 +2708,16 @@ bool QD3D11Texture::build() return true; } -bool QD3D11Texture::buildFrom(const QRhiNativeHandles *src) +bool QD3D11Texture::buildFrom(QRhiTexture::NativeTexture src) { - const QRhiD3D11TextureNativeHandles *h = static_cast<const QRhiD3D11TextureNativeHandles *>(src); - if (!h || !h->texture) + auto *srcTex = static_cast<ID3D11Texture2D * const *>(src.object); + if (!srcTex || !*srcTex) return false; if (!prepareBuild()) return false; - tex = static_cast<ID3D11Texture2D *>(h->texture); + tex = *srcTex; if (!finishBuild()) return false; @@ -2764,9 +2731,9 @@ bool QD3D11Texture::buildFrom(const QRhiNativeHandles *src) return true; } -const QRhiNativeHandles *QD3D11Texture::nativeHandles() +QRhiTexture::NativeTexture QD3D11Texture::nativeTexture() { - return &nativeHandlesStruct; + return {&tex, 0}; } ID3D11UnorderedAccessView *QD3D11Texture::unorderedAccessViewForLevel(int level) @@ -2801,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) { } @@ -2862,12 +2829,8 @@ static inline D3D11_TEXTURE_ADDRESS_MODE toD3DAddressMode(QRhiSampler::AddressMo return D3D11_TEXTURE_ADDRESS_WRAP; case QRhiSampler::ClampToEdge: return D3D11_TEXTURE_ADDRESS_CLAMP; - case QRhiSampler::Border: - return D3D11_TEXTURE_ADDRESS_BORDER; case QRhiSampler::Mirror: return D3D11_TEXTURE_ADDRESS_MIRROR; - case QRhiSampler::MirrorOnce: - return D3D11_TEXTURE_ADDRESS_MIRROR_ONCE; default: Q_UNREACHABLE(); return D3D11_TEXTURE_ADDRESS_CLAMP; @@ -2944,6 +2907,12 @@ void QD3D11RenderPassDescriptor::release() // nothing to do here } +bool QD3D11RenderPassDescriptor::isCompatible(const QRhiRenderPassDescriptor *other) const +{ + Q_UNUSED(other); + return true; +} + QD3D11ReferenceRenderTarget::QD3D11ReferenceRenderTarget(QRhiImplementation *rhi) : QRhiRenderTarget(rhi), d(rhi) @@ -3367,11 +3336,9 @@ static inline D3D11_BLEND toD3DBlendFactor(QRhiGraphicsPipeline::BlendFactor f) case QRhiGraphicsPipeline::OneMinusDstAlpha: return D3D11_BLEND_INV_DEST_ALPHA; case QRhiGraphicsPipeline::ConstantColor: - Q_FALLTHROUGH(); case QRhiGraphicsPipeline::ConstantAlpha: return D3D11_BLEND_BLEND_FACTOR; case QRhiGraphicsPipeline::OneMinusConstantColor: - Q_FALLTHROUGH(); case QRhiGraphicsPipeline::OneMinusConstantAlpha: return D3D11_BLEND_INV_BLEND_FACTOR; case QRhiGraphicsPipeline::SrcAlphaSaturate: @@ -3500,6 +3467,9 @@ bool QD3D11GraphicsPipeline::build() rastDesc.FillMode = D3D11_FILL_SOLID; rastDesc.CullMode = toD3DCullMode(m_cullMode); rastDesc.FrontCounterClockwise = m_frontFace == CCW; + rastDesc.DepthBias = m_depthBias; + rastDesc.SlopeScaledDepthBias = m_slopeScaledDepthBias; + rastDesc.DepthClipEnable = true; rastDesc.ScissorEnable = m_flags.testFlag(UsesScissor); rastDesc.MultisampleEnable = rhiD->effectiveSampleCount(m_sampleCount).Count > 1; HRESULT hr = rhiD->dev->CreateRasterizerState(&rastDesc, &rastState); |