Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qrhid3d11.cpp File Reference

(578e8a01a23ab13f382bcfb339dc8309269940d7)

#include "qrhid3d11_p.h"
#include "qshader.h"
#include "vs_test_p.h"
#include <QWindow>
#include <qmath.h>
#include <QtCore/qcryptographichash.h>
#include <QtCore/private/qsystemerror_p.h>
#include "qrhid3dhelpers_p.h"
#include <cstdio>
Include dependency graph for qrhid3d11.cpp:

Go to the source code of this file.

Classes

struct  QD3D11PipelineCacheDataHeader

Macros

#define DXGI_ADAPTER_FLAG_SOFTWARE   2
 \variable QRhiD3D11NativeHandles::dev
#define D3D11_1_UAV_SLOT_COUNT   64
#define D3D11_VS_INPUT_REGISTER_COUNT   32
#define SETUBUFBATCH(stagePrefixL, stagePrefixU)
#define SETSAMPLERBATCH(stagePrefixL, stagePrefixU)
#define SETUAVBATCH(stagePrefixL, stagePrefixU)
#define SETSHADER(StageL, StageU)

Functions

template<class Int>
Int aligned (Int v, Int byteAlign)
 \variable QRhiVulkanQueueSubmitParams::waitSemaphoreCount
static IDXGIFactory1 * createDXGIFactory2 ()
static QD3D11RenderTargetDatartData (QRhiRenderTarget *rt)
static DXGI_FORMAT toD3DTextureFormat (QRhiTexture::Format format, QRhiTexture::Flags flags)
static QRhiTexture::Format swapchainReadbackTextureFormat (DXGI_FORMAT format, QRhiTexture::Flags *flags)
static bool isDepthTextureFormat (QRhiTexture::Format format)
static std::pair< int, int > mapBinding (int binding, int stageIndex, const QShader::NativeResourceBindingMap *nativeResourceBindingMaps[])
static void applyDynamicOffsets (UINT *offsets, int batchIndex, const QRhiBatchedBindings< UINT > *originalBindings, const QRhiBatchedBindings< UINT > *staticOffsets, const uint *dynOfsPairs, int dynOfsPairCount)
static uint clampedResourceCount (uint startSlot, int countSlots, uint maxSlots, const char *resType)
static uint toD3DBufferUsage (QRhiBuffer::UsageFlags usage)
static DXGI_FORMAT toD3DDepthTextureSRVFormat (QRhiTexture::Format format)
static DXGI_FORMAT toD3DDepthTextureDSVFormat (QRhiTexture::Format format)
static D3D11_FILTER toD3DFilter (QRhiSampler::Filter minFilter, QRhiSampler::Filter magFilter, QRhiSampler::Filter mipFilter)
static D3D11_TEXTURE_ADDRESS_MODE toD3DAddressMode (QRhiSampler::AddressMode m)
static D3D11_COMPARISON_FUNC toD3DTextureComparisonFunc (QRhiSampler::CompareOp op)
template<typename T>
void releasePipelineShader (T &s)
static D3D11_CULL_MODE toD3DCullMode (QRhiGraphicsPipeline::CullMode c)
static D3D11_FILL_MODE toD3DFillMode (QRhiGraphicsPipeline::PolygonMode mode)
static D3D11_COMPARISON_FUNC toD3DCompareOp (QRhiGraphicsPipeline::CompareOp op)
static D3D11_STENCIL_OP toD3DStencilOp (QRhiGraphicsPipeline::StencilOp op)
static DXGI_FORMAT toD3DAttributeFormat (QRhiVertexInputAttribute::Format format)
static D3D11_PRIMITIVE_TOPOLOGY toD3DTopology (QRhiGraphicsPipeline::Topology t, int patchControlPointCount)
static UINT8 toD3DColorWriteMask (QRhiGraphicsPipeline::ColorMask c)
static D3D11_BLEND toD3DBlendFactor (QRhiGraphicsPipeline::BlendFactor f, bool rgb)
static D3D11_BLEND_OP toD3DBlendOp (QRhiGraphicsPipeline::BlendOp op)
static QByteArray sourceHash (const QByteArray &source)

Variables

static const int RBM_SUPPORTED_STAGES = 6
static const int RBM_VERTEX = 0
static const int RBM_HULL = 1
static const int RBM_DOMAIN = 2
static const int RBM_GEOMETRY = 3
static const int RBM_FRAGMENT = 4
static const int RBM_COMPUTE = 5
static const DXGI_FORMAT DEFAULT_FORMAT = DXGI_FORMAT_R8G8B8A8_UNORM
static const DXGI_FORMAT DEFAULT_SRGB_FORMAT = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB

Macro Definition Documentation

◆ D3D11_1_UAV_SLOT_COUNT

#define D3D11_1_UAV_SLOT_COUNT   64

Definition at line 149 of file qrhid3d11.cpp.

◆ D3D11_VS_INPUT_REGISTER_COUNT

#define D3D11_VS_INPUT_REGISTER_COUNT   32

Definition at line 153 of file qrhid3d11.cpp.

◆ DXGI_ADAPTER_FLAG_SOFTWARE

#define DXGI_ADAPTER_FLAG_SOFTWARE   2

\variable QRhiD3D11NativeHandles::dev

Points to a \l{https://learn.microsoft.com/en-us/windows/win32/api/d3d11/nn-d3d11-id3d11device}{ID3D11Device} or left set to \nullptr if no existing device is to be imported.

Note
When importing a device, both the device and the device context must be set to valid objects.

\variable QRhiD3D11NativeHandles::context

Points to a \l{https://learn.microsoft.com/en-us/windows/win32/api/d3d11/nn-d3d11-id3d11devicecontext}{ID3D11DeviceContext} or left set to \nullptr if no existing device context is to be imported.

Note
When importing a device, both the device and the device context must be set to valid objects.

\variable QRhiD3D11NativeHandles::featureLevel

Specifies the feature level passed to \l{https://learn.microsoft.com/en-us/windows/win32/api/d3d11/nf-d3d11-d3d11createdevice}{D3D11CreateDevice()}. Relevant only when QRhi creates the device, ignored when importing a device and device context. When not set, the default rules outlined in the D3D documentation apply.

\variable QRhiD3D11NativeHandles::adapterLuidLow

The low part of the local identifier (LUID) of the DXGI adapter to use. Relevant only when QRhi creates the device, ignored when importing a device and device context.

\variable QRhiD3D11NativeHandles::adapterLuidHigh

The high part of the local identifier (LUID) of the DXGI adapter to use. Relevant only when QRhi creates the device, ignored when importing a device and device context.

Definition at line 145 of file qrhid3d11.cpp.

◆ SETSAMPLERBATCH

#define SETSAMPLERBATCH ( stagePrefixL,
stagePrefixU )
Value:
if (allResourceBatches.stagePrefixL##SamplerBatches.present) { \
for (const auto &batch : allResourceBatches.stagePrefixL##SamplerBatches.samplers.batches) { \
const uint count = clampedResourceCount(batch.startBinding, batch.resources.count(), \
D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, #stagePrefixU " sampler"); \
if (count) \
context->stagePrefixU##SetSamplers(batch.startBinding, count, batch.resources.constData()); \
} \
for (const auto &batch : allResourceBatches.stagePrefixL##SamplerBatches.shaderresources.batches) { \
const uint count = clampedResourceCount(batch.startBinding, batch.resources.count(), \
D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, #stagePrefixU " SRV"); \
if (count) { \
context->stagePrefixU##SetShaderResources(batch.startBinding, count, batch.resources.constData()); \
contextState.stagePrefixL##HighestActiveSrvBinding = qMax(contextState.stagePrefixL##HighestActiveSrvBinding, \
int(batch.startBinding + count) - 1); \
} \
} \
}
static const QString context()
Definition java.cpp:398
static int qMax(int i1, int i2, int i3)
GLenum GLenum GLsizei count
static uint clampedResourceCount(uint startSlot, int countSlots, uint maxSlots, const char *resType)
unsigned int uint
Definition qtypes.h:39

Definition at line 2742 of file qrhid3d11.cpp.

◆ SETSHADER

#define SETSHADER ( StageL,
StageU )
Value:
if (psD->StageL.shader) { \
context->StageU##SetShader(psD->StageL.shader, nullptr, 0); \
currentShaderMask |= StageU##MaskBit; \
} else if (currentShaderMask & StageU##MaskBit) { \
context->StageU##SetShader(nullptr, nullptr, 0); \
currentShaderMask &= ~StageU##MaskBit; \
}

Definition at line 2898 of file qrhid3d11.cpp.

◆ SETUAVBATCH

#define SETUAVBATCH ( stagePrefixL,
stagePrefixU )
Value:
if (allResourceBatches.stagePrefixL##UavBatches.present) { \
for (const auto &batch : allResourceBatches.stagePrefixL##UavBatches.uavs.batches) { \
const uint count = clampedResourceCount(batch.startBinding, batch.resources.count(), \
D3D11_1_UAV_SLOT_COUNT, #stagePrefixU " UAV"); \
if (count) { \
context->stagePrefixU##SetUnorderedAccessViews(batch.startBinding, \
count, \
batch.resources.constData(), \
nullptr); \
contextState.stagePrefixL##HighestActiveUavBinding = qMax(contextState.stagePrefixL##HighestActiveUavBinding, \
int(batch.startBinding + count) - 1); \
} \
} \
}
#define D3D11_1_UAV_SLOT_COUNT

Definition at line 2761 of file qrhid3d11.cpp.

◆ SETUBUFBATCH

#define SETUBUFBATCH ( stagePrefixL,
stagePrefixU )
Value:
if (allResourceBatches.stagePrefixL##UniformBufferBatches.present) { \
const QD3D11ShaderResourceBindings::StageUniformBufferBatches &batches(allResourceBatches.stagePrefixL##UniformBufferBatches); \
for (int i = 0, ie = batches.ubufs.batches.count(); i != ie; ++i) { \
const uint count = clampedResourceCount(batches.ubufs.batches[i].startBinding, \
batches.ubufs.batches[i].resources.count(), \
D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, \
#stagePrefixU " cbuf"); \
if (count) { \
if (!dynOfsPairCount) { \
context->stagePrefixU##SetConstantBuffers1(batches.ubufs.batches[i].startBinding, \
count, \
batches.ubufs.batches[i].resources.constData(), \
batches.ubufoffsets.batches[i].resources.constData(), \
batches.ubufsizes.batches[i].resources.constData()); \
} else { \
applyDynamicOffsets(offsets, i, \
&batches.ubuforigbindings, &batches.ubufoffsets, \
dynOfsPairs, dynOfsPairCount); \
context->stagePrefixU##SetConstantBuffers1(batches.ubufs.batches[i].startBinding, \
count, \
batches.ubufs.batches[i].resources.constData(), \
batches.ubufsizes.batches[i].resources.constData()); \
} \
} \
} \
}
EGLImageKHR int EGLint EGLint * offsets

Definition at line 2713 of file qrhid3d11.cpp.

Function Documentation

◆ aligned()

template<class Int>
Int aligned ( Int v,
Int byteAlign )
inline

\variable QRhiVulkanQueueSubmitParams::waitSemaphoreCount

See \l{https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSubmitInfo.html}{VkSubmitInfo} for details.

\variable QRhiVulkanQueueSubmitParams::waitSemaphores

See \l{https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSubmitInfo.html}{VkSubmitInfo} for details.

\variable QRhiVulkanQueueSubmitParams::signalSemaphoreCount

See \l{https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSubmitInfo.html}{VkSubmitInfo} for details.

\variable QRhiVulkanQueueSubmitParams::signalSemaphores

See \l{https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkSubmitInfo.html}{VkSubmitInfo} for details.

\variable QRhiVulkanQueueSubmitParams::presentWaitSemaphoreCount

When non-zero, this applies to the next vkQueuePresentKHR() call. See \l{https://registry.khronos.org/VulkanSC/specs/1.0-extensions/man/html/VkPresentInfoKHR.html}{VkPresentInfoKHR} for details.

\variable QRhiVulkanQueueSubmitParams::presentWaitSemaphores

See \l{https://registry.khronos.org/VulkanSC/specs/1.0-extensions/man/html/VkPresentInfoKHR.html}{VkPresentInfoKHR} for details.

Definition at line 180 of file qrhid3d11.cpp.

◆ applyDynamicOffsets()

void applyDynamicOffsets ( UINT * offsets,
int batchIndex,
const QRhiBatchedBindings< UINT > * originalBindings,
const QRhiBatchedBindings< UINT > * staticOffsets,
const uint * dynOfsPairs,
int dynOfsPairCount )
static

Definition at line 2679 of file qrhid3d11.cpp.

◆ clampedResourceCount()

uint clampedResourceCount ( uint startSlot,
int countSlots,
uint maxSlots,
const char * resType )
inlinestatic

Definition at line 2703 of file qrhid3d11.cpp.

◆ createDXGIFactory2()

IDXGIFactory1 * createDXGIFactory2 ( )
static

Definition at line 185 of file qrhid3d11.cpp.

◆ isDepthTextureFormat()

bool isDepthTextureFormat ( QRhiTexture::Format format)
inlinestatic

Definition at line 1775 of file qrhid3d11.cpp.

◆ mapBinding()

std::pair< int, int > mapBinding ( int binding,
int stageIndex,
const QShader::NativeResourceBindingMap * nativeResourceBindingMaps[] )
inlinestatic

Definition at line 2370 of file qrhid3d11.cpp.

◆ releasePipelineShader()

template<typename T>
void releasePipelineShader ( T & s)
inline

Definition at line 4273 of file qrhid3d11.cpp.

◆ rtData()

QD3D11RenderTargetData * rtData ( QRhiRenderTarget * rt)
inlinestatic

Definition at line 1436 of file qrhid3d11.cpp.

Referenced by QRhiD3D11::beginFrame(), QRhiD3D11::beginPass(), and QRhiD3D11::executeCommandBuffer().

Here is the caller graph for this function:

◆ sourceHash()

QByteArray sourceHash ( const QByteArray & source)
inlinestatic

Definition at line 4563 of file qrhid3d11.cpp.

◆ swapchainReadbackTextureFormat()

QRhiTexture::Format swapchainReadbackTextureFormat ( DXGI_FORMAT format,
QRhiTexture::Flags * flags )
inlinestatic

Definition at line 1747 of file qrhid3d11.cpp.

◆ toD3DAddressMode()

D3D11_TEXTURE_ADDRESS_MODE toD3DAddressMode ( QRhiSampler::AddressMode m)
inlinestatic

Definition at line 3841 of file qrhid3d11.cpp.

◆ toD3DAttributeFormat()

DXGI_FORMAT toD3DAttributeFormat ( QRhiVertexInputAttribute::Format format)
inlinestatic

Definition at line 4394 of file qrhid3d11.cpp.

◆ toD3DBlendFactor()

D3D11_BLEND toD3DBlendFactor ( QRhiGraphicsPipeline::BlendFactor f,
bool rgb )
inlinestatic

Definition at line 4493 of file qrhid3d11.cpp.

◆ toD3DBlendOp()

D3D11_BLEND_OP toD3DBlendOp ( QRhiGraphicsPipeline::BlendOp op)
inlinestatic

Definition at line 4544 of file qrhid3d11.cpp.

◆ toD3DBufferUsage()

uint toD3DBufferUsage ( QRhiBuffer::UsageFlags usage)
inlinestatic

Definition at line 3141 of file qrhid3d11.cpp.

◆ toD3DColorWriteMask()

UINT8 toD3DColorWriteMask ( QRhiGraphicsPipeline::ColorMask c)
inlinestatic

Definition at line 4479 of file qrhid3d11.cpp.

◆ toD3DCompareOp()

D3D11_COMPARISON_FUNC toD3DCompareOp ( QRhiGraphicsPipeline::CompareOp op)
inlinestatic

Definition at line 4344 of file qrhid3d11.cpp.

◆ toD3DCullMode()

D3D11_CULL_MODE toD3DCullMode ( QRhiGraphicsPipeline::CullMode c)
inlinestatic

Definition at line 4316 of file qrhid3d11.cpp.

◆ toD3DDepthTextureDSVFormat()

DXGI_FORMAT toD3DDepthTextureDSVFormat ( QRhiTexture::Format format)
inlinestatic

Definition at line 3445 of file qrhid3d11.cpp.

◆ toD3DDepthTextureSRVFormat()

DXGI_FORMAT toD3DDepthTextureSRVFormat ( QRhiTexture::Format format)
inlinestatic

Definition at line 3426 of file qrhid3d11.cpp.

◆ toD3DFillMode()

D3D11_FILL_MODE toD3DFillMode ( QRhiGraphicsPipeline::PolygonMode mode)
inlinestatic

Definition at line 4331 of file qrhid3d11.cpp.

◆ toD3DFilter()

D3D11_FILTER toD3DFilter ( QRhiSampler::Filter minFilter,
QRhiSampler::Filter magFilter,
QRhiSampler::Filter mipFilter )
inlinestatic

Definition at line 3809 of file qrhid3d11.cpp.

◆ toD3DStencilOp()

D3D11_STENCIL_OP toD3DStencilOp ( QRhiGraphicsPipeline::StencilOp op)
inlinestatic

Definition at line 4369 of file qrhid3d11.cpp.

◆ toD3DTextureComparisonFunc()

D3D11_COMPARISON_FUNC toD3DTextureComparisonFunc ( QRhiSampler::CompareOp op)
inlinestatic

Definition at line 3856 of file qrhid3d11.cpp.

◆ toD3DTextureFormat()

DXGI_FORMAT toD3DTextureFormat ( QRhiTexture::Format format,
QRhiTexture::Flags flags )
inlinestatic

Definition at line 1644 of file qrhid3d11.cpp.

◆ toD3DTopology()

D3D11_PRIMITIVE_TOPOLOGY toD3DTopology ( QRhiGraphicsPipeline::Topology t,
int patchControlPointCount )
inlinestatic

Definition at line 4457 of file qrhid3d11.cpp.

Variable Documentation

◆ DEFAULT_FORMAT

const DXGI_FORMAT DEFAULT_FORMAT = DXGI_FORMAT_R8G8B8A8_UNORM
static

Definition at line 5258 of file qrhid3d11.cpp.

◆ DEFAULT_SRGB_FORMAT

const DXGI_FORMAT DEFAULT_SRGB_FORMAT = DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
static

Definition at line 5259 of file qrhid3d11.cpp.

◆ RBM_COMPUTE

const int RBM_COMPUTE = 5
static

◆ RBM_DOMAIN

const int RBM_DOMAIN = 2
static

◆ RBM_FRAGMENT

const int RBM_FRAGMENT = 4
static

◆ RBM_GEOMETRY

const int RBM_GEOMETRY = 3
static

◆ RBM_HULL

const int RBM_HULL = 1
static

◆ RBM_SUPPORTED_STAGES

const int RBM_SUPPORTED_STAGES = 6
static

◆ RBM_VERTEX

const int RBM_VERTEX = 0
static