| 412 | } |
| 413 | |
| 414 | BufferHandle DeviceWrapper::createBuffer(const BufferDesc& d) |
| 415 | { |
| 416 | BufferDesc patchedDesc = d; |
| 417 | if (patchedDesc.debugName.empty()) |
| 418 | patchedDesc.debugName = utils::GenerateBufferDebugName(patchedDesc); |
| 419 | |
| 420 | if (d.isVolatile && !d.isConstantBuffer) |
| 421 | { |
| 422 | std::stringstream ss; |
| 423 | ss << "Buffer " << patchedDesc.debugName << " is volatile but is not a constant buffer. Only constant buffers can be made volatile."; |
| 424 | error(ss.str()); |
| 425 | return nullptr; |
| 426 | } |
| 427 | |
| 428 | if (d.isVolatile && d.maxVersions == 0) |
| 429 | { |
| 430 | std::stringstream ss; |
| 431 | ss << "Volatile constant buffer " << patchedDesc.debugName << " has maxVersions = 0"; |
| 432 | error(ss.str()); |
| 433 | return nullptr; |
| 434 | } |
| 435 | |
| 436 | if (d.isVolatile && (d.isVertexBuffer || d.isIndexBuffer || d.isDrawIndirectArgs || d.canHaveUAVs || d.isAccelStructBuildInput || d.isAccelStructStorage || d.isShaderBindingTable || d.isVirtual)) |
| 437 | { |
| 438 | std::stringstream ss; |
| 439 | ss << "Buffer " << patchedDesc.debugName << " is volatile but has unsupported usage flags:"; |
| 440 | if (d.isVertexBuffer) ss << " IsVertexBuffer"; |
| 441 | if (d.isIndexBuffer) ss << " IsIndexBuffer"; |
| 442 | if (d.isDrawIndirectArgs) ss << " IsDrawIndirectArgs"; |
| 443 | if (d.canHaveUAVs) ss << " CanHaveUAVs"; |
| 444 | if (d.isAccelStructBuildInput) ss << " IsAccelStructBuildInput"; |
| 445 | if (d.isAccelStructStorage) ss << " IsAccelStructStorage"; |
| 446 | if (d.isShaderBindingTable) ss << " IsShaderBindingTable"; |
| 447 | if (d.isVirtual) ss << " IsVirtual"; |
| 448 | ss << "." << std::endl << "Only constant buffers can be made volatile, and volatile buffers cannot be virtual."; |
| 449 | error(ss.str()); |
| 450 | return nullptr; |
| 451 | } |
| 452 | |
| 453 | if (d.isVolatile && d.cpuAccess != CpuAccessMode::None) |
| 454 | { |
| 455 | std::stringstream ss; |
| 456 | ss << "Volatile constant buffer " << patchedDesc.debugName << " must have cpuAccess set to None. Write-discard access is implied."; |
| 457 | error(ss.str()); |
| 458 | return nullptr; |
| 459 | } |
| 460 | |
| 461 | if (d.isVirtual && !m_Device->queryFeatureSupport(Feature::VirtualResources)) |
| 462 | { |
| 463 | error("The device does not support virtual resources"); |
| 464 | return nullptr; |
| 465 | } |
| 466 | |
| 467 | if (d.keepInitialState && d.initialState == ResourceStates::Unknown) |
| 468 | { |
| 469 | std::stringstream ss; |
| 470 | ss << "Buffer " << patchedDesc.debugName << " has initialState = Unknown, which is incompatible with keepInitialState = true."; |
| 471 | error(ss.str()); |
nothing calls this directly
no test coverage detected