summaryrefslogtreecommitdiffstats
path: root/tools/gfx
diff options
context:
space:
mode:
Diffstat (limited to 'tools/gfx')
-rw-r--r--tools/gfx/d3d12/d3d12-device.cpp72
-rw-r--r--tools/gfx/debug-layer/debug-command-encoder.cpp2
2 files changed, 38 insertions, 36 deletions
diff --git a/tools/gfx/d3d12/d3d12-device.cpp b/tools/gfx/d3d12/d3d12-device.cpp
index c1db6c6ba..2d9780b0f 100644
--- a/tools/gfx/d3d12/d3d12-device.cpp
+++ b/tools/gfx/d3d12/d3d12-device.cpp
@@ -33,6 +33,28 @@ using namespace Slang;
static const uint32_t D3D_FEATURE_LEVEL_12_2 = 0xc200;
+struct ShaderModelInfo
+{
+ D3D_SHADER_MODEL shaderModel;
+ SlangCompileTarget compileTarget;
+ const char* profileName;
+};
+static ShaderModelInfo kKnownShaderModels[] = {
+#define SHADER_MODEL_INFO_DXBC(major, minor) {D3D_SHADER_MODEL_##major##_##minor, SLANG_DXBC, "sm_" #major "_" #minor }
+ SHADER_MODEL_INFO_DXBC(5, 1),
+#undef SHADER_MODEL_INFO_DXBC
+#define SHADER_MODEL_INFO_DXIL(major, minor) {(D3D_SHADER_MODEL)0x##major##minor, SLANG_DXIL, "sm_" #major "_" #minor }
+ SHADER_MODEL_INFO_DXIL(6, 0),
+ SHADER_MODEL_INFO_DXIL(6, 1),
+ SHADER_MODEL_INFO_DXIL(6, 2),
+ SHADER_MODEL_INFO_DXIL(6, 3),
+ SHADER_MODEL_INFO_DXIL(6, 4),
+ SHADER_MODEL_INFO_DXIL(6, 5),
+ SHADER_MODEL_INFO_DXIL(6, 6),
+ SHADER_MODEL_INFO_DXIL(6, 7)
+#undef SHADER_MODEL_INFO_DXIL
+};
+
Result DeviceImpl::createBuffer(
const D3D12_RESOURCE_DESC& resourceDesc,
const void* srcData,
@@ -579,7 +601,10 @@ Result DeviceImpl::initialize(const Desc& desc)
}
D3D12_FEATURE_DATA_SHADER_MODEL shaderModelData = {};
- shaderModelData.HighestShaderModel = D3D_SHADER_MODEL_6_6;
+ if (m_extendedDesc.highestShaderModel != 0)
+ shaderModelData.HighestShaderModel = (D3D_SHADER_MODEL)m_extendedDesc.highestShaderModel;
+ else
+ shaderModelData.HighestShaderModel = kKnownShaderModels[SLANG_COUNT_OF(kKnownShaderModels)-1].shaderModel;
// Find what features are supported
{
@@ -744,42 +769,19 @@ Result DeviceImpl::initialize(const Desc& desc)
// Check shader model version.
SlangCompileTarget compileTarget = SLANG_DXBC;
const char* profileName = "sm_5_1";
- switch (shaderModelData.HighestShaderModel)
+ for (auto& sm : kKnownShaderModels)
{
- case D3D_SHADER_MODEL_5_1:
- compileTarget = SLANG_DXBC;
- profileName = "sm_5_1";
- break;
- case D3D_SHADER_MODEL_6_0:
- compileTarget = SLANG_DXIL;
- profileName = "sm_6_0";
- break;
- case D3D_SHADER_MODEL_6_1:
- compileTarget = SLANG_DXIL;
- profileName = "sm_6_1";
- break;
- case D3D_SHADER_MODEL_6_2:
- compileTarget = SLANG_DXIL;
- profileName = "sm_6_2";
- break;
- case D3D_SHADER_MODEL_6_3:
- compileTarget = SLANG_DXIL;
- profileName = "sm_6_3";
- break;
- case D3D_SHADER_MODEL_6_4:
- compileTarget = SLANG_DXIL;
- profileName = "sm_6_4";
- break;
- case D3D_SHADER_MODEL_6_5:
- compileTarget = SLANG_DXIL;
- profileName = "sm_6_5";
- break;
- default:
- compileTarget = SLANG_DXIL;
- profileName = "sm_6_6";
- break;
+ if (sm.shaderModel <= shaderModelData.HighestShaderModel)
+ {
+ m_features.add(sm.profileName);
+ profileName = sm.profileName;
+ compileTarget = sm.compileTarget;
+ }
+ else
+ {
+ break;
+ }
}
- m_features.add(profileName);
// If user specified a higher shader model than what the system supports, return failure.
int userSpecifiedShaderModel = D3DUtil::getShaderModelFromProfileName(desc.slang.targetProfile);
if (userSpecifiedShaderModel > shaderModelData.HighestShaderModel)
diff --git a/tools/gfx/debug-layer/debug-command-encoder.cpp b/tools/gfx/debug-layer/debug-command-encoder.cpp
index b8b005338..64ebd2b46 100644
--- a/tools/gfx/debug-layer/debug-command-encoder.cpp
+++ b/tools/gfx/debug-layer/debug-command-encoder.cpp
@@ -346,7 +346,7 @@ void DebugResourceCommandEncoderImpl::resolveQuery(
IQueryPool* queryPool, GfxIndex index, GfxCount count, IBufferResource* buffer, Offset offset)
{
SLANG_GFX_API_FUNC;
- getBaseResourceEncoder()->resolveQuery(getInnerObj(queryPool), index, count, buffer, offset);
+ getBaseResourceEncoder()->resolveQuery(getInnerObj(queryPool), index, count, getInnerObj(buffer), offset);
}
void DebugResourceCommandEncoderImpl::copyTextureToBuffer(