D3D12: Skip patching DXBC with Aon9 chunk.

This commit is contained in:
Branimir Karadžić 2016-03-09 21:33:20 -08:00
parent f3e4d83540
commit 3afc13e521
7 changed files with 79 additions and 28 deletions

View File

@ -747,10 +747,10 @@ namespace bgfx { namespace d3d11
#if USE_D3D11_DYNAMIC_LIB
m_d3d11dll = bx::dlopen("d3d11.dll");
BX_WARN(NULL != m_d3d11dll, "Failed to load d3d11.dll.");
if (NULL == m_d3d11dll)
{
BX_TRACE("Failed to load d3d11.dll.");
goto error;
}
@ -777,25 +777,25 @@ namespace bgfx { namespace d3d11
}
D3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE)bx::dlsym(m_d3d11dll, "D3D11CreateDevice");
BX_WARN(NULL != D3D11CreateDevice, "Function D3D11CreateDevice not found.");
if (NULL == D3D11CreateDevice)
{
BX_TRACE("Function D3D11CreateDevice not found.");
goto error;
}
m_dxgidll = bx::dlopen("dxgi.dll");
BX_WARN(NULL != m_dxgidll, "Failed to load dxgi.dll.");
if (NULL == m_dxgidll)
{
BX_TRACE("Failed to load dxgi.dll.");
goto error;
}
errorState = ErrorState::LoadedDXGI;
CreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY)bx::dlsym(m_dxgidll, "CreateDXGIFactory");
BX_WARN(NULL != CreateDXGIFactory, "Function CreateDXGIFactory not found.");
if (NULL == CreateDXGIFactory)
{
BX_TRACE("Function CreateDXGIFactory not found.");
goto error;
}
@ -828,9 +828,9 @@ namespace bgfx { namespace d3d11
hr = S_OK;
factory = NULL;
#endif // BX_PLATFORM_*
BX_WARN(SUCCEEDED(hr), "Unable to create DXGI factory.");
if (FAILED(hr) )
{
BX_TRACE("Unable to create DXGI factory.");
goto error;
}
@ -910,8 +910,10 @@ namespace bgfx { namespace d3d11
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0,
#if BX_PLATFORM_WINRT
D3D_FEATURE_LEVEL_9_3,
D3D_FEATURE_LEVEL_9_2,
#endif // BX_PLATFORM_WINRT
};
for (;;)
@ -965,10 +967,10 @@ namespace bgfx { namespace d3d11
break;
}
BX_WARN(SUCCEEDED(hr), "Unable to create Direct3D11 device.");
if (FAILED(hr) )
{
BX_TRACE("Unable to create Direct3D11 device.");
goto error;
}
@ -980,10 +982,10 @@ namespace bgfx { namespace d3d11
else
{
m_device->GetImmediateContext(&m_deviceCtx);
BX_WARN(NULL != m_deviceCtx, "Unable to create Direct3D11 device.");
if (NULL == m_deviceCtx)
{
BX_TRACE("Unable to create Direct3D11 device.");
goto error;
}
}
@ -1020,9 +1022,9 @@ BX_PRAGMA_DIAGNOSTIC_POP();
}
}
BX_WARN(SUCCEEDED(hr), "Unable to create Direct3D11 device.");
if (FAILED(hr) )
{
BX_TRACE("Unable to create Direct3D11 device.");
goto error;
}
@ -1045,9 +1047,9 @@ BX_PRAGMA_DIAGNOSTIC_POP();
}
hr = adapter->GetDesc(&m_adapterDesc);
BX_WARN(SUCCEEDED(hr), "Unable to create Direct3D11 device.");
if (FAILED(hr) )
{
BX_TRACE("Unable to create Direct3D11 device.");
DX_RELEASE(adapter, 2);
goto error;
}
@ -1062,10 +1064,10 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{
#if !BX_PLATFORM_WINDOWS
hr = adapter->GetParent(__uuidof(IDXGIFactory2), (void**)&m_factory);
BX_WARN(SUCCEEDED(hr), "Unable to create Direct3D11 device.");
DX_RELEASE(adapter, 2);
if (FAILED(hr) )
{
BX_TRACE("Unable to create Direct3D11 device.");
goto error;
}
@ -1122,10 +1124,10 @@ BX_PRAGMA_DIAGNOSTIC_POP();
}
#else
hr = adapter->GetParent(IID_IDXGIFactory, (void**)&m_factory);
BX_WARN(SUCCEEDED(hr), "Unable to create Direct3D11 device.");
DX_RELEASE(adapter, 2);
if (FAILED(hr) )
{
BX_TRACE("Unable to create Direct3D11 device.");
goto error;
}
@ -1152,9 +1154,9 @@ BX_PRAGMA_DIAGNOSTIC_POP();
| DXGI_MWA_NO_ALT_ENTER
) );
#endif // BX_PLATFORM_*
BX_WARN(SUCCEEDED(hr), "Failed to create swap chain.");
if (FAILED(hr) )
{
BX_TRACE("Failed to create swap chain.");
goto error;
}
}
@ -1867,9 +1869,9 @@ BX_PRAGMA_DIAGNOSTIC_POP();
void saveScreenShot(const char* _filePath) BX_OVERRIDE
{
BX_WARN(NULL != m_swapChain, "Unable to capture screenshot %s.", _filePath);
if (NULL == m_swapChain)
{
BX_TRACE("Unable to capture screenshot %s.", _filePath);
return;
}
@ -5722,8 +5724,10 @@ BX_PRAGMA_DIAGNOSTIC_POP();
tvm.clear();
uint16_t pos = 0;
tvm.printf(0, pos++, BGFX_CONFIG_DEBUG ? 0x89 : 0x8f
, " %s / " BX_COMPILER_NAME " / " BX_CPU_NAME " / " BX_ARCH_NAME " / " BX_PLATFORM_NAME " "
, " %s (FL %d.%d) / " BX_COMPILER_NAME " / " BX_CPU_NAME " / " BX_ARCH_NAME " / " BX_PLATFORM_NAME " "
, getRendererName()
, (m_featureLevel >> 12) & 0xf
, (m_featureLevel >> 8) & 0xf
);
const DXGI_ADAPTER_DESC& desc = m_adapterDesc;

View File

@ -457,7 +457,11 @@ namespace bgfx { namespace d3d12
struct RendererContextD3D12 : public RendererContextI
{
RendererContextD3D12()
: m_wireframe(false)
: m_d3d12dll(NULL)
, m_dxgidll(NULL)
, m_renderdocdll(NULL)
, m_featureLevel(D3D_FEATURE_LEVEL(0) )
, m_wireframe(false)
, m_maxAnisotropy(1)
, m_depthClamp(false)
, m_fsChanges(0)
@ -660,12 +664,13 @@ namespace bgfx { namespace d3d12
, (featureLevel[ii] >> 12) & 0xf
, (featureLevel[ii] >> 8) & 0xf
);
m_featureLevel = featureLevel[ii];
}
BX_WARN(SUCCEEDED(hr), "Unable to create Direct3D12 device.");
}
if (FAILED(hr) )
{
BX_TRACE("Unable to create Direct3D12 device.");
goto error;
}
@ -2261,8 +2266,9 @@ data.NumQualityLevels = 0;
bx::Error err;
read(&rd, dxbc, &err);
bool patchShader = true;
if (BX_ENABLED(BGFX_CONFIG_DEBUG) )
bool patchShader = !dxbc.shader.aon9;
if (BX_ENABLED(BGFX_CONFIG_DEBUG)
&& patchShader)
{
union { uint32_t offset; void* ptr; } cast = { 0 };
filter(dxbc.shader, dxbc.shader, patchCb0, cast.ptr);
@ -2307,6 +2313,11 @@ data.NumQualityLevels = 0;
desc.PS.pShaderBytecode = temp->data;
desc.PS.BytecodeLength = temp->size;
}
else
{
desc.PS.pShaderBytecode = program.m_fsh->m_code->data;
desc.PS.BytecodeLength = program.m_fsh->m_code->size;
}
desc.DS.pShaderBytecode = NULL;
desc.DS.BytecodeLength = 0;
@ -2643,6 +2654,9 @@ data.NumQualityLevels = 0;
void* m_kernel32dll;
void* m_d3d12dll;
void* m_dxgidll;
void* m_renderdocdll;
D3D_FEATURE_LEVEL m_featureLevel;
D3D_DRIVER_TYPE m_driverType;
DXGI_ADAPTER_DESC m_adapterDesc;
@ -5273,8 +5287,10 @@ data.NumQualityLevels = 0;
tvm.clear();
uint16_t pos = 0;
tvm.printf(0, pos++, BGFX_CONFIG_DEBUG ? 0x89 : 0x8f
, " %s / " BX_COMPILER_NAME " / " BX_CPU_NAME " / " BX_ARCH_NAME " / " BX_PLATFORM_NAME " "
, " %s (FL %d.%d) / " BX_COMPILER_NAME " / " BX_CPU_NAME " / " BX_ARCH_NAME " / " BX_PLATFORM_NAME " "
, getRendererName()
, (m_featureLevel >> 12) & 0xf
, (m_featureLevel >> 8) & 0xf
);
const DXGI_ADAPTER_DESC& desc = m_adapterDesc;

View File

@ -741,7 +741,7 @@ namespace bgfx
_fn(instruction, _userData);
write(&writer, instruction);
write(&writer, instruction, _err);
token += instruction.length;
}

View File

@ -187,6 +187,8 @@ namespace bgfx
struct Dx9bcSubOperand
{
Dx9bcSubOperand() { /* not pod */ }
Dx9bcOperandType::Enum type;
uint32_t regIndex;
uint8_t swizzleBits;
@ -194,6 +196,8 @@ namespace bgfx
struct Dx9bcOperand
{
Dx9bcOperand() { /* not pod */ }
Dx9bcOperandType::Enum type;
uint32_t regIndex;
@ -214,6 +218,8 @@ namespace bgfx
struct Dx9bcInstruction
{
Dx9bcInstruction() { /* not pod */ }
Dx9bcOpcode::Enum opcode;
uint16_t length;
uint8_t numOperands;
@ -232,6 +238,8 @@ namespace bgfx
struct Dx9bcShader
{
Dx9bcShader() { /* not pod */ }
stl::vector<uint8_t> byteCode;
};
@ -240,6 +248,8 @@ namespace bgfx
struct Dx9bc
{
Dx9bc() { /* not pod */ }
uint32_t version;
Dx9bcShader shader;
};

View File

@ -790,7 +790,7 @@ namespace bgfx
case DxbcOperandAddrMode::Reg:
{
DxbcSubOperand subOperand;
size += read(_reader, subOperand);
size += read(_reader, subOperand, _err);
}
break;
@ -799,7 +799,7 @@ namespace bgfx
size += bx::read(_reader, _subOperand.regIndex, _err);
DxbcSubOperand subOperand;
size += read(_reader, subOperand);
size += read(_reader, subOperand, _err);
}
break;
@ -809,7 +809,7 @@ namespace bgfx
size += bx::read(_reader, _subOperand.regIndex, _err);
DxbcSubOperand subOperand;
size += read(_reader, subOperand);
size += read(_reader, subOperand, _err);
}
break;
@ -843,7 +843,7 @@ namespace bgfx
case DxbcOperandAddrMode::Reg:
{
DxbcSubOperand subOperand;
size += write(_writer, subOperand);
size += write(_writer, subOperand, _err);
}
break;
@ -852,7 +852,7 @@ namespace bgfx
size += bx::write(_writer, _subOperand.regIndex, _err);
DxbcSubOperand subOperand;
size += write(_writer, subOperand);
size += write(_writer, subOperand, _err);
}
break;
@ -862,7 +862,7 @@ namespace bgfx
size += bx::write(_writer, _subOperand.regIndex, _err);
DxbcSubOperand subOperand;
size += write(_writer, subOperand);
size += write(_writer, subOperand, _err);
}
break;
@ -1747,6 +1747,7 @@ namespace bgfx
int32_t size = 0;
size += bx::read(_reader, _dxbc.header, _err);
_dxbc.shader.shex = false;
_dxbc.shader.aon9 = false;
for (uint32_t ii = 0; ii < _dxbc.header.numChunks; ++ii)
{
@ -1785,6 +1786,9 @@ namespace bgfx
break;
case BX_MAKEFOURCC('A', 'o', 'n', '9'): // Contains DX9BC for feature level 9.x (*s_4_0_level_9_*) shaders.
_dxbc.shader.aon9 = true;
break;
case BX_MAKEFOURCC('I', 'F', 'C', 'E'): // Interface.
case BX_MAKEFOURCC('R', 'D', 'E', 'F'): // Resource definition.
case BX_MAKEFOURCC('S', 'D', 'G', 'B'): // Shader debugging info (old).

View File

@ -448,6 +448,8 @@ namespace bgfx
struct DxbcSubOperand
{
DxbcSubOperand() { /* not pod */ }
DxbcOperandType::Enum type;
uint8_t mode;
uint8_t modeBits;
@ -459,6 +461,8 @@ namespace bgfx
struct DxbcOperand
{
DxbcOperand() { /* not pod */ }
DxbcOperandType::Enum type;
DxbcOperandMode::Enum mode;
uint8_t modeBits;
@ -480,6 +484,8 @@ namespace bgfx
struct DxbcInstruction
{
DxbcInstruction() { /* not pod */ }
struct ExtendedType
{
enum Enum
@ -546,6 +552,8 @@ namespace bgfx
struct DxbcSignature
{
DxbcSignature() { /* not pod */ }
struct Element
{
stl::string name;
@ -570,6 +578,7 @@ namespace bgfx
uint32_t version;
stl::vector<uint8_t> byteCode;
bool shex;
bool aon9;
};
int32_t read(bx::ReaderSeekerI* _reader, DxbcShader& _shader, bx::Error* _err);

View File

@ -524,6 +524,8 @@ namespace bgfx
struct SpvOperand
{
SpvOperand() { /* not pod */ }
enum Enum
{
AccessQualifier,
@ -575,6 +577,8 @@ namespace bgfx
struct SpvInstruction
{
SpvInstruction() { /* not pod */ }
SpvOpcode::Enum opcode;
uint16_t length;
uint16_t numOperands;
@ -593,6 +597,8 @@ namespace bgfx
struct SpvShader
{
SpvShader() { /* not pod */ }
stl::vector<uint8_t> byteCode;
};
@ -607,6 +613,8 @@ namespace bgfx
struct SpirV
{
SpirV() { /* not pod */ }
struct Header
{
uint32_t magic;