9#include <QtCore/qcryptographichash.h>
10#include <QtCore/private/qsystemerror_p.h>
115#ifndef DXGI_ADAPTER_FLAG_SOFTWARE
116#define DXGI_ADAPTER_FLAG_SOFTWARE 2
119#ifndef D3D11_1_UAV_SLOT_COUNT
120#define D3D11_1_UAV_SLOT_COUNT 64
123#ifndef D3D11_VS_INPUT_REGISTER_COUNT
124#define D3D11_VS_INPUT_REGISTER_COUNT 32
133 if (importParams->dev && importParams->context) {
134 dev =
reinterpret_cast<ID3D11Device *
>(importParams->dev);
135 ID3D11DeviceContext *
ctx =
reinterpret_cast<ID3D11DeviceContext *
>(importParams->context);
136 if (SUCCEEDED(
ctx->QueryInterface(__uuidof(ID3D11DeviceContext1),
reinterpret_cast<void **
>(&
context)))) {
141 qWarning(
"ID3D11DeviceContext1 not supported by context, cannot import");
144 featureLevel = D3D_FEATURE_LEVEL(importParams->featureLevel);
145 adapterLuid.LowPart = importParams->adapterLuidLow;
146 adapterLuid.HighPart = importParams->adapterLuidHigh;
153 return (
v + byteAlign - 1) & ~(byteAlign - 1);
158 IDXGIFactory1 *
result =
nullptr;
159 const HRESULT hr = CreateDXGIFactory2(0, __uuidof(IDXGIFactory2),
reinterpret_cast<void **
>(&
result));
161 qWarning(
"CreateDXGIFactory2() failed to create DXGI factory: %s",
162 qPrintable(QSystemError::windowsComString(hr)));
174 devFlags |= D3D11_CREATE_DEVICE_DEBUG;
184 IDXGIFactory5 *factory5 =
nullptr;
185 if (SUCCEEDED(
dxgiFactory->QueryInterface(__uuidof(IDXGIFactory5),
reinterpret_cast<void **
>(&factory5)))) {
186 BOOL allowTearing =
false;
187 if (SUCCEEDED(factory5->CheckFeatureSupport(DXGI_FEATURE_PRESENT_ALLOW_TEARING, &allowTearing,
sizeof(allowTearing))))
193 qWarning(
"The default swap effect is FLIP_DISCARD, QT_D3D_FLIP_DISCARD is now ignored");
196 qWarning(
"Non-FLIP swapchains are no longer supported, QT_D3D_NO_FLIP is now ignored");
198 qCDebug(QRHI_LOG_INFO,
"FLIP_* swapchain supported = true, ALLOW_TEARING supported = %s",
201 qCDebug(QRHI_LOG_INFO,
"Default swap effect: FLIP_DISCARD");
204 IDXGIAdapter1 *adapter;
205 int requestedAdapterIndex = -1;
211 for (
int adapterIndex = 0;
dxgiFactory->EnumAdapters1(UINT(adapterIndex), &adapter) != DXGI_ERROR_NOT_FOUND; ++adapterIndex) {
212 DXGI_ADAPTER_DESC1
desc;
213 adapter->GetDesc1(&
desc);
218 requestedAdapterIndex = adapterIndex;
225 for (
int adapterIndex = 0;
dxgiFactory->EnumAdapters1(UINT(adapterIndex), &adapter) != DXGI_ERROR_NOT_FOUND; ++adapterIndex) {
226 DXGI_ADAPTER_DESC1
desc;
227 adapter->GetDesc1(&
desc);
230 requestedAdapterIndex = adapterIndex;
237 for (
int adapterIndex = 0;
dxgiFactory->EnumAdapters1(UINT(adapterIndex), &adapter) != DXGI_ERROR_NOT_FOUND; ++adapterIndex) {
238 DXGI_ADAPTER_DESC1
desc;
239 adapter->GetDesc1(&
desc);
241 qCDebug(QRHI_LOG_INFO,
"Adapter %d: '%s' (vendor 0x%X device 0x%X flags 0x%X)",
247 if (!
activeAdapter && (requestedAdapterIndex < 0 || requestedAdapterIndex == adapterIndex)) {
253 qCDebug(QRHI_LOG_INFO,
" using this adapter");
266 bool requestFeatureLevels =
false;
268 requestFeatureLevels =
true;
272 ID3D11DeviceContext *
ctx =
nullptr;
274 requestFeatureLevels ? requestedFeatureLevels.
constData() :
nullptr,
275 requestFeatureLevels ? requestedFeatureLevels.
count() : 0,
279 if (hr == DXGI_ERROR_SDK_COMPONENT_MISSING &&
debugLayer) {
280 qCDebug(QRHI_LOG_INFO,
"Debug layer was requested but is not available. "
281 "Attempting to create D3D11 device without it.");
282 devFlags &= ~D3D11_CREATE_DEVICE_DEBUG;
283 hr = D3D11CreateDevice(
activeAdapter, D3D_DRIVER_TYPE_UNKNOWN,
nullptr, devFlags,
284 requestFeatureLevels ? requestedFeatureLevels.
constData() :
nullptr,
285 requestFeatureLevels ? requestedFeatureLevels.
count() : 0,
290 qWarning(
"Failed to create D3D11 device and context: %s",
291 qPrintable(QSystemError::windowsComString(hr)));
297 ID3D11VertexShader *testShader =
nullptr;
298 if (SUCCEEDED(
dev->CreateVertexShader(g_testVertexShader,
sizeof(g_testVertexShader),
nullptr, &testShader))) {
299 testShader->Release();
301 qWarning(
"D3D11 smoke test failed (failed to create vertex shader)");
306 const bool supports11_1 = SUCCEEDED(
ctx->QueryInterface(__uuidof(ID3D11DeviceContext1),
reinterpret_cast<void **
>(&
context)));
309 qWarning(
"ID3D11DeviceContext1 not supported");
313 D3D11_FEATURE_DATA_D3D11_OPTIONS features = {};
314 if (SUCCEEDED(
dev->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS, &features,
sizeof(features)))) {
318 if (!features.ConstantBufferOffsetting) {
319 qWarning(
"Constant buffer offsetting is not supported by the driver");
323 qWarning(
"Failed to query D3D11_FEATURE_D3D11_OPTIONS");
329 IDXGIDevice *dxgiDev =
nullptr;
330 if (SUCCEEDED(
dev->QueryInterface(__uuidof(IDXGIDevice),
reinterpret_cast<void **
>(&dxgiDev)))) {
331 IDXGIAdapter *adapter =
nullptr;
332 if (SUCCEEDED(dxgiDev->GetAdapter(&adapter))) {
333 DXGI_ADAPTER_DESC
desc;
334 adapter->GetDesc(&
desc);
343 qCDebug(QRHI_LOG_INFO,
"Using imported device %p",
dev);
346 if (FAILED(
context->QueryInterface(__uuidof(ID3DUserDefinedAnnotation),
reinterpret_cast<void **
>(&
annotations))))
417 if (SUCCEEDED(
device->QueryInterface(__uuidof(ID3D11Debug),
reinterpret_cast<void **
>(&
debug)))) {
418 debug->ReportLiveDeviceObjects(D3D11_RLDO_DETAIL);
425 return { 1, 2, 4, 8 };
430 DXGI_SAMPLE_DESC
desc;
435 int s =
qBound(1, sampleCount, 64);
438 qWarning(
"Attempted to set unsupported sample count %d", sampleCount);
442 desc.Count = UINT(
s);
444 desc.Quality = UINT(D3D11_STANDARD_MULTISAMPLE_PATTERN);
486 if (
m.isIdentity()) {
489 0.0f, 1.0f, 0.0f, 0.0f,
490 0.0f, 0.0f, 0.5f, 0.5f,
491 0.0f, 0.0f, 0.0f, 1.0f);
603 return D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION;
615 return D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION;
617 return D3D11_CS_THREAD_GROUP_MAX_THREADS_PER_GROUP;
619 return D3D11_CS_THREAD_GROUP_MAX_X;
621 return D3D11_CS_THREAD_GROUP_MAX_Y;
623 return D3D11_CS_THREAD_GROUP_MAX_Z;
625 return D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION;
631 return D3D11_VS_OUTPUT_REGISTER_COUNT;
693 const size_t dataOffset =
sizeof(
header);
707 char *
p =
buf.data() + dataOffset;
715 memcpy(
p,
key.sourceHash.constData(),
key.sourceHash.size());
716 p +=
key.sourceHash.size();
718 i =
key.target.size();
721 memcpy(
p,
key.target.constData(),
key.target.size());
722 p +=
key.target.size();
724 i =
key.entryPoint.size();
727 memcpy(
p,
key.entryPoint.constData(),
key.entryPoint.size());
728 p +=
key.entryPoint.size();
738 p += bytecode.
size();
755 qCDebug(QRHI_LOG_INFO,
"setPipelineCacheData: Invalid blob size (header incomplete)");
763 if (
header.rhiId != rhiId) {
764 qCDebug(QRHI_LOG_INFO,
"setPipelineCacheData: The data is for a different QRhi version or backend (%u, %u)",
769 if (
header.arch != arch) {
770 qCDebug(QRHI_LOG_INFO,
"setPipelineCacheData: Architecture does not match (%u, %u)",
778 qCDebug(QRHI_LOG_INFO,
"setPipelineCacheData: Invalid blob size (data incomplete)");
784 const char *
p =
data.constData() + dataOffset;
828 int sampleCount, QRhiRenderBuffer::Flags
flags,
835 const QSize &pixelSize,
int depth,
int arraySize,
836 int sampleCount, QRhiTexture::Flags
flags)
845 return new QD3D11Sampler(
this, magFilter, minFilter, mipmapMode, u,
v,
w);
849 QRhiTextureRenderTarget::Flags
flags)
876 if (pipelineChanged) {
896 int dynamicOffsetCount,
913 bool srbUpdate =
false;
942 for (
int elem = 0; elem <
data->count; ++elem) {
951 const quint64 samplerId = samplerD ? samplerD->
m_id : 0;
999 memset(resBindMaps, 0,
sizeof(resBindMaps));
1036 for (
int i = 0;
i < dynamicOffsetCount; ++
i) {
1038 const uint binding =
uint(dynOfs.first);
1040 const quint32 offsetInConstants = dynOfs.second / 16;
1042 *
p++ = offsetInConstants;
1045 qWarning(
"Too many dynamic offsets (%d, max is %d)",
1059 bool needsBindVBuf =
false;
1060 for (
int i = 0;
i < bindingCount; ++
i) {
1061 const int inputSlot = startBinding +
i;
1070 needsBindVBuf =
true;
1076 if (needsBindVBuf) {
1081 qWarning(
"Too many vertex buffer bindings (%d, max is %d)",
1089 for (
int i = 0, ie =
qMin(bindingCount, inputBindingCount);
i != ie; ++
i) {
1104 : DXGI_FORMAT_R32_UINT;
1131 if (!qrhi_toTopLeftRenderTargetRect<UnBounded>(outputSize,
viewport.viewport(), &
x, &
y, &
w, &
h))
1153 if (!qrhi_toTopLeftRenderTargetRect<Bounded>(outputSize, scissor.
scissor(), &
x, &
y, &
w, &
h))
1296 swapChainD->
rt.
d.
dsv = swapChainD->
ds ? swapChainD->
ds->
dsv :
nullptr;
1301 double elapsedSec = 0;
1322 if (recordTimestamps)
1334 if (recordTimestamps) {
1341 UINT presentFlags = 0;
1343 presentFlags |= DXGI_PRESENT_ALLOW_TEARING;
1345 if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) {
1346 qWarning(
"Device loss detected in Present()");
1349 }
else if (FAILED(hr)) {
1351 qPrintable(QSystemError::windowsComString(hr)));
1379 double elapsedSec = 0;
1396 if (recordTimestamps) {
1406 if (recordTimestamps) {
1421 return srgb ? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB : DXGI_FORMAT_R8G8B8A8_UNORM;
1423 return srgb ? DXGI_FORMAT_B8G8R8A8_UNORM_SRGB : DXGI_FORMAT_B8G8R8A8_UNORM;
1425 return DXGI_FORMAT_R8_UNORM;
1427 return DXGI_FORMAT_R8G8_UNORM;
1429 return DXGI_FORMAT_R16_UNORM;
1431 return DXGI_FORMAT_R16G16_UNORM;
1433 return DXGI_FORMAT_R8_UNORM;
1436 return DXGI_FORMAT_R16G16B16A16_FLOAT;
1438 return DXGI_FORMAT_R32G32B32A32_FLOAT;
1440 return DXGI_FORMAT_R16_FLOAT;
1442 return DXGI_FORMAT_R32_FLOAT;
1445 return DXGI_FORMAT_R10G10B10A2_UNORM;
1448 return DXGI_FORMAT_R16_TYPELESS;
1450 return DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
1452 return DXGI_FORMAT_D24_UNORM_S8_UINT;
1454 return DXGI_FORMAT_R32_TYPELESS;
1457 return srgb ? DXGI_FORMAT_BC1_UNORM_SRGB : DXGI_FORMAT_BC1_UNORM;
1459 return srgb ? DXGI_FORMAT_BC2_UNORM_SRGB : DXGI_FORMAT_BC2_UNORM;
1461 return srgb ? DXGI_FORMAT_BC3_UNORM_SRGB : DXGI_FORMAT_BC3_UNORM;
1463 return DXGI_FORMAT_BC4_UNORM;
1465 return DXGI_FORMAT_BC5_UNORM;
1467 return DXGI_FORMAT_BC6H_UF16;
1469 return srgb ? DXGI_FORMAT_BC7_UNORM_SRGB : DXGI_FORMAT_BC7_UNORM;
1474 qWarning(
"QRhiD3D11 does not support ETC2 textures");
1475 return DXGI_FORMAT_R8G8B8A8_UNORM;
1491 qWarning(
"QRhiD3D11 does not support ASTC textures");
1492 return DXGI_FORMAT_R8G8B8A8_UNORM;
1496 return DXGI_FORMAT_R8G8B8A8_UNORM;
1503 case DXGI_FORMAT_R8G8B8A8_UNORM:
1505 case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
1509 case DXGI_FORMAT_B8G8R8A8_UNORM:
1511 case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
1515 case DXGI_FORMAT_R16G16B16A16_FLOAT:
1517 case DXGI_FORMAT_R32G32B32A32_FLOAT:
1519 case DXGI_FORMAT_R10G10B10A2_UNORM:
1569 box.front = is3D ? UINT(
layer) : 0u;
1571 box.back =
box.front + 1;
1581 int bpl =
img.bytesPerLine();
1586 if (
img.depth() == 32) {
1587 const int offset =
sp.y() *
img.bytesPerLine() +
sp.x() * 4;
1591 bpl =
img.bytesPerLine();
1597 box.left = UINT(dp.
x());
1598 box.top = UINT(dp.
y());
1599 box.right = UINT(dp.
x() +
size.width());
1600 box.bottom = UINT(dp.
y() +
size.height());
1629 box.left = UINT(dp.
x());
1630 box.top = UINT(dp.
y());
1631 box.right = UINT(dp.
x() +
size.width());
1632 box.bottom = UINT(dp.
y() +
size.height());
1671 box.back =
box.bottom = 1;
1687 D3D11_BUFFER_DESC
desc = {};
1689 desc.Usage = D3D11_USAGE_STAGING;
1690 desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
1693 qWarning(
"Failed to create buffer: %s",
1694 qPrintable(QSystemError::windowsComString(hr)));
1711 box.back =
box.bottom = 1;
1742 srcBox.left = UINT(
sp.x());
1743 srcBox.top = UINT(
sp.y());
1746 srcBox.right = srcBox.left + UINT(copySize.
width());
1747 srcBox.bottom = srcBox.top + UINT(copySize.
height());
1748 srcBox.back = srcBox.front + 1;
1765 ID3D11Resource *
src;
1766 DXGI_FORMAT dxgiFormat;
1776 qWarning(
"Multisample texture cannot be read back");
1810 D3D11_TEXTURE2D_DESC
desc = {};
1815 desc.Format = dxgiFormat;
1816 desc.SampleDesc.Count = 1;
1817 desc.Usage = D3D11_USAGE_STAGING;
1818 desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
1819 ID3D11Texture2D *stagingTex;
1822 qWarning(
"Failed to create readback staging texture: %s",
1823 qPrintable(QSystemError::windowsComString(hr)));
1837 D3D11_BOX srcBox = {};
1838 srcBox.front = UINT(u.
rb.
layer());
1839 srcBox.right =
desc.Width;
1840 srcBox.bottom =
desc.Height;
1841 srcBox.back = srcBox.front + 1;
1875 D3D11_MAPPED_SUBRESOURCE mp;
1877 if (SUCCEEDED(hr)) {
1882 char *
src =
static_cast<char *
>(mp.pData);
1890 qWarning(
"Failed to map readback staging texture: %s",
1891 qPrintable(QSystemError::windowsComString(hr)));
1905 D3D11_MAPPED_SUBRESOURCE mp;
1907 if (SUCCEEDED(hr)) {
1912 qWarning(
"Failed to map readback staging texture: %s",
1913 qPrintable(QSystemError::windowsComString(hr)));
1924 for (
auto f : completedCallbacks)
1950 const QColor &colorClearValue,
1953 QRhiCommandBuffer::BeginPassFlags)
1958 if (resourceUpdates)
1961 bool wantsColorClear =
true;
1962 bool wantsDsClear =
true;
1968 if (!QRhiRenderTargetAttachmentTracker::isUpToDate<QD3D11Texture, QD3D11RenderBuffer>(rtTex->
description(), rtD->
currentResIdList))
2027 qWarning(
"Resolve source (%d) and destination (%d) formats do not match",
2033 qWarning(
"Cannot resolve a non-multisample texture");
2038 qWarning(
"Resolve source and destination sizes do not match");
2045 qWarning(
"Resolve source (%d) and destination (%d) formats do not match",
2051 qWarning(
"Resolve source and destination sizes do not match");
2064 if (resourceUpdates)
2070 QRhiCommandBuffer::BeginPassFlags)
2075 if (resourceUpdates)
2093 if (resourceUpdates)
2104 if (pipelineChanged) {
2133 return { binding, binding };
2169 uint offsetInConstants;
2170 uint sizeInConstants;
2174 ID3D11ShaderResourceView *srv;
2182 ID3D11UnorderedAccessView *uav;
2208 for (
const Stage::Uav &u : uavs)
2230 const quint32 offsetInConstants =
b->u.ubuf.offset / 16;
2234 const quint32 sizeInConstants =
aligned(
b->u.ubuf.maybeSize ?
b->u.ubuf.maybeSize : bufD->
m_size, 256u) / 16;
2237 if (nativeBinding.first >= 0)
2238 res[
RBM_VERTEX].buffers.append({
b->binding, nativeBinding.first, bufD->
buffer, offsetInConstants, sizeInConstants });
2242 if (nativeBinding.first >= 0)
2243 res[
RBM_HULL].buffers.append({
b->binding, nativeBinding.first, bufD->
buffer, offsetInConstants, sizeInConstants });
2247 if (nativeBinding.first >= 0)
2248 res[
RBM_DOMAIN].buffers.append({
b->binding, nativeBinding.first, bufD->
buffer, offsetInConstants, sizeInConstants });
2252 if (nativeBinding.first >= 0)
2253 res[
RBM_GEOMETRY].buffers.append({
b->binding, nativeBinding.first, bufD->
buffer, offsetInConstants, sizeInConstants });
2257 if (nativeBinding.first >= 0)
2258 res[
RBM_FRAGMENT].buffers.append({
b->binding, nativeBinding.first, bufD->
buffer, offsetInConstants, sizeInConstants });
2262 if (nativeBinding.first >= 0)
2263 res[
RBM_COMPUTE].buffers.append({
b->binding, nativeBinding.first, bufD->
buffer, offsetInConstants, sizeInConstants });
2282 for (
int elem = 0; elem <
data->count; ++elem) {
2294 const int samplerBinding = texD && samplerD ? nativeBindingVert.second
2295 : (samplerD ? nativeBindingVert.first : -1);
2296 if (nativeBindingVert.first >= 0 && texD)
2297 res[
RBM_VERTEX].textures.append({ nativeBindingVert.first + elem, texD->
srv });
2298 if (samplerBinding >= 0)
2302 const int samplerBinding = texD && samplerD ? nativeBindingHull.second
2303 : (samplerD ? nativeBindingHull.first : -1);
2304 if (nativeBindingHull.first >= 0 && texD)
2305 res[
RBM_HULL].textures.append({ nativeBindingHull.first + elem, texD->
srv });
2306 if (samplerBinding >= 0)
2310 const int samplerBinding = texD && samplerD ? nativeBindingDomain.second
2311 : (samplerD ? nativeBindingDomain.first : -1);
2312 if (nativeBindingDomain.first >= 0 && texD)
2313 res[
RBM_DOMAIN].textures.append({ nativeBindingDomain.first + elem, texD->
srv });
2314 if (samplerBinding >= 0)
2318 const int samplerBinding = texD && samplerD ? nativeBindingGeom.second
2319 : (samplerD ? nativeBindingGeom.first : -1);
2320 if (nativeBindingGeom.first >= 0 && texD)
2322 if (samplerBinding >= 0)
2326 const int samplerBinding = texD && samplerD ? nativeBindingFrag.second
2327 : (samplerD ? nativeBindingFrag.first : -1);
2328 if (nativeBindingFrag.first >= 0 && texD)
2330 if (samplerBinding >= 0)
2334 const int samplerBinding = texD && samplerD ? nativeBindingComp.second
2335 : (samplerD ? nativeBindingComp.first : -1);
2336 if (nativeBindingComp.first >= 0 && texD)
2337 res[
RBM_COMPUTE].textures.append({ nativeBindingComp.first + elem, texD->
srv });
2338 if (samplerBinding >= 0)
2353 if (nativeBinding.first >= 0) {
2359 qWarning(
"Unordered access only supported at compute stage");
2372 if (nativeBinding.first >= 0) {
2378 qWarning(
"Unordered access only supported at compute stage");
2393 std::sort(
res[stage].
buffers.begin(),
res[stage].buffers.end(), [](
const Stage::Buffer &
a,
const Stage::Buffer &
b) {
2394 return a.breg < b.breg;
2396 std::sort(
res[stage].
textures.begin(),
res[stage].textures.end(), [](
const Stage::Texture &
a,
const Stage::Texture &
b) {
2397 return a.treg < b.treg;
2399 std::sort(
res[stage].
samplers.begin(),
res[stage].samplers.end(), [](
const Stage::Sampler &
a,
const Stage::Sampler &
b) {
2400 return a.sreg < b.sreg;
2402 std::sort(
res[stage].uavs.begin(),
res[stage].uavs.end(), [](
const Stage::Uav &
a,
const Stage::Uav &
b) {
2403 return a.ureg < b.ureg;
2431 D3D11_MAPPED_SUBRESOURCE mp;
2433 if (SUCCEEDED(hr)) {
2437 qWarning(
"Failed to map buffer: %s",
2438 qPrintable(QSystemError::windowsComString(hr)));
2446 const uint *dynOfsPairs,
int dynOfsPairCount)
2448 const int count = staticOffsets->
batches[batchIndex].resources.count();
2453 for (
int di = 0; di < dynOfsPairCount; ++di) {
2454 const uint binding = dynOfsPairs[2 * di];
2457 if (binding == originalBindings->
batches[batchIndex].resources[
b]) {
2458 const uint offsetInConstants = dynOfsPairs[2 * di + 1];
2468 if (startSlot + countSlots > maxSlots) {
2469 qWarning(
"Not enough D3D11 %s slots to bind %d resources starting at slot %d, max slots is %d",
2470 resType, countSlots, startSlot, maxSlots);
2471 countSlots = maxSlots > startSlot ? maxSlots - startSlot : 0;
2476#define SETUBUFBATCH(stagePrefixL, stagePrefixU) \
2477 if (srbD->stagePrefixL##UniformBufferBatches.present) { \
2478 const QD3D11ShaderResourceBindings::StageUniformBufferBatches &batches(srbD->stagePrefixL##UniformBufferBatches); \
2479 for (int i = 0, ie = batches.ubufs.batches.count(); i != ie; ++i) { \
2480 const uint count = clampedResourceCount(batches.ubufs.batches[i].startBinding, \
2481 batches.ubufs.batches[i].resources.count(), \
2482 D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, \
2483 #stagePrefixU " cbuf"); \
2485 if (!dynOfsPairCount) { \
2486 context->stagePrefixU##SetConstantBuffers1(batches.ubufs.batches[i].startBinding, \
2488 batches.ubufs.batches[i].resources.constData(), \
2489 batches.ubufoffsets.batches[i].resources.constData(), \
2490 batches.ubufsizes.batches[i].resources.constData()); \
2492 applyDynamicOffsets(offsets, i, \
2493 &batches.ubuforigbindings, &batches.ubufoffsets, \
2494 dynOfsPairs, dynOfsPairCount); \
2495 context->stagePrefixU##SetConstantBuffers1(batches.ubufs.batches[i].startBinding, \
2497 batches.ubufs.batches[i].resources.constData(), \
2499 batches.ubufsizes.batches[i].resources.constData()); \
2505#define SETSAMPLERBATCH(stagePrefixL, stagePrefixU) \
2506 if (srbD->stagePrefixL##SamplerBatches.present) { \
2507 for (const auto &batch : srbD->stagePrefixL##SamplerBatches.samplers.batches) { \
2508 const uint count = clampedResourceCount(batch.startBinding, batch.resources.count(), \
2509 D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT, #stagePrefixU " sampler"); \
2511 context->stagePrefixU##SetSamplers(batch.startBinding, count, batch.resources.constData()); \
2513 for (const auto &batch : srbD->stagePrefixL##SamplerBatches.shaderresources.batches) { \
2514 const uint count = clampedResourceCount(batch.startBinding, batch.resources.count(), \
2515 D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, #stagePrefixU " SRV"); \
2517 context->stagePrefixU##SetShaderResources(batch.startBinding, count, batch.resources.constData()); \
2518 contextState.stagePrefixL##HighestActiveSrvBinding = qMax(contextState.stagePrefixL##HighestActiveSrvBinding, \
2519 int(batch.startBinding + count) - 1); \
2524#define SETUAVBATCH(stagePrefixL, stagePrefixU) \
2525 if (srbD->stagePrefixL##UavBatches.present) { \
2526 for (const auto &batch : srbD->stagePrefixL##UavBatches.uavs.batches) { \
2527 const uint count = clampedResourceCount(batch.startBinding, batch.resources.count(), \
2528 D3D11_1_UAV_SLOT_COUNT, #stagePrefixU " UAV"); \
2530 context->stagePrefixU##SetUnorderedAccessViews(batch.startBinding, \
2532 batch.resources.constData(), \
2534 contextState.stagePrefixL##HighestActiveUavBinding = qMax(contextState.stagePrefixL##HighestActiveUavBinding, \
2535 int(batch.startBinding + count) - 1); \
2541 const uint *dynOfsPairs,
int dynOfsPairCount,
2542 bool offsetOnlyChange)
2553 if (!offsetOnlyChange) {
2570 context->IASetIndexBuffer(
nullptr, DXGI_FORMAT_R16_UINT, 0);
2574 if (
contextState.vsHighestActiveVertexBufferBinding >= 0) {
2578 nullbufs[
i] =
nullptr;
2595 if (nullsrvCount > 0) {
2597 D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT> nullsrvs(nullsrvCount);
2598 for (
int i = 0;
i < nullsrvs.count(); ++
i)
2599 nullsrvs[
i] =
nullptr;
2601 context->VSSetShaderResources(0, UINT(
contextState.vsHighestActiveSrvBinding + 1), nullsrvs.constData());
2605 context->HSSetShaderResources(0, UINT(
contextState.hsHighestActiveSrvBinding + 1), nullsrvs.constData());
2609 context->DSSetShaderResources(0, UINT(
contextState.dsHighestActiveSrvBinding + 1), nullsrvs.constData());
2613 context->GSSetShaderResources(0, UINT(
contextState.gsHighestActiveSrvBinding + 1), nullsrvs.constData());
2617 context->PSSetShaderResources(0, UINT(
contextState.fsHighestActiveSrvBinding + 1), nullsrvs.constData());
2621 context->CSSetShaderResources(0, UINT(
contextState.csHighestActiveSrvBinding + 1), nullsrvs.constData());
2627 const int nulluavCount =
contextState.csHighestActiveUavBinding + 1;
2629 D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT> nulluavs(nulluavCount);
2630 for (
int i = 0;
i < nulluavCount; ++
i)
2631 nulluavs[
i] =
nullptr;
2632 context->CSSetUnorderedAccessViews(0, UINT(nulluavCount), nulluavs.constData(),
nullptr);
2637#define SETSHADER(StageL, StageU) \
2638 if (psD->StageL.shader) { \
2639 context->StageU##SetShader(psD->StageL.shader, nullptr, 0); \
2640 currentShaderMask |= StageU##MaskBit; \
2641 } else if (currentShaderMask & StageU##MaskBit) { \
2642 context->StageU##SetShader(nullptr, nullptr, 0); \
2643 currentShaderMask &= ~StageU##MaskBit; \
2649 float blendConstants[] = { 1, 1, 1, 1 };
2650 enum ActiveShaderMask {
2657 int currentShaderMask = 0xFF;
2659 if (timestampSwapChain) {
2697 ds |= D3D11_CLEAR_DEPTH;
2699 ds |= D3D11_CLEAR_STENCIL;
2728 contextState.vsHighestActiveVertexBufferBinding = qMax<int>(
2780 qWarning(
"No graphics pipeline active for draw; ignored");
2793 qWarning(
"No graphics pipeline active for drawIndexed; ignored");
2858 it.value()->Release();
2863 rhiD->unregisterResource(
this);
2870 u |= D3D11_BIND_VERTEX_BUFFER;
2872 u |= D3D11_BIND_INDEX_BUFFER;
2874 u |= D3D11_BIND_CONSTANT_BUFFER;
2876 u |= D3D11_BIND_UNORDERED_ACCESS;
2886 qWarning(
"UniformBuffer must always be combined with Dynamic on D3D11");
2891 qWarning(
"StorageBuffer cannot be combined with Dynamic");
2898 D3D11_BUFFER_DESC
desc = {};
2899 desc.ByteWidth = roundedSize;
2908 qWarning(
"Failed to create buffer: %s",
2909 qPrintable(QSystemError::windowsComString(hr)));
2914 dynBuf =
new char[nonZeroSize];
2922 rhiD->registerResource(
this);
2930 rhiD->executeBufferHostWrites(
this);
2932 return { { &
buffer }, 1 };
2944 D3D11_MAPPED_SUBRESOURCE mp;
2946 HRESULT hr = rhiD->context->Map(
buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mp);
2948 qWarning(
"Failed to map buffer: %s",
2949 qPrintable(QSystemError::windowsComString(hr)));
2952 return static_cast<char *
>(mp.pData);
2958 rhiD->context->Unmap(
buffer, 0);
2968 D3D11_UNORDERED_ACCESS_VIEW_DESC
desc = {};
2969 desc.Format = DXGI_FORMAT_R32_TYPELESS;
2970 desc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
2973 desc.Buffer.Flags = D3D11_BUFFER_UAV_FLAG_RAW;
2976 ID3D11UnorderedAccessView *uav =
nullptr;
2979 qWarning(
"Failed to create UAV: %s",
2980 qPrintable(QSystemError::windowsComString(hr)));
2989 int sampleCount, QRhiRenderBuffer::Flags
flags,
3020 rhiD->unregisterResource(
this);
3034 D3D11_TEXTURE2D_DESC
desc = {};
3040 desc.Usage = D3D11_USAGE_DEFAULT;
3046 desc.BindFlags = D3D11_BIND_RENDER_TARGET;
3049 qWarning(
"Failed to create color renderbuffer: %s",
3050 qPrintable(QSystemError::windowsComString(hr)));
3053 D3D11_RENDER_TARGET_VIEW_DESC rtvDesc = {};
3055 rtvDesc.ViewDimension =
desc.SampleDesc.Count > 1 ? D3D11_RTV_DIMENSION_TEXTURE2DMS
3056 : D3D11_RTV_DIMENSION_TEXTURE2D;
3057 hr = rhiD->dev->CreateRenderTargetView(
tex, &rtvDesc, &
rtv);
3059 qWarning(
"Failed to create rtv: %s",
3060 qPrintable(QSystemError::windowsComString(hr)));
3066 desc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
3069 qWarning(
"Failed to create depth-stencil buffer: %s",
3070 qPrintable(QSystemError::windowsComString(hr)));
3073 D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc = {};
3075 dsvDesc.ViewDimension =
desc.SampleDesc.Count > 1 ? D3D11_DSV_DIMENSION_TEXTURE2DMS
3076 : D3D11_DSV_DIMENSION_TEXTURE2D;
3077 hr = rhiD->dev->CreateDepthStencilView(
tex, &dsvDesc, &
dsv);
3079 qWarning(
"Failed to create dsv: %s",
3080 qPrintable(QSystemError::windowsComString(hr)));
3091 rhiD->registerResource(
this);
3148 rhiD->unregisterResource(
this);
3155 return DXGI_FORMAT_R16_FLOAT;
3157 return DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
3159 return DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
3161 return DXGI_FORMAT_R32_FLOAT;
3164 return DXGI_FORMAT_R32_FLOAT;
3172 return DXGI_FORMAT_D16_UNORM;
3174 return DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
3176 return DXGI_FORMAT_D24_UNORM_S8_UINT;
3178 return DXGI_FORMAT_D32_FLOAT;
3181 return DXGI_FORMAT_D32_FLOAT;
3206 qWarning(
"Cubemap texture cannot be multisample");
3210 qWarning(
"3D texture cannot be multisample");
3214 qWarning(
"Multisample texture cannot have mipmaps");
3218 if (isDepth && hasMipMaps) {
3219 qWarning(
"Depth texture cannot have mipmaps");
3222 if (isCube && is3D) {
3223 qWarning(
"Texture cannot be both cube and 3D");
3226 if (isArray && is3D) {
3227 qWarning(
"Texture cannot be both array and 3D");
3230 if (isCube && is1D) {
3231 qWarning(
"Texture cannot be both cube and 1D");
3235 qWarning(
"Texture cannot be both 1D and 3D");
3239 qWarning(
"Texture cannot have a depth of %d when it is not 3D",
m_depth);
3252 *adjustedSize =
size;
3266 D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
3269 srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
3274 srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1DARRAY;
3280 srvDesc.Texture1DArray.FirstArraySlice = 0;
3284 srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D;
3287 }
else if (isArray) {
3289 srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DMSARRAY;
3294 srvDesc.Texture2DMSArray.FirstArraySlice = 0;
3298 srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
3304 srvDesc.Texture2DArray.FirstArraySlice = 0;
3310 srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DMS;
3312 srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D;
3315 srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
3323 qWarning(
"Failed to create srv: %s",
3324 qPrintable(QSystemError::windowsComString(hr)));
3344 uint bindFlags = D3D11_BIND_SHADER_RESOURCE;
3345 uint miscFlags = isCube ? D3D11_RESOURCE_MISC_TEXTURECUBE : 0;
3348 bindFlags |= D3D11_BIND_DEPTH_STENCIL;
3350 bindFlags |= D3D11_BIND_RENDER_TARGET;
3354 qWarning(
"Depth texture cannot have mipmaps generated");
3357 bindFlags |= D3D11_BIND_RENDER_TARGET;
3358 miscFlags |= D3D11_RESOURCE_MISC_GENERATE_MIPS;
3361 bindFlags |= D3D11_BIND_UNORDERED_ACCESS;
3365 D3D11_TEXTURE1D_DESC
desc = {};
3370 desc.Usage = D3D11_USAGE_DEFAULT;
3371 desc.BindFlags = bindFlags;
3372 desc.MiscFlags = miscFlags;
3376 qWarning(
"Failed to create 1D texture: %s",
3377 qPrintable(QSystemError::windowsComString(hr)));
3384 D3D11_TEXTURE2D_DESC
desc = {};
3391 desc.Usage = D3D11_USAGE_DEFAULT;
3392 desc.BindFlags = bindFlags;
3393 desc.MiscFlags = miscFlags;
3397 qWarning(
"Failed to create 2D texture: %s",
3398 qPrintable(QSystemError::windowsComString(hr)));
3404 D3D11_TEXTURE3D_DESC
desc = {};
3410 desc.Usage = D3D11_USAGE_DEFAULT;
3411 desc.BindFlags = bindFlags;
3412 desc.MiscFlags = miscFlags;
3416 qWarning(
"Failed to create 3D texture: %s",
3417 qPrintable(QSystemError::windowsComString(hr)));
3428 rhiD->registerResource(
this);
3441 tex3D =
reinterpret_cast<ID3D11Texture3D *
>(
src.object);
3443 tex1D =
reinterpret_cast<ID3D11Texture1D *
>(
src.object);
3445 tex =
reinterpret_cast<ID3D11Texture2D *
>(
src.object);
3452 rhiD->registerResource(
this);
3469 D3D11_UNORDERED_ACCESS_VIEW_DESC
desc = {};
3472 desc.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2DARRAY;
3473 desc.Texture2DArray.MipSlice = UINT(
level);
3474 desc.Texture2DArray.FirstArraySlice = 0;
3475 desc.Texture2DArray.ArraySize = 6;
3476 }
else if (isArray) {
3477 desc.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2DARRAY;
3478 desc.Texture2DArray.MipSlice = UINT(
level);
3479 desc.Texture2DArray.FirstArraySlice = 0;
3482 desc.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE3D;
3485 desc.ViewDimension = D3D11_UAV_DIMENSION_TEXTURE2D;
3490 ID3D11UnorderedAccessView *uav =
nullptr;
3493 qWarning(
"Failed to create UAV: %s",
3494 qPrintable(QSystemError::windowsComString(hr)));
3504 :
QRhiSampler(rhi, magFilter, minFilter, mipmapMode, u,
v,
w)
3523 rhiD->unregisterResource(
this);
3531 return D3D11_FILTER_MIN_MAG_POINT_MIP_LINEAR;
3533 return D3D11_FILTER_MIN_MAG_MIP_POINT;
3536 return D3D11_FILTER_MIN_POINT_MAG_MIP_LINEAR;
3538 return D3D11_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT;
3543 return D3D11_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR;
3545 return D3D11_FILTER_MIN_LINEAR_MAG_MIP_POINT;
3548 return D3D11_FILTER_MIN_MAG_MIP_LINEAR;
3550 return D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT;
3555 return D3D11_FILTER_MIN_MAG_MIP_LINEAR;
3562 return D3D11_TEXTURE_ADDRESS_WRAP;
3564 return D3D11_TEXTURE_ADDRESS_CLAMP;
3566 return D3D11_TEXTURE_ADDRESS_MIRROR;
3569 return D3D11_TEXTURE_ADDRESS_CLAMP;
3577 return D3D11_COMPARISON_NEVER;
3579 return D3D11_COMPARISON_LESS;
3581 return D3D11_COMPARISON_EQUAL;
3583 return D3D11_COMPARISON_LESS_EQUAL;
3585 return D3D11_COMPARISON_GREATER;
3587 return D3D11_COMPARISON_NOT_EQUAL;
3589 return D3D11_COMPARISON_GREATER_EQUAL;
3591 return D3D11_COMPARISON_ALWAYS;
3594 return D3D11_COMPARISON_NEVER;
3603 D3D11_SAMPLER_DESC
desc = {};
3606 desc.Filter = D3D11_FILTER(
desc.Filter | 0x80);
3610 desc.MaxAnisotropy = 1.0f;
3617 qWarning(
"Failed to create sampler state: %s",
3618 qPrintable(QSystemError::windowsComString(hr)));
3623 rhiD->registerResource(
this);
3642 rhiD->unregisterResource(
this);
3655 rhiD->registerResource(rpD,
false);
3733 rhiD->unregisterResource(
this);
3740 rhiD->registerResource(rpD,
false);
3765 D3D11_RENDER_TARGET_VIEW_DESC rtvDesc = {};
3768 rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
3769 rtvDesc.Texture2DArray.MipSlice = UINT(colorAtt.
level());
3770 rtvDesc.Texture2DArray.FirstArraySlice = UINT(colorAtt.
layer());
3771 rtvDesc.Texture2DArray.ArraySize = 1;
3774 rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE1DARRAY;
3775 rtvDesc.Texture1DArray.MipSlice = UINT(colorAtt.
level());
3776 rtvDesc.Texture1DArray.FirstArraySlice = UINT(colorAtt.
layer());
3777 rtvDesc.Texture1DArray.ArraySize = 1;
3779 rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE1D;
3780 rtvDesc.Texture1D.MipSlice = UINT(colorAtt.
level());
3784 rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMSARRAY;
3785 rtvDesc.Texture2DMSArray.FirstArraySlice = UINT(colorAtt.
layer());
3786 rtvDesc.Texture2DMSArray.ArraySize = 1;
3788 rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
3789 rtvDesc.Texture2DArray.MipSlice = UINT(colorAtt.
level());
3790 rtvDesc.Texture2DArray.FirstArraySlice = UINT(colorAtt.
layer());
3791 rtvDesc.Texture2DArray.ArraySize = 1;
3794 rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE3D;
3795 rtvDesc.Texture3D.MipSlice = UINT(colorAtt.
level());
3796 rtvDesc.Texture3D.FirstWSlice = UINT(colorAtt.
layer());
3797 rtvDesc.Texture3D.WSize = 1;
3800 rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DMS;
3802 rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
3803 rtvDesc.Texture2D.MipSlice = UINT(colorAtt.
level());
3808 qWarning(
"Failed to create rtv: %s",
3809 qPrintable(QSystemError::windowsComString(hr)));
3813 if (attIndex == 0) {
3820 rtv[attIndex] = rbD->
rtv;
3821 if (attIndex == 0) {
3829 if (hasDepthStencil) {
3833 D3D11_DEPTH_STENCIL_VIEW_DESC dsvDesc = {};
3835 dsvDesc.ViewDimension = depthTexD->
sampleDesc.Count > 1 ? D3D11_DSV_DIMENSION_TEXTURE2DMS
3836 : D3D11_DSV_DIMENSION_TEXTURE2D;
3839 dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY;
3841 dsvDesc.Texture2DMSArray.FirstArraySlice = UINT(depthTexD->
arrayRangeStart());
3844 dsvDesc.Texture2DMSArray.FirstArraySlice = 0;
3845 dsvDesc.Texture2DMSArray.ArraySize = UINT(
qMax(0, depthTexD->
arraySize()));
3848 dsvDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2DARRAY;
3850 dsvDesc.Texture2DArray.FirstArraySlice = UINT(depthTexD->
arrayRangeStart());
3853 dsvDesc.Texture2DArray.FirstArraySlice = 0;
3854 dsvDesc.Texture2DArray.ArraySize = UINT(
qMax(0, depthTexD->
arraySize()));
3858 HRESULT hr = rhiD->dev->CreateDepthStencilView(depthTexD->
tex, &dsvDesc, &
dsv);
3860 qWarning(
"Failed to create dsv: %s",
3861 qPrintable(QSystemError::windowsComString(hr)));
3888 QRhiRenderTargetAttachmentTracker::updateResIdList<QD3D11Texture, QD3D11RenderBuffer>(
m_desc, &
d.
currentResIdList);
3890 rhiD->registerResource(
this);
3896 if (!QRhiRenderTargetAttachmentTracker::isUpToDate<QD3D11Texture, QD3D11RenderBuffer>(
m_desc,
d.
currentResIdList))
3929 rhiD->unregisterResource(
this);
3938 if (!rhiD->sanityCheckShaderResourceBindings(
this))
3941 rhiD->updateLayoutDesc(
this);
3961 rhiD->registerResource(
this,
false);
3993 s.shader->Release();
3996 s.nativeResourceBindingMap.clear();
4030 rhiD->unregisterResource(
this);
4037 return D3D11_CULL_NONE;
4039 return D3D11_CULL_FRONT;
4041 return D3D11_CULL_BACK;
4044 return D3D11_CULL_NONE;
4052 return D3D11_FILL_SOLID;
4054 return D3D11_FILL_WIREFRAME;
4057 return D3D11_FILL_SOLID;
4065 return D3D11_COMPARISON_NEVER;
4067 return D3D11_COMPARISON_LESS;
4069 return D3D11_COMPARISON_EQUAL;
4071 return D3D11_COMPARISON_LESS_EQUAL;
4073 return D3D11_COMPARISON_GREATER;
4075 return D3D11_COMPARISON_NOT_EQUAL;
4077 return D3D11_COMPARISON_GREATER_EQUAL;
4079 return D3D11_COMPARISON_ALWAYS;
4082 return D3D11_COMPARISON_ALWAYS;
4090 return D3D11_STENCIL_OP_ZERO;
4092 return D3D11_STENCIL_OP_KEEP;
4094 return D3D11_STENCIL_OP_REPLACE;
4096 return D3D11_STENCIL_OP_INCR_SAT;
4098 return D3D11_STENCIL_OP_DECR_SAT;
4100 return D3D11_STENCIL_OP_INVERT;
4102 return D3D11_STENCIL_OP_INCR;
4104 return D3D11_STENCIL_OP_DECR;
4107 return D3D11_STENCIL_OP_KEEP;
4115 return DXGI_FORMAT_R32G32B32A32_FLOAT;
4117 return DXGI_FORMAT_R32G32B32_FLOAT;
4119 return DXGI_FORMAT_R32G32_FLOAT;
4121 return DXGI_FORMAT_R32_FLOAT;
4123 return DXGI_FORMAT_R8G8B8A8_UNORM;
4125 return DXGI_FORMAT_R8G8_UNORM;
4127 return DXGI_FORMAT_R8_UNORM;
4129 return DXGI_FORMAT_R32G32B32A32_UINT;
4131 return DXGI_FORMAT_R32G32B32_UINT;
4133 return DXGI_FORMAT_R32G32_UINT;
4135 return DXGI_FORMAT_R32_UINT;
4137 return DXGI_FORMAT_R32G32B32A32_SINT;
4139 return DXGI_FORMAT_R32G32B32_SINT;
4141 return DXGI_FORMAT_R32G32_SINT;
4143 return DXGI_FORMAT_R32_SINT;
4147 return DXGI_FORMAT_R16G16B16A16_FLOAT;
4149 return DXGI_FORMAT_R16G16_FLOAT;
4151 return DXGI_FORMAT_R16_FLOAT;
4154 return DXGI_FORMAT_R32G32B32A32_FLOAT;
4162 return D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
4164 return D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
4166 return D3D11_PRIMITIVE_TOPOLOGY_LINELIST;
4168 return D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP;
4170 return D3D11_PRIMITIVE_TOPOLOGY_POINTLIST;
4172 Q_ASSERT(patchControlPointCount >= 1 && patchControlPointCount <= 32);
4173 return D3D11_PRIMITIVE_TOPOLOGY(D3D11_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST + (patchControlPointCount - 1));
4176 return D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
4184 f |= D3D11_COLOR_WRITE_ENABLE_RED;
4186 f |= D3D11_COLOR_WRITE_ENABLE_GREEN;
4188 f |= D3D11_COLOR_WRITE_ENABLE_BLUE;
4190 f |= D3D11_COLOR_WRITE_ENABLE_ALPHA;
4204 return D3D11_BLEND_ZERO;
4206 return D3D11_BLEND_ONE;
4208 return rgb ? D3D11_BLEND_SRC_COLOR : D3D11_BLEND_SRC_ALPHA;
4210 return rgb ? D3D11_BLEND_INV_SRC_COLOR : D3D11_BLEND_INV_SRC_ALPHA;
4212 return rgb ? D3D11_BLEND_DEST_COLOR : D3D11_BLEND_DEST_ALPHA;
4214 return rgb ? D3D11_BLEND_INV_DEST_COLOR : D3D11_BLEND_INV_DEST_ALPHA;
4216 return D3D11_BLEND_SRC_ALPHA;
4218 return D3D11_BLEND_INV_SRC_ALPHA;
4220 return D3D11_BLEND_DEST_ALPHA;
4222 return D3D11_BLEND_INV_DEST_ALPHA;
4225 return D3D11_BLEND_BLEND_FACTOR;
4228 return D3D11_BLEND_INV_BLEND_FACTOR;
4230 return D3D11_BLEND_SRC_ALPHA_SAT;
4232 return rgb ? D3D11_BLEND_SRC1_COLOR : D3D11_BLEND_SRC1_ALPHA;
4234 return rgb ? D3D11_BLEND_INV_SRC1_COLOR : D3D11_BLEND_INV_SRC1_ALPHA;
4236 return D3D11_BLEND_SRC1_ALPHA;
4238 return D3D11_BLEND_INV_SRC1_ALPHA;
4241 return D3D11_BLEND_ZERO;
4249 return D3D11_BLEND_OP_ADD;
4251 return D3D11_BLEND_OP_SUBTRACT;
4253 return D3D11_BLEND_OP_REV_SUBTRACT;
4255 return D3D11_BLEND_OP_MIN;
4257 return D3D11_BLEND_OP_MAX;
4260 return D3D11_BLEND_OP_ADD;
4279 *usedShaderKey =
key;
4286 qWarning() <<
"No HLSL (shader model 5.0) code found in baked shader" <<
shader;
4291 *usedShaderKey =
key;
4294 switch (
shader.stage()) {
4326 return cacheIt.value();
4330 if (d3dCompile ==
nullptr) {
4331 qWarning(
"Unable to resolve function D3DCompile()");
4335 ID3DBlob *bytecode =
nullptr;
4336 ID3DBlob *errors =
nullptr;
4338 nullptr,
nullptr,
nullptr,
4340 if (FAILED(hr) || !bytecode) {
4341 qWarning(
"HLSL shader compilation failed: 0x%x",
uint(hr));
4344 int(errors->GetBufferSize()));
4351 result.resize(
int(bytecode->GetBufferSize()));
4352 memcpy(
result.data(), bytecode->GetBufferPointer(),
size_t(
result.size()));
4353 bytecode->Release();
4367 rhiD->pipelineCreationStart();
4368 if (!rhiD->sanityCheckGraphicsPipeline(
this))
4371 D3D11_RASTERIZER_DESC rastDesc = {};
4377 rastDesc.DepthClipEnable =
true;
4379 rastDesc.MultisampleEnable = rhiD->effectiveSampleCount(
m_sampleCount).Count > 1;
4382 qWarning(
"Failed to create rasterizer state: %s",
4383 qPrintable(QSystemError::windowsComString(hr)));
4387 D3D11_DEPTH_STENCIL_DESC dsDesc = {};
4389 dsDesc.DepthWriteMask =
m_depthWrite ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
4404 hr = rhiD->dev->CreateDepthStencilState(&dsDesc, &
dsState);
4406 qWarning(
"Failed to create depth-stencil state: %s",
4407 qPrintable(QSystemError::windowsComString(hr)));
4411 D3D11_BLEND_DESC blendDesc = {};
4415 D3D11_RENDER_TARGET_BLEND_DESC blend = {};
4416 blend.BlendEnable =
b.enable;
4424 blendDesc.RenderTarget[
i] = blend;
4427 D3D11_RENDER_TARGET_BLEND_DESC blend = {};
4428 blend.RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL;
4429 blendDesc.RenderTarget[0] = blend;
4431 hr = rhiD->dev->CreateBlendState(&blendDesc, &
blendState);
4433 qWarning(
"Failed to create blend state: %s",
4434 qPrintable(QSystemError::windowsComString(hr)));
4440 auto cacheIt = rhiD->m_shaderCache.constFind(shaderStage);
4441 if (cacheIt != rhiD->m_shaderCache.constEnd()) {
4442 switch (shaderStage.type()) {
4444 vs.shader =
static_cast<ID3D11VertexShader *
>(cacheIt->s);
4445 vs.shader->AddRef();
4446 vsByteCode = cacheIt->bytecode;
4447 vs.nativeResourceBindingMap = cacheIt->nativeResourceBindingMap;
4450 hs.shader =
static_cast<ID3D11HullShader *
>(cacheIt->s);
4451 hs.shader->AddRef();
4452 hs.nativeResourceBindingMap = cacheIt->nativeResourceBindingMap;
4455 ds.shader =
static_cast<ID3D11DomainShader *
>(cacheIt->s);
4456 ds.shader->AddRef();
4457 ds.nativeResourceBindingMap = cacheIt->nativeResourceBindingMap;
4460 gs.shader =
static_cast<ID3D11GeometryShader *
>(cacheIt->s);
4461 gs.shader->AddRef();
4462 gs.nativeResourceBindingMap = cacheIt->nativeResourceBindingMap;
4465 fs.shader =
static_cast<ID3D11PixelShader *
>(cacheIt->s);
4466 fs.shader->AddRef();
4467 fs.nativeResourceBindingMap = cacheIt->nativeResourceBindingMap;
4475 UINT compileFlags = 0;
4477 compileFlags |= D3DCOMPILE_DEBUG;
4479 const QByteArray bytecode = rhiD->compileHlslShaderSource(shaderStage.shader(), shaderStage.shaderVariant(), compileFlags,
4480 &
error, &shaderKey);
4488 rhiD->clearShaderCache();
4491 switch (shaderStage.type()) {
4493 hr = rhiD->dev->CreateVertexShader(bytecode.
constData(), SIZE_T(bytecode.
size()),
nullptr, &
vs.shader);
4495 qWarning(
"Failed to create vertex shader: %s",
4496 qPrintable(QSystemError::windowsComString(hr)));
4499 vsByteCode = bytecode;
4500 vs.nativeResourceBindingMap = shaderStage.shader().nativeResourceBindingMap(shaderKey);
4501 rhiD->m_shaderCache.insert(shaderStage,
QRhiD3D11::Shader(
vs.shader, bytecode,
vs.nativeResourceBindingMap));
4502 vs.shader->AddRef();
4505 hr = rhiD->dev->CreateHullShader(bytecode.
constData(), SIZE_T(bytecode.
size()),
nullptr, &
hs.shader);
4507 qWarning(
"Failed to create hull shader: %s",
4508 qPrintable(QSystemError::windowsComString(hr)));
4511 hs.nativeResourceBindingMap = shaderStage.shader().nativeResourceBindingMap(shaderKey);
4512 rhiD->m_shaderCache.insert(shaderStage,
QRhiD3D11::Shader(
hs.shader, bytecode,
hs.nativeResourceBindingMap));
4513 hs.shader->AddRef();
4516 hr = rhiD->dev->CreateDomainShader(bytecode.
constData(), SIZE_T(bytecode.
size()),
nullptr, &
ds.shader);
4518 qWarning(
"Failed to create domain shader: %s",
4519 qPrintable(QSystemError::windowsComString(hr)));
4522 ds.nativeResourceBindingMap = shaderStage.shader().nativeResourceBindingMap(shaderKey);
4523 rhiD->m_shaderCache.insert(shaderStage,
QRhiD3D11::Shader(
ds.shader, bytecode,
ds.nativeResourceBindingMap));
4524 ds.shader->AddRef();
4527 hr = rhiD->dev->CreateGeometryShader(bytecode.
constData(), SIZE_T(bytecode.
size()),
nullptr, &
gs.shader);
4529 qWarning(
"Failed to create geometry shader: %s",
4530 qPrintable(QSystemError::windowsComString(hr)));
4533 gs.nativeResourceBindingMap = shaderStage.shader().nativeResourceBindingMap(shaderKey);
4534 rhiD->m_shaderCache.insert(shaderStage,
QRhiD3D11::Shader(
gs.shader, bytecode,
gs.nativeResourceBindingMap));
4535 gs.shader->AddRef();
4538 hr = rhiD->dev->CreatePixelShader(bytecode.
constData(), SIZE_T(bytecode.
size()),
nullptr, &
fs.shader);
4540 qWarning(
"Failed to create pixel shader: %s",
4541 qPrintable(QSystemError::windowsComString(hr)));
4544 fs.nativeResourceBindingMap = shaderStage.shader().nativeResourceBindingMap(shaderKey);
4545 rhiD->m_shaderCache.insert(shaderStage,
QRhiD3D11::Shader(
fs.shader, bytecode,
fs.nativeResourceBindingMap));
4546 fs.shader->AddRef();
4562 D3D11_INPUT_ELEMENT_DESC
desc = {};
4567 const int matrixSlice =
it->matrixSlice();
4568 if (matrixSlice < 0) {
4569 desc.SemanticName =
"TEXCOORD";
4570 desc.SemanticIndex = UINT(
it->location());
4575 matrixSliceSemantics.append(
sem);
4576 desc.SemanticName = matrixSliceSemantics.last().constData();
4577 desc.SemanticIndex = UINT(matrixSlice);
4580 desc.InputSlot = UINT(
it->binding());
4581 desc.AlignedByteOffset =
it->offset();
4584 desc.InputSlotClass = D3D11_INPUT_PER_INSTANCE_DATA;
4587 desc.InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
4592 hr = rhiD->dev->CreateInputLayout(inputDescs.
constData(), UINT(inputDescs.
count()),
4595 qWarning(
"Failed to create input layout: %s",
4596 qPrintable(QSystemError::windowsComString(hr)));
4602 rhiD->pipelineCreationEnd();
4604 rhiD->registerResource(
this);
4623 cs.shader->Release();
4624 cs.shader =
nullptr;
4625 cs.nativeResourceBindingMap.clear();
4629 rhiD->unregisterResource(
this);
4638 rhiD->pipelineCreationStart();
4640 auto cacheIt = rhiD->m_shaderCache.constFind(
m_shaderStage);
4641 if (cacheIt != rhiD->m_shaderCache.constEnd()) {
4642 cs.shader =
static_cast<ID3D11ComputeShader *
>(cacheIt->s);
4643 cs.nativeResourceBindingMap = cacheIt->nativeResourceBindingMap;
4647 UINT compileFlags = 0;
4649 compileFlags |= D3DCOMPILE_DEBUG;
4652 &
error, &shaderKey);
4658 HRESULT hr = rhiD->dev->CreateComputeShader(bytecode.
constData(), SIZE_T(bytecode.
size()),
nullptr, &
cs.shader);
4660 qWarning(
"Failed to create compute shader: %s",
4661 qPrintable(QSystemError::windowsComString(hr)));
4668 rhiD->clearShaderCache();
4673 cs.shader->AddRef();
4675 rhiD->pipelineCreationEnd();
4677 rhiD->registerResource(
this);
4703 D3D11_QUERY_DESC queryDesc = {};
4706 queryDesc.Query = D3D11_QUERY_TIMESTAMP_DISJOINT;
4709 qWarning(
"Failed to create timestamp disjoint query: %s",
4710 qPrintable(QSystemError::windowsComString(hr)));
4714 queryDesc.Query = D3D11_QUERY_TIMESTAMP;
4715 for (
int j = 0;
j < 2; ++
j) {
4720 qWarning(
"Failed to create timestamp query: %s",
4721 qPrintable(QSystemError::windowsComString(hr)));
4739 for (
int j = 0;
j < 2; ++
j) {
4742 query[idx]->Release();
4743 query[idx] =
nullptr;
4757 ID3D11Query *tsStart =
query[tsIdx];
4758 ID3D11Query *tsEnd =
query[tsIdx + 1];
4760 D3D11_QUERY_DATA_TIMESTAMP_DISJOINT dj;
4763 ok &=
context->GetData(tsDisjoint, &dj,
sizeof(dj), D3D11_ASYNC_GETDATA_DONOTFLUSH) == S_OK;
4764 ok &=
context->GetData(tsEnd, ×tamps[1],
sizeof(
quint64), D3D11_ASYNC_GETDATA_DONOTFLUSH) == S_OK;
4769 ok &=
context->GetData(tsStart, ×tamps[0],
sizeof(
quint64), D3D11_ASYNC_GETDATA_DONOTFLUSH) == S_OK;
4772 if (!dj.Disjoint && dj.Frequency) {
4773 const float elapsedMs = (timestamps[1] - timestamps[0]) /
float(dj.Frequency) * 1000.0f;
4774 *elapsedSec = elapsedMs / 1000.0;
4847 rhiD->unregisterResource(
this);
4869 QRect wr =
w->geometry();
4872 IDXGIOutput *currentOutput =
nullptr;
4873 IDXGIOutput *
output =
nullptr;
4874 for (UINT
i = 0; adapter->EnumOutputs(
i, &
output) != DXGI_ERROR_NOT_FOUND; ++
i) {
4875 DXGI_OUTPUT_DESC
desc;
4877 const RECT
r =
desc.DesktopCoordinates;
4886 if (currentOutput) {
4887 ok = SUCCEEDED(currentOutput->QueryInterface(__uuidof(IDXGIOutput6),
reinterpret_cast<void **
>(
result)));
4888 currentOutput->Release();
4896 IDXGIOutput6 *out6 =
nullptr;
4898 ok = SUCCEEDED(out6->GetDesc1(
result));
4910 qWarning(
"Attempted to call isFormatSupported() without a window set");
4915 DXGI_OUTPUT_DESC1 desc1;
4917 if (desc1.ColorSpace == DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020)
4929 DXGI_OUTPUT_DESC1 hdrOutputDesc;
4931 info.isHardCodedDefaults =
false;
4933 info.limits.luminanceInNits.minLuminance = hdrOutputDesc.MinLuminance;
4934 info.limits.luminanceInNits.maxLuminance = hdrOutputDesc.MaxLuminance;
4944 rhiD->registerResource(rpD,
false);
4949 ID3D11Texture2D **tex, ID3D11RenderTargetView **rtv)
const
4951 D3D11_TEXTURE2D_DESC
desc = {};
4958 desc.Usage = D3D11_USAGE_DEFAULT;
4959 desc.BindFlags = D3D11_BIND_RENDER_TARGET;
4962 HRESULT hr = rhiD->dev->CreateTexture2D(&
desc,
nullptr, tex);
4964 qWarning(
"Failed to create color buffer texture: %s",
4965 qPrintable(QSystemError::windowsComString(hr)));
4969 D3D11_RENDER_TARGET_VIEW_DESC rtvDesc = {};
4971 rtvDesc.ViewDimension =
sampleDesc.Count > 1 ? D3D11_RTV_DIMENSION_TEXTURE2DMS : D3D11_RTV_DIMENSION_TEXTURE2D;
4972 hr = rhiD->dev->CreateRenderTargetView(*tex, &rtvDesc, rtv);
4974 qWarning(
"Failed to create color buffer rtv: %s",
4975 qPrintable(QSystemError::windowsComString(hr)));
4989 qCDebug(QRHI_LOG_INFO,
"Creating Direct Composition device (needed for semi-transparent windows)");
5016 HWND hwnd =
reinterpret_cast<HWND
>(
window->winId());
5022 if (rhiD->ensureDirectCompositionDevice()) {
5024 hr = rhiD->dcompDevice->CreateTargetForHwnd(hwnd,
true, &
dcompTarget);
5026 qWarning(
"Failed to create Direct Compsition target for the window: %s",
5027 qPrintable(QSystemError::windowsComString(hr)));
5031 hr = rhiD->dcompDevice->CreateVisual(&
dcompVisual);
5033 qWarning(
"Failed to create DirectComposition visual: %s",
5034 qPrintable(QSystemError::windowsComString(hr)));
5040 qWarning(
"Swapchain says surface has alpha but the window has no alphaBufferSize set. "
5041 "This may lead to problems.");
5059 DXGI_COLOR_SPACE_TYPE hdrColorSpace = DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709;
5060 DXGI_OUTPUT_DESC1 hdrOutputDesc;
5063 if (hdrOutputDesc.ColorSpace == DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020) {
5067 hdrColorSpace = DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709;
5072 hdrColorSpace = DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020;
5082 qWarning(
"The output associated with the window is not HDR capable "
5083 "(or Use HDR is Off in the Display Settings), ignoring HDR format request");
5093 DXGI_SWAP_CHAIN_DESC1
desc = {};
5097 desc.SampleDesc.Count = 1;
5098 desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
5101 desc.Scaling = DXGI_SCALING_NONE;
5102 desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
5108 desc.AlphaMode = DXGI_ALPHA_MODE_PREMULTIPLIED;
5113 desc.Scaling = DXGI_SCALING_STRETCH;
5116 IDXGIFactory2 *fac =
static_cast<IDXGIFactory2 *
>(rhiD->dxgiFactory);
5117 IDXGISwapChain1 *sc1;
5120 hr = fac->CreateSwapChainForComposition(rhiD->dev, &
desc,
nullptr, &sc1);
5122 hr = fac->CreateSwapChainForHwnd(rhiD->dev, hwnd, &
desc,
nullptr,
nullptr, &sc1);
5131 hr = fac->CreateSwapChainForComposition(rhiD->dev, &
desc,
nullptr, &sc1);
5133 hr = fac->CreateSwapChainForHwnd(rhiD->dev, hwnd, &
desc,
nullptr,
nullptr, &sc1);
5136 if (SUCCEEDED(hr)) {
5139 IDXGISwapChain3 *sc3 =
nullptr;
5140 if (SUCCEEDED(sc1->QueryInterface(__uuidof(IDXGISwapChain3),
reinterpret_cast<void **
>(&sc3)))) {
5141 hr = sc3->SetColorSpace1(hdrColorSpace);
5143 qWarning(
"Failed to set color space on swapchain: %s",
5144 qPrintable(QSystemError::windowsComString(hr)));
5147 qWarning(
"IDXGISwapChain3 not available, HDR swapchain will not work as expected");
5152 if (SUCCEEDED(hr)) {
5155 qWarning(
"Failed to associate Direct Composition visual with the target: %s",
5156 qPrintable(QSystemError::windowsComString(hr)));
5159 qWarning(
"Failed to set content for Direct Composition visual: %s",
5160 qPrintable(QSystemError::windowsComString(hr)));
5164 rhiD->dxgiFactory->MakeWindowAssociation(hwnd, DXGI_MWA_NO_WINDOW_CHANGES);
5168 qWarning(
"Failed to create D3D11 swapchain: %s",
5169 qPrintable(QSystemError::windowsComString(hr)));
5177 if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) {
5178 qWarning(
"Device loss detected in ResizeBuffers()");
5179 rhiD->deviceLost =
true;
5181 }
else if (FAILED(hr)) {
5182 qWarning(
"Failed to resize D3D11 swapchain: %s",
5183 qPrintable(QSystemError::windowsComString(hr)));
5204 qWarning(
"Failed to query swapchain backbuffer: %s",
5205 qPrintable(QSystemError::windowsComString(hr)));
5208 D3D11_RENDER_TARGET_VIEW_DESC rtvDesc = {};
5210 rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
5213 qWarning(
"Failed to create rtv for swapchain backbuffer: %s",
5214 qPrintable(QSystemError::windowsComString(hr)));
5227 qWarning(
"Depth-stencil buffer's sampleCount (%d) does not match color buffers' sample count (%d). Expect problems.",
5234 qWarning(
"Failed to rebuild swapchain's associated depth-stencil buffer for size %dx%d",
5237 qWarning(
"Depth-stencil buffer's size (%dx%d) does not match the surface size (%dx%d). Expect problems.",
5251 rtD->
d.
dpr = float(
window->devicePixelRatio());
5261 if (needsRegistration)
5262 rhiD->registerResource(
this);
IOBluetoothDevice * device
char * data()
\macro QT_NO_CAST_FROM_BYTEARRAY
qsizetype size() const noexcept
Returns the number of bytes in this byte array.
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
void resize(qsizetype size)
Sets the size of the byte array to size bytes.
QByteArray toHex(char separator='\0') const
Returns a hex encoded copy of the byte array.
The QColor class provides colors based on RGB, HSV or CMYK values.
float greenF() const noexcept
Returns the green color component of this color.
float redF() const noexcept
Returns the red color component of this color.
float alphaF() const noexcept
Returns the alpha color component of this color.
float blueF() const noexcept
Returns the blue color component of this color.
void addData(QByteArrayView data) noexcept
Adds the characters in bytes to the cryptographic hash.
QByteArray result() const
Returns the final hash value.
iterator begin()
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
iterator end() noexcept
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last ...
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
bool isNull() const
Returns true if it is a null image, otherwise returns false.
iterator insert(const Key &key, const T &value)
const_iterator cend() const
const_iterator constFind(const Key &key) const
The QMatrix4x4 class represents a 4x4 transformation matrix in 3D space.
\inmodule QtCore\reentrant
constexpr bool isNull() const noexcept
Returns true if both the x and y coordinates are set to 0, otherwise returns false.
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
constexpr QSize size() const noexcept
Returns the size of the rectangle.
constexpr QPoint center() const noexcept
Returns the center point of the rectangle.
const char * constData() const
Type
Specifies storage type of buffer resource.
QRhiRenderBuffer * renderBuffer() const
QRhiTexture * texture() const
QRhiTexture * resolveTexture() const
QPair< QRhiBuffer *, quint32 > VertexInput
Synonym for QPair<QRhiBuffer *, quint32>.
QPair< int, quint32 > DynamicOffset
Synonym for QPair<int, quint32>.
IndexFormat
Specifies the index data type.
QRhiShaderStage m_shaderStage
QRhiShaderResourceBindings * m_shaderResourceBindings
@ CompileShadersWithDebugInfo
\variable QRhiD3D11InitParams::enableDebugLayer
void setScissor(QRhiCommandBuffer *cb, const QRhiScissor &scissor) override
void debugMarkMsg(QRhiCommandBuffer *cb, const QByteArray &msg) override
QRhiD3D11NativeHandles nativeHandlesStruct
bool isYUpInNDC() const override
QRhiSwapChain * createSwapChain() override
void enqueueResourceUpdates(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates)
bool isFeatureSupported(QRhi::Feature feature) const override
QRhi::FrameOpResult endOffscreenFrame(QRhi::EndFrameFlags flags) override
bool isDeviceLost() const override
void executeBufferHostWrites(QD3D11Buffer *bufD)
void resetShaderResources()
void updateShaderResourceBindings(QD3D11ShaderResourceBindings *srbD, const QShader::NativeResourceBindingMap *nativeResourceBindingMaps[])
QRhiStats statistics() override
QHash< BytecodeCacheKey, QByteArray > m_bytecodeCache
QRhiComputePipeline * createComputePipeline() override
void debugMarkBegin(QRhiCommandBuffer *cb, const QByteArray &name) override
QRhi::FrameOpResult finish() override
void setVertexInput(QRhiCommandBuffer *cb, int startBinding, int bindingCount, const QRhiCommandBuffer::VertexInput *bindings, QRhiBuffer *indexBuf, quint32 indexOffset, QRhiCommandBuffer::IndexFormat indexFormat) override
IDXGIAdapter1 * activeAdapter
QRhiGraphicsPipeline * createGraphicsPipeline() override
QRhiShaderResourceBindings * createShaderResourceBindings() override
QVarLengthArray< BufferReadback, 2 > activeBufferReadbacks
QRhi::FrameOpResult beginFrame(QRhiSwapChain *swapChain, QRhi::BeginFrameFlags flags) override
ID3D11DeviceContext1 * context
QList< int > supportedSampleCounts() const override
QRhiTextureRenderTarget * createTextureRenderTarget(const QRhiTextureRenderTargetDescription &desc, QRhiTextureRenderTarget::Flags flags) override
QByteArray compileHlslShaderSource(const QShader &shader, QShader::Variant shaderVariant, uint flags, QString *error, QShaderKey *usedShaderKey)
void setBlendConstants(QRhiCommandBuffer *cb, const QColor &c) override
bool isClipDepthZeroToOne() const override
IDCompositionDevice * dcompDevice
QRhiDriverInfo driverInfoStruct
QHash< QRhiShaderStage, Shader > m_shaderCache
bool ensureDirectCompositionDevice()
void beginComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates, QRhiCommandBuffer::BeginPassFlags flags) override
void draw(QRhiCommandBuffer *cb, quint32 vertexCount, quint32 instanceCount, quint32 firstVertex, quint32 firstInstance) override
void enqueueSubresUpload(QD3D11Texture *texD, QD3D11CommandBuffer *cbD, int layer, int level, const QRhiTextureSubresourceUploadDescription &subresDesc)
void reportLiveObjects(ID3D11Device *device)
void resourceUpdate(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override
QMatrix4x4 clipSpaceCorrMatrix() const override
void executeCommandBuffer(QD3D11CommandBuffer *cbD, QD3D11SwapChain *timestampSwapChain=nullptr)
struct QRhiD3D11::OffscreenFrame ofr
bool isYUpInFramebuffer() const override
int resourceLimit(QRhi::ResourceLimit limit) const override
void beginExternal(QRhiCommandBuffer *cb) override
QRhiTexture * createTexture(QRhiTexture::Format format, const QSize &pixelSize, int depth, int arraySize, int sampleCount, QRhiTexture::Flags flags) override
void setPipelineCacheData(const QByteArray &data) override
void bindShaderResources(QD3D11ShaderResourceBindings *srbD, const uint *dynOfsPairs, int dynOfsPairCount, bool offsetOnlyChange)
void debugMarkEnd(QRhiCommandBuffer *cb) override
DXGI_SAMPLE_DESC effectiveSampleCount(int sampleCount) const
void releaseCachedResources() override
double lastCompletedGpuTime(QRhiCommandBuffer *cb) override
ID3DUserDefinedAnnotation * annotations
bool importedDeviceAndContext
QRhi::FrameOpResult beginOffscreenFrame(QRhiCommandBuffer **cb, QRhi::BeginFrameFlags flags) override
QRhiBuffer * createBuffer(QRhiBuffer::Type type, QRhiBuffer::UsageFlags usage, quint32 size) override
bool supportsAllowTearing
void dispatch(QRhiCommandBuffer *cb, int x, int y, int z) override
void endExternal(QRhiCommandBuffer *cb) override
void setViewport(QRhiCommandBuffer *cb, const QRhiViewport &viewport) override
QVarLengthArray< TextureReadback, 2 > activeTextureReadbacks
void setComputePipeline(QRhiCommandBuffer *cb, QRhiComputePipeline *ps) override
QRhi::FrameOpResult endFrame(QRhiSwapChain *swapChain, QRhi::EndFrameFlags flags) override
bool isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture::Flags flags) const override
void setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBindings *srb, int dynamicOffsetCount, const QRhiCommandBuffer::DynamicOffset *dynamicOffsets) override
D3D_FEATURE_LEVEL featureLevel
void endComputePass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override
bool makeThreadLocalNativeContextCurrent() override
bool create(QRhi::Flags flags) override
void finishActiveReadbacks()
IDXGIFactory1 * dxgiFactory
QByteArray pipelineCacheData() override
const QRhiNativeHandles * nativeHandles() override
QRhiDriverInfo driverInfo() const override
void endPass(QRhiCommandBuffer *cb, QRhiResourceUpdateBatch *resourceUpdates) override
int ubufAlignment() const override
void beginPass(QRhiCommandBuffer *cb, QRhiRenderTarget *rt, const QColor &colorClearValue, const QRhiDepthStencilClearValue &depthStencilClearValue, QRhiResourceUpdateBatch *resourceUpdates, QRhiCommandBuffer::BeginPassFlags flags) override
void drawIndexed(QRhiCommandBuffer *cb, quint32 indexCount, quint32 instanceCount, quint32 firstIndex, qint32 vertexOffset, quint32 firstInstance) override
QRhiSampler * createSampler(QRhiSampler::Filter magFilter, QRhiSampler::Filter minFilter, QRhiSampler::Filter mipmapMode, QRhiSampler::AddressMode u, QRhiSampler::AddressMode v, QRhiSampler::AddressMode w) override
QRhiRenderBuffer * createRenderBuffer(QRhiRenderBuffer::Type type, const QSize &pixelSize, int sampleCount, QRhiRenderBuffer::Flags flags, QRhiTexture::Format backingFormatHint) override
void setGraphicsPipeline(QRhiCommandBuffer *cb, QRhiGraphicsPipeline *ps) override
QRhiD3D11(QRhiD3D11InitParams *params, QRhiD3D11NativeHandles *importDevice=nullptr)
void setStencilRef(QRhiCommandBuffer *cb, quint32 refValue) override
struct QRhiD3D11::@352 contextState
float depthClearValue() const
quint32 stencilClearValue() const
quint32 m_stencilReadMask
@ CompileShadersWithDebugInfo
BlendOp
Specifies the blend operation.
PolygonMode
Specifies the polygon rasterization mode.
BlendFactor
Specifies the blend factor.
StencilOpState m_stencilFront
quint32 m_stencilWriteMask
CompareOp
Specifies the depth or stencil comparison function.
CullMode
Specifies the culling mode.
QVarLengthArray< QRhiShaderStage, 4 > m_shaderStages
QRhiVertexInputLayout m_vertexInputLayout
QVarLengthArray< TargetBlend, 8 > m_targetBlends
QRhiShaderResourceBindings * m_shaderResourceBindings
PolygonMode m_polygonMode
float m_slopeScaledDepthBias
Topology
Specifies the primitive topology.
StencilOpState m_stencilBack
StencilOp
Specifies the stencil operation.
int m_patchControlPointCount
bool isCompressedFormat(QRhiTexture::Format format) const
static const QRhiShaderResourceBinding::Data * shaderResourceBindingData(const QRhiShaderResourceBinding &binding)
quint32 pipelineCacheRhiId() const
void compressedFormatInfo(QRhiTexture::Format format, const QSize &size, quint32 *bpl, quint32 *byteSize, QSize *blockDim) const
static const int MAX_SHADER_CACHE_ENTRIES
static bool sortedBindingLessThan(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b)
qint64 totalPipelineCreationTime() const
void textureFormatInfo(QRhiTexture::Format format, const QSize &size, quint32 *bpl, quint32 *byteSize, quint32 *bytesPerPixel) const
QRhiTexture * texture() const
void setPixelSize(const QSize &sz)
Sets the size (in pixels) to sz.
QRhiTexture::Format m_backingFormatHint
Type
Specifies the type of the renderbuffer.
virtual bool create()=0
Creates the corresponding native graphics resources.
void setRenderPassDescriptor(QRhiRenderPassDescriptor *desc)
Sets the QRhiRenderPassDescriptor desc for use with this render target.
virtual QSize pixelSize() const =0
QRhiRenderPassDescriptor * m_renderPassDesc
QVarLengthArray< BufferOp, BUFFER_OPS_STATIC_ALLOC > bufferOps
QVarLengthArray< TextureOp, TEXTURE_OPS_STATIC_ALLOC > textureOps
static QRhiResourceUpdateBatchPrivate * get(QRhiResourceUpdateBatch *b)
virtual Type resourceType() const =0
QRhiImplementation * m_rhi
Filter
Specifies the minification, magnification, or mipmap filtering.
AddressMode
Specifies the addressing mode.
CompareOp
Specifies the texture comparison function.
std::array< int, 4 > scissor() const
@ TessellationEvaluationStage
@ TessellationControlStage
QVarLengthArray< QRhiShaderResourceBinding, BINDING_PREALLOC > m_bindings
QShader::Variant shaderVariant() const
@ SurfaceHasNonPreMulAlpha
QRhiRenderPassDescriptor * m_renderPassDesc
Format
Describes the swapchain format.
virtual QRhiSwapChainHdrInfo hdrInfo()
\variable QRhiSwapChainHdrInfo::isHardCodedDefaults
QRhiRenderBuffer * m_depthStencil
QPoint destinationTopLeft() const
QPoint sourceTopLeft() const
int destinationLevel() const
int destinationLayer() const
const QRhiColorAttachment * cbeginColorAttachments() const
QRhiTexture * depthTexture() const
const QRhiColorAttachment * cendColorAttachments() const
QRhiRenderBuffer * depthStencilBuffer() const
qsizetype colorAttachmentCount() const
QRhiTextureRenderTargetDescription m_desc
@ PreserveDepthStencilContents
QRhiTextureRenderTargetDescription description() const
quint32 dataStride() const
QPoint sourceTopLeft() const
QPoint destinationTopLeft() const
int arrayRangeStart() const
Format
Specifies the texture format.
int arrayRangeLength() const
ResourceLimit
Describes the resource limit to query.
@ MaxThreadsPerThreadGroup
@ MaxThreadGroupsPerDimension
Feature
Flag values to indicate what features are supported by the backend currently in use.
@ NonDynamicUniformBuffers
@ RenderToNonBaseMipLevel
@ MultisampleRenderBuffer
@ PipelineCacheDataLoadSave
@ ReadBackNonUniformBuffer
@ RenderToOneDimensionalTexture
@ OneDimensionalTextureMipmaps
@ ReadBackNonBaseMipLevel
@ ThreeDimensionalTextureMipmaps
@ NonFourAlignedEffectiveIndexBufferOffset
@ ThreeDimensionalTextures
@ ReadBackAnyTextureFormat
static const int MAX_MIP_LEVELS
FrameOpResult
Describes the result of operations that can have a soft failure.
@ EnablePipelineCacheDataSave
QByteArray shader() const
QByteArray entryPoint() const
NativeResourceBindingMap nativeResourceBindingMap(const QShaderKey &key) const
Variant
Describes what kind of shader code an entry contains.
@ TessellationEvaluationStage
@ TessellationControlStage
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
constexpr bool isEmpty() const noexcept
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
const ushort * utf16() const
Returns the QString as a '\0\'-terminated array of unsigned shorts.
static QString fromUtf16(const char16_t *, qsizetype size=-1)
const QChar * constData() const
Returns a pointer to the data stored in the QString.
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
qsizetype count(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QByteArray toUtf8() const &
const T & at(qsizetype idx) const
const_iterator cbegin() const noexcept
const_iterator cend() const noexcept
const T * constData() const
iterator begin() noexcept
QSize size() const override
Returns the size of the window excluding any window frame.
QMap< QString, QString > map
[6]
QSet< QString >::iterator it
pD3DCompile resolveD3DCompile()
IDCompositionDevice * createDirectCompositionDevice()
Combined button and popup list for selecting options.
constexpr Initialization Uninitialized
Q_CORE_EXPORT char * qstrncpy(char *dst, const char *src, size_t len)
Q_CORE_EXPORT int qsnprintf(char *str, size_t n, const char *fmt,...)
std::pair< T1, T2 > QPair
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
DBusConnection const char DBusError * error
static QString header(const QString &name)
static const qint64 headerSize
#define qCDebug(category,...)
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qBound(const T &min, const T &val, const T &max)
constexpr const T & qMax(const T &a, const T &b)
static bool contains(const QJsonArray &haystack, unsigned needle)
GLboolean GLboolean GLboolean b
GLsizei const GLfloat * v
[13]
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat z
GLint GLint GLint GLint GLint x
[0]
GLuint const GLuint * buffers
GLint GLenum GLsizei GLsizei GLsizei depth
GLenum GLuint GLint level
GLfloat GLfloat GLfloat w
[0]
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint const GLuint GLuint const GLuint * textures
GLenum GLenum GLsizei count
GLenum GLuint GLenum GLsizei const GLchar * buf
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLuint GLintptr offset
GLint GLsizei GLsizei GLenum format
GLsizei const GLint * box
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLsizei GLchar * source
GLuint GLsizei const GLuint const GLintptr * offsets
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum colorFormat
GLsizeiptr const void GLenum usage
static const int RBM_VERTEX
static QPair< int, int > mapBinding(int binding, int stageIndex, const QShader::NativeResourceBindingMap *nativeResourceBindingMaps[])
static bool output6ForWindow(QWindow *w, IDXGIAdapter1 *adapter, IDXGIOutput6 **result)
static void applyDynamicOffsets(UINT *offsets, int batchIndex, const QRhiBatchedBindings< UINT > *originalBindings, const QRhiBatchedBindings< UINT > *staticOffsets, const uint *dynOfsPairs, int dynOfsPairCount)
static D3D11_TEXTURE_ADDRESS_MODE toD3DAddressMode(QRhiSampler::AddressMode m)
#define SETUAVBATCH(stagePrefixL, stagePrefixU)
static QByteArray sourceHash(const QByteArray &source)
#define SETSAMPLERBATCH(stagePrefixL, stagePrefixU)
static uint toD3DBufferUsage(QRhiBuffer::UsageFlags usage)
static bool outputDesc1ForWindow(QWindow *w, IDXGIAdapter1 *adapter, DXGI_OUTPUT_DESC1 *result)
#define SETUBUFBATCH(stagePrefixL, stagePrefixU)
static const int RBM_DOMAIN
static const DXGI_FORMAT DEFAULT_SRGB_FORMAT
Int aligned(Int v, Int byteAlign)
static DXGI_FORMAT toD3DDepthTextureDSVFormat(QRhiTexture::Format format)
static const DXGI_FORMAT DEFAULT_FORMAT
static D3D11_BLEND toD3DBlendFactor(QRhiGraphicsPipeline::BlendFactor f, bool rgb)
static D3D11_BLEND_OP toD3DBlendOp(QRhiGraphicsPipeline::BlendOp op)
static D3D11_FILTER toD3DFilter(QRhiSampler::Filter minFilter, QRhiSampler::Filter magFilter, QRhiSampler::Filter mipFilter)
static QD3D11RenderTargetData * rtData(QRhiRenderTarget *rt)
static UINT8 toD3DColorWriteMask(QRhiGraphicsPipeline::ColorMask c)
static const int RBM_COMPUTE
static D3D11_STENCIL_OP toD3DStencilOp(QRhiGraphicsPipeline::StencilOp op)
void releasePipelineShader(T &s)
static D3D11_COMPARISON_FUNC toD3DTextureComparisonFunc(QRhiSampler::CompareOp op)
static DXGI_FORMAT toD3DAttributeFormat(QRhiVertexInputAttribute::Format format)
static D3D11_PRIMITIVE_TOPOLOGY toD3DTopology(QRhiGraphicsPipeline::Topology t, int patchControlPointCount)
static const int RBM_HULL
static const int RBM_FRAGMENT
static IDXGIFactory1 * createDXGIFactory2()
static D3D11_FILL_MODE toD3DFillMode(QRhiGraphicsPipeline::PolygonMode mode)
static bool isDepthTextureFormat(QRhiTexture::Format format)
static D3D11_CULL_MODE toD3DCullMode(QRhiGraphicsPipeline::CullMode c)
#define SETSHADER(StageL, StageU)
static DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTexture::Flags flags)
static uint clampedResourceCount(uint startSlot, int countSlots, uint maxSlots, const char *resType)
static const int RBM_SUPPORTED_STAGES
#define D3D11_VS_INPUT_REGISTER_COUNT
#define DXGI_ADAPTER_FLAG_SOFTWARE
\variable QRhiD3D11NativeHandles::dev
static QRhiTexture::Format swapchainReadbackTextureFormat(DXGI_FORMAT format, QRhiTexture::Flags *flags)
static D3D11_COMPARISON_FUNC toD3DCompareOp(QRhiGraphicsPipeline::CompareOp op)
static DXGI_FORMAT toD3DDepthTextureSRVFormat(QRhiTexture::Format format)
static const int RBM_GEOMETRY
SSL_CTX int(* cb)(SSL *ssl, unsigned char **out, unsigned char *outlen, const unsigned char *in, unsigned int inlen, void *arg)
#define qPrintable(string)
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
unsigned long long quint64
QT_BEGIN_NAMESPACE typedef uchar * output
QFileInfo info(fileName)
[8]
view viewport() -> scroll(dx, dy, deviceRect)
bool hasPendingDynamicUpdates
void endFullDynamicBufferUpdateForCurrentFrame() override
To be called when the entire contents of the buffer data has been updated in the memory block returne...
QD3D11Buffer(QRhiImplementation *rhi, Type type, UsageFlags usage, quint32 size)
char * beginFullDynamicBufferUpdateForCurrentFrame() override
bool create() override
Creates the corresponding native graphics resources.
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QHash< quint32, ID3D11UnorderedAccessView * > uavs
QRhiBuffer::NativeBuffer nativeBuffer() override
ID3D11UnorderedAccessView * unorderedAccessView(quint32 offset)
union QD3D11CommandBuffer::Command::Args args
QRhiRenderTarget * currentTarget
static const int MAX_DYNAMIC_OFFSET_COUNT
const uchar * retainBufferData(const QRhiBufferData &data)
ID3D11Buffer * currentVertexBuffers[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]
static const int MAX_VERTEX_BUFFER_BINDING_COUNT
QRhiShaderResourceBindings * currentGraphicsSrb
const uchar * retainImage(const QImage &image)
QD3D11CommandBuffer(QRhiImplementation *rhi)
const uchar * retainData(const QByteArray &data)
QRhiShaderResourceBindings * currentComputeSrb
QRhiBackendCommandList< Command > commands
uint currentPipelineGeneration
quint32 currentIndexOffset
uint currentSrbGeneration
QRhiComputePipeline * currentComputePipeline
ID3D11Buffer * currentIndexBuffer
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
DXGI_FORMAT currentIndexFormat
quint32 currentVertexOffsets[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]
QRhiGraphicsPipeline * currentGraphicsPipeline
QD3D11ComputePipeline(QRhiImplementation *rhi)
QShader::NativeResourceBindingMap nativeResourceBindingMap
struct QD3D11ComputePipeline::@253 cs
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QD3D11GraphicsPipeline(QRhiImplementation *rhi)
ID3D11VertexShader * shader
ID3D11InputLayout * inputLayout
struct QD3D11GraphicsPipeline::@246 vs
ID3D11BlendState * blendState
ID3D11RasterizerState * rastState
D3D11_PRIMITIVE_TOPOLOGY d3dTopology
struct QD3D11GraphicsPipeline::@249 ds
struct QD3D11GraphicsPipeline::@251 fs
~QD3D11GraphicsPipeline()
bool create() override
Creates the corresponding native graphics resources.
struct QD3D11GraphicsPipeline::@250 gs
ID3D11DepthStencilState * dsState
struct QD3D11GraphicsPipeline::@248 hs
QShader::NativeResourceBindingMap nativeResourceBindingMap
QD3D11RenderBuffer(QRhiImplementation *rhi, Type type, const QSize &pixelSize, int sampleCount, QRhiRenderBuffer::Flags flags, QRhiTexture::Format backingFormatHint)
ID3D11RenderTargetView * rtv
ID3D11DepthStencilView * dsv
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
DXGI_SAMPLE_DESC sampleDesc
bool create() override
Creates the corresponding native graphics resources.
QRhiTexture::Format backingFormat() const override
QD3D11RenderPassDescriptor(QRhiImplementation *rhi)
~QD3D11RenderPassDescriptor()
QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor() const override
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
bool isCompatible(const QRhiRenderPassDescriptor *other) const override
QVector< quint32 > serializedFormat() const override
static const int MAX_COLOR_ATTACHMENTS
ID3D11RenderTargetView * rtv[MAX_COLOR_ATTACHMENTS]
ID3D11DepthStencilView * dsv
QD3D11RenderPassDescriptor * rp
QRhiRenderTargetAttachmentTracker::ResIdList currentResIdList
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QD3D11Sampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode, AddressMode u, AddressMode v, AddressMode w)
ID3D11SamplerState * samplerState
BoundStorageBufferData sbuf
BoundUniformBufferData ubuf
BoundSampledTextureData stex
BoundStorageImageData simage
struct QD3D11ShaderResourceBindings::BoundSampledTextureData::@242 d[QRhiShaderResourceBinding::Data::MAX_TEX_SAMPLER_ARRAY_SIZE]
QRhiBatchedBindings< ID3D11SamplerState * > samplers
QRhiBatchedBindings< ID3D11ShaderResourceView * > shaderresources
QRhiBatchedBindings< ID3D11UnorderedAccessView * > uavs
QVarLengthArray< BoundResourceData, 8 > boundResourceData
StageSamplerBatches hsSamplerBatches
StageUavBatches csUavBatches
QVarLengthArray< QRhiShaderResourceBinding, 8 > sortedBindings
StageSamplerBatches gsSamplerBatches
~QD3D11ShaderResourceBindings()
StageUniformBufferBatches dsUniformBufferBatches
StageUniformBufferBatches gsUniformBufferBatches
void updateResources(UpdateFlags flags) override
StageSamplerBatches vsSamplerBatches
StageSamplerBatches fsSamplerBatches
StageUniformBufferBatches fsUniformBufferBatches
StageSamplerBatches dsSamplerBatches
StageSamplerBatches csSamplerBatches
StageUniformBufferBatches csUniformBufferBatches
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QD3D11ShaderResourceBindings(QRhiImplementation *rhi)
StageUniformBufferBatches hsUniformBufferBatches
StageUniformBufferBatches vsUniformBufferBatches
int sampleCount() const override
~QD3D11SwapChainRenderTarget()
QD3D11SwapChainRenderTarget(QRhiImplementation *rhi, QRhiSwapChain *swapchain)
float devicePixelRatio() const override
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
QSize pixelSize() const override
QRhiSwapChainHdrInfo hdrInfo() override
\variable QRhiSwapChainHdrInfo::isHardCodedDefaults
QD3D11Timestamps timestamps
ID3D11RenderTargetView * backBufferRtv
QRhiRenderTarget * currentFrameRenderTarget() override
ID3D11Texture2D * msaaTex[BUFFER_COUNT]
QD3D11SwapChain(QRhiImplementation *rhi)
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
IDCompositionTarget * dcompTarget
ID3D11RenderTargetView * msaaRtv[BUFFER_COUNT]
bool createOrResize() override
Creates the swapchain if not already done and resizes the swapchain buffers to match the current size...
QSize surfacePixelSize() override
bool newColorBuffer(const QSize &size, DXGI_FORMAT format, DXGI_SAMPLE_DESC sampleDesc, ID3D11Texture2D **tex, ID3D11RenderTargetView **rtv) const
static const int BUFFER_COUNT
QD3D11SwapChainRenderTarget rt
bool isFormatSupported(Format f) override
DXGI_SAMPLE_DESC sampleDesc
IDCompositionVisual * dcompVisual
QRhiCommandBuffer * currentFrameCommandBuffer() override
QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor() override
IDXGISwapChain * swapChain
DXGI_FORMAT srgbAdjustedColorFormat
ID3D11Texture2D * backBufferTex
QSize pixelSize() const override
QD3D11TextureRenderTarget(QRhiImplementation *rhi, const QRhiTextureRenderTargetDescription &desc, Flags flags)
ID3D11DepthStencilView * dsv
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
float devicePixelRatio() const override
QRhiRenderPassDescriptor * newCompatibleRenderPassDescriptor() override
int sampleCount() const override
bool ownsRtv[QD3D11RenderTargetData::MAX_COLOR_ATTACHMENTS]
ID3D11RenderTargetView * rtv[QD3D11RenderTargetData::MAX_COLOR_ATTACHMENTS]
bool create() override
Creates the corresponding native graphics resources.
~QD3D11TextureRenderTarget()
bool create() override
Creates the corresponding native graphics resources.
void destroy() override
Releases (or requests deferred releasing of) the underlying native graphics resources.
bool createFrom(NativeTexture src) override
Similar to create(), except that no new native textures are created.
NativeTexture nativeTexture() override
ID3D11UnorderedAccessView * perLevelViews[QRhi::MAX_MIP_LEVELS]
bool prepareCreate(QSize *adjustedSize=nullptr)
QD3D11Texture(QRhiImplementation *rhi, Format format, const QSize &pixelSize, int depth, int arraySize, int sampleCount, Flags flags)
ID3D11UnorderedAccessView * unorderedAccessViewForLevel(int level)
DXGI_SAMPLE_DESC sampleDesc
ID3D11ShaderResourceView * srv
ID3D11Resource * textureResource() const
ID3D11Query * disjointQuery[MAX_TIMESTAMP_PAIRS]
bool active[MAX_TIMESTAMP_PAIRS]
ID3D11Query * query[MAX_TIMESTAMP_PAIRS *2]
bool tryQueryTimestamps(int idx, ID3D11DeviceContext *context, double *elapsedSec)
bool prepare(int pairCount, QRhiD3D11 *rhiD)
static const int MAX_TIMESTAMP_PAIRS
void feed(int binding, T resource)
QVarLengthArray< Batch, 4 > batches
ID3D11Buffer * stagingBuf
QRhiReadbackResult * result
QD3D11CommandBuffer cbWrapper
QD3D11Timestamps timestamps
QRhiReadbackResult * result
QRhiTexture::Format format
QRhiReadbackDescription desc
ID3D11Texture2D * stagingTex
\variable QRhiReadbackResult::completed
QRhiTexture::Format format
std::function< void()> completed
QRhiReadbackResult * result
QRhiTextureCopyDescription desc
QRhiReadbackDescription rb
QVarLengthArray< MipLevelUploadList, 6 > subresDesc
QRhiReadbackResult * result
union QRhiShaderResourceBinding::Data::@328 u
QRhiShaderResourceBinding::Type type
struct QD3D11CommandBuffer::Command::Args::@327 copySubRes
ID3D11Buffer * buffers[MAX_VERTEX_BUFFER_BINDING_COUNT]
struct QD3D11CommandBuffer::Command::Args::@320 bindGraphicsPipeline
QD3D11ShaderResourceBindings * srb
struct QD3D11CommandBuffer::Command::Args::@321 bindShaderResources
struct QD3D11CommandBuffer::Command::Args::@334 bindComputePipeline
struct QD3D11CommandBuffer::Command::Args::@322 stencilRef
struct QD3D11CommandBuffer::Command::Args::@314 clear
ID3D11ShaderResourceView * srv
struct QD3D11CommandBuffer::Command::Args::@333 debugMark
struct QD3D11CommandBuffer::Command::Args::@323 blendConstants
struct QD3D11CommandBuffer::Command::Args::@329 resolveSubRes
struct QD3D11CommandBuffer::Command::Args::@326 updateSubRes
UINT offsets[MAX_VERTEX_BUFFER_BINDING_COUNT]
struct QD3D11CommandBuffer::Command::Args::@325 drawIndexed
uint dynamicOffsetPairs[MAX_DYNAMIC_OFFSET_COUNT *2]
struct QD3D11CommandBuffer::Command::Args::@315 viewport
QD3D11GraphicsPipeline * ps
UINT strides[MAX_VERTEX_BUFFER_BINDING_COUNT]
struct QD3D11CommandBuffer::Command::Args::@332 genMip
struct QD3D11CommandBuffer::Command::Args::@319 bindIndexBuffer
struct QD3D11CommandBuffer::Command::Args::@318 bindVertexBuffers
struct QD3D11CommandBuffer::Command::Args::@324 draw
struct QD3D11CommandBuffer::Command::Args::@312 setRenderTarget
struct QD3D11CommandBuffer::Command::Args::@317 scissor
struct QD3D11CommandBuffer::Command::Args::@335 dispatch