@@ -13,8 +13,6 @@ template <typename T>
1313static HRESULT create_shader (LPCSTR const pTarget, DWORD const * buffer, u32 const buffer_size, LPCSTR const file_name,
1414 T*& result, bool const disasm)
1515{
16- // XXX: disasm it
17-
1816 result->sh = ShaderTypeTraits<T>::CreateHWShader (buffer, buffer_size);
1917
2018 ID3DShaderReflection* pReflection = 0 ;
@@ -38,72 +36,48 @@ static HRESULT create_shader(LPCSTR const pTarget, DWORD const* buffer, u32 cons
3836static HRESULT create_shader (LPCSTR const pTarget, DWORD const * buffer, u32 const buffer_size, LPCSTR const file_name,
3937 void *& result, bool const disasm)
4038{
41- // XXX: what's going on with casts here???
4239 HRESULT _result = E_FAIL;
40+ pcstr extension = " .hlsl" ;
4341 if (pTarget[0 ] == ' p' )
4442 {
43+ extension = " .ps" ;
4544 _result = create_shader (pTarget, buffer, buffer_size, file_name, (SPS*&)result, disasm);
4645 }
4746 else if (pTarget[0 ] == ' v' )
4847 {
49- // XXX: try to use code below
50- // _result = create_shader(pTarget, buffer, buffer_size, file_name, (SVS*&)result, disasm);
51-
48+ extension = " .vs" ;
5249 SVS* svs_result = (SVS*)result;
53- _result = HW.pDevice ->CreateVertexShader (buffer, buffer_size, 0 , &svs_result->sh );
54-
55- if (!SUCCEEDED (_result))
56- {
57- Log (" ! VS: " , file_name);
58- Msg (" ! CreatePixelShader hr == 0x%08x" , _result);
59- return E_FAIL;
60- }
61-
62- ID3DShaderReflection* pReflection = 0 ;
63- _result = D3DReflect (buffer, buffer_size, IID_ID3DShaderReflection, (void **)&pReflection);
64-
65- // Parse constant, texture, sampler binding
66- // Store input signature blob
67- if (SUCCEEDED (_result) && pReflection)
50+ _result = create_shader (pTarget, buffer, buffer_size, file_name, svs_result, disasm);
51+ if (SUCCEEDED (_result))
6852 {
69- // TODO: DX10: share the same input signatures
70-
7153 // Store input signature (need only for VS)
72- // CHK_DX( D3DxxGetInputSignatureBlob(pShaderBuf->GetBufferPointer(), pShaderBuf->GetBufferSize(),
73- // &_vs->signature) );
7454 ID3DBlob* pSignatureBlob;
7555 CHK_DX (D3DGetInputSignatureBlob (buffer, buffer_size, &pSignatureBlob));
7656 VERIFY (pSignatureBlob);
7757
7858 svs_result->signature = RImplementation.Resources ->_CreateInputSignature (pSignatureBlob);
7959
8060 _RELEASE (pSignatureBlob);
81-
82- // Let constant table parse it's data
83- svs_result->constants .parse (pReflection, RC_dest_vertex);
84-
85- _RELEASE (pReflection);
86- }
87- else
88- {
89- Log (" ! VS: " , file_name);
90- Msg (" ! D3DXFindShaderComment hr == 0x%08x" , _result);
9161 }
9262 }
9363 else if (pTarget[0 ] == ' g' )
9464 {
65+ extension = " .gs" ;
9566 _result = create_shader (pTarget, buffer, buffer_size, file_name, (SGS*&)result, disasm);
9667 }
9768 else if (pTarget[0 ] == ' c' )
9869 {
70+ extension = " .cs" ;
9971 _result = create_shader (pTarget, buffer, buffer_size, file_name, (SCS*&)result, disasm);
10072 }
10173 else if (pTarget[0 ] == ' h' )
10274 {
75+ extension = " .hs" ;
10376 _result = create_shader (pTarget, buffer, buffer_size, file_name, (SHS*&)result, disasm);
10477 }
10578 else if (pTarget[0 ] == ' d' )
10679 {
80+ extension = " .ds" ;
10781 _result = create_shader (pTarget, buffer, buffer_size, file_name, (SDS*&)result, disasm);
10882 }
10983 else
@@ -115,10 +89,8 @@ static HRESULT create_shader(LPCSTR const pTarget, DWORD const* buffer, u32 cons
11589 {
11690 ID3DBlob* disasm = 0 ;
11791 D3DDisassemble (buffer, buffer_size, FALSE , 0 , &disasm);
118- // D3DXDisassembleShader (LPDWORD(code->GetBufferPointer()), FALSE, 0, &disasm );
11992 string_path dname;
120- strconcat (sizeof (dname), dname, " disasm" DELIMITER, file_name,
121- (' v' == pTarget[0 ]) ? " .vs" : (' p' == pTarget[0 ]) ? " .ps" : " .gs" );
93+ strconcat (sizeof (dname), dname, " disasm" DELIMITER, file_name, extension);
12294 IWriter* W = FS.w_open (" $logs$" , dname);
12395 W->w (disasm->GetBufferPointer (), (u32 )disasm->GetBufferSize ());
12496 FS.w_close (W);
0 commit comments