Skip to content

Commit

Permalink
Reduce differences between files.
Browse files Browse the repository at this point in the history
  • Loading branch information
intorr committed Jan 8, 2018
1 parent 08a3d68 commit 4a92877
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 73 deletions.
36 changes: 16 additions & 20 deletions src/Layers/xrRenderPC_R3/r3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,9 @@ void CRender::create()

rmNormal();
marker = 0;
D3D10_QUERY_DESC qdesc;
D3D_QUERY_DESC qdesc;
qdesc.MiscFlags = 0;
qdesc.Query = D3D10_QUERY_EVENT;
qdesc.Query = D3D_QUERY_EVENT;
ZeroMemory(q_sync_point, sizeof(q_sync_point));
// R_CHK (HW.pDevice->CreateQuery(&qdesc,&q_sync_point[0]));
// R_CHK (HW.pDevice->CreateQuery(&qdesc,&q_sync_point[1]));
Expand Down Expand Up @@ -500,9 +500,9 @@ void CRender::reset_begin()

void CRender::reset_end()
{
D3D10_QUERY_DESC qdesc;
D3D_QUERY_DESC qdesc;
qdesc.MiscFlags = 0;
qdesc.Query = D3D10_QUERY_EVENT;
qdesc.Query = D3D_QUERY_EVENT;
// R_CHK (HW.pDevice->CreateQuery(&qdesc,&q_sync_point[0]));
// R_CHK (HW.pDevice->CreateQuery(&qdesc,&q_sync_point[1]));
for (u32 i = 0; i < HW.Caps.iGPUNum; ++i)
Expand Down Expand Up @@ -767,20 +767,7 @@ void CRender::DumpStatistics(IGameFont& font, IPerformanceAlert* alert)
Sectors_xrc.DumpStatistics(font, alert);
}

static inline bool match_shader_id(
LPCSTR const debug_shader_id, LPCSTR const full_shader_id, FS_FileSet const& file_set, string_path& result);

/////////
#pragma comment(lib, "d3dx9.lib")
/*
extern "C"
{
LPCSTR WINAPI D3DXGetPixelShaderProfile (LPDIRECT3DDEVICE9 pDevice);
LPCSTR WINAPI D3DXGetVertexShaderProfile (LPDIRECT3DDEVICE9 pDevice);
};
*/
static HRESULT create_shader(LPCSTR const pTarget, DWORD const* buffer, u32 const buffer_size, LPCSTR const file_name,
void*& result, bool const disasm)
static HRESULT create_shader(LPCSTR const pTarget, DWORD const* buffer, u32 const buffer_size, LPCSTR const file_name, void*& result, bool const disasm)
{
HRESULT _result = E_FAIL;
if (pTarget[0] == 'p')
Expand Down Expand Up @@ -910,6 +897,10 @@ static HRESULT create_shader(LPCSTR const pTarget, DWORD const* buffer, u32 cons
Msg("! D3DReflectShader hr == 0x%08x", _result);
}
}
else
{
NODEFAULT;
}

if (disasm)
{
Expand Down Expand Up @@ -964,6 +955,9 @@ class includer : public ID3DInclude
}
};

static inline bool match_shader_id(
LPCSTR const debug_shader_id, LPCSTR const full_shader_id, FS_FileSet const& file_set, string_path& result);

HRESULT CRender::shader_compile(LPCSTR name, DWORD const* pSrcData, UINT SrcDataLen, LPCSTR pFunctionName,
LPCSTR pTarget, DWORD Flags, void*& result)
{
Expand Down Expand Up @@ -1351,15 +1345,17 @@ HRESULT CRender::shader_compile(LPCSTR name, DWORD const* pSrcData, UINT SrcData
sh_name[len] = '0' + char(o.dx10_minmax_sm != 0);
++len;

// Be carefull!!!!! this should be at the end to correctly generate
// compiled shader name;
// add a #define for DX10_1 MSAA support
if (o.dx10_msaa)
{
static char samples[2];

defines[def_it].Name = "USE_MSAA";
defines[def_it].Definition = "1";
def_it++;

static char samples[2];

defines[def_it].Name = "MSAA_SAMPLES";
samples[0] = char(o.dx10_msaa_samples) + '0';
samples[1] = 0;
Expand Down
59 changes: 6 additions & 53 deletions src/Layers/xrRenderPC_R4/r4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,16 +779,6 @@ void CRender::DumpStatistics(IGameFont& font, IPerformanceAlert* alert)
Sectors_xrc.DumpStatistics(font, alert);
}

/////////
#pragma comment(lib, "d3dx9.lib")
/*
extern "C"
{
LPCSTR WINAPI D3DXGetPixelShaderProfile (LPDIRECT3DDEVICE9 pDevice);
LPCSTR WINAPI D3DXGetVertexShaderProfile (LPDIRECT3DDEVICE9 pDevice);
};
*/

void CRender::addShaderOption(const char* name, const char* value)
{
D3D_SHADER_MACRO macro = {name, value};
Expand All @@ -803,7 +793,7 @@ static HRESULT create_shader(LPCSTR const pTarget, DWORD const* buffer, u32 cons

ID3DShaderReflection* pReflection = 0;

HRESULT const _hr = D3DReflect(buffer, buffer_size, IID_ID3D11ShaderReflection, (void**)&pReflection);
HRESULT const _hr = D3DReflect(buffer, buffer_size, IID_ID3DShaderReflection, (void**)&pReflection);
if (SUCCEEDED(_hr) && pReflection)
{
// Parse constant table data
Expand All @@ -819,8 +809,7 @@ static HRESULT create_shader(LPCSTR const pTarget, DWORD const* buffer, u32 cons
return _hr;
}

static HRESULT create_shader(LPCSTR const pTarget, DWORD const* buffer, u32 const buffer_size, LPCSTR const file_name,
void*& result, bool const disasm)
static HRESULT create_shader(LPCSTR const pTarget, DWORD const* buffer, u32 const buffer_size, LPCSTR const file_name, void*& result, bool const disasm)
{
HRESULT _result = E_FAIL;
if (pTarget[0] == 'p')
Expand All @@ -841,7 +830,7 @@ static HRESULT create_shader(LPCSTR const pTarget, DWORD const* buffer, u32 cons
ID3DShaderReflection* pReflection = 0;

#ifdef USE_DX11
_result = D3DReflect(buffer, buffer_size, IID_ID3D11ShaderReflection, (void**)&pReflection);
_result = D3DReflect(buffer, buffer_size, IID_ID3DShaderReflection, (void**)&pReflection);
#else
_result = D3D10ReflectShader(buffer, buffer_size, &pReflection);
#endif
Expand Down Expand Up @@ -879,7 +868,7 @@ static HRESULT create_shader(LPCSTR const pTarget, DWORD const* buffer, u32 cons

ID3DShaderReflection* pReflection = 0;
#ifdef USE_DX11
_result = D3DReflect(buffer, buffer_size, IID_ID3D11ShaderReflection, (void**)&pReflection);
_result = D3DReflect(buffer, buffer_size, IID_ID3DShaderReflection, (void**)&pReflection);
#else
_result = D3D10ReflectShader(buffer, buffer_size, &pReflection);
#endif
Expand Down Expand Up @@ -930,7 +919,7 @@ static HRESULT create_shader(LPCSTR const pTarget, DWORD const* buffer, u32 cons
ID3DShaderReflection* pReflection = 0;

#ifdef USE_DX11
_result = D3DReflect(buffer, buffer_size, IID_ID3D11ShaderReflection, (void**)&pReflection);
_result = D3DReflect(buffer, buffer_size, IID_ID3DShaderReflection, (void**)&pReflection);
#else
_result = D3D10ReflectShader(buffer, buffer_size, &pReflection);
#endif
Expand All @@ -950,42 +939,6 @@ static HRESULT create_shader(LPCSTR const pTarget, DWORD const* buffer, u32 cons
Msg("! D3DReflectShader hr == 0x%08x", _result);
}
}
// else if (pTarget[0] == 'c') {
// SCS* scs_result = (SCS*)result;
//#ifdef USE_DX11
// _result = HW.pDevice->CreateComputeShader(buffer, buffer_size, 0, &scs_result->sh);
//#else // #ifdef USE_DX11
// _result = HW.pDevice->CreateComputeShader(buffer, buffer_size, &scs_result->sh);
//#endif // #ifdef USE_DX11
// if ( !SUCCEEDED(_result) ) {
// Log ("! CS: ", file_name);
// Msg ("! CreateComputeShaderhr == 0x%08x", _result);
// return E_FAIL;
// }
//
// ID3DShaderReflection *pReflection = 0;
//
//#ifdef USE_DX11
// _result = D3DReflect( buffer, buffer_size, IID_ID3DShaderReflection, (void**)&pReflection);
//#else
// _result = D3D10ReflectShader( buffer, buffer_size, &pReflection);
//#endif
//
// // Parse constant, texture, sampler binding
// // Store input signature blob
// if (SUCCEEDED(_result) && pReflection)
// {
// // Let constant table parse it's data
// scs_result->constants.parse(pReflection,RC_dest_pixel);
//
// _RELEASE(pReflection);
// }
// else
// {
// Log ("! PS: ", file_name);
// Msg ("! D3DReflectShader hr == 0x%08x", _result);
// }
// }
else if (pTarget[0] == 'c')
{
_result = create_shader(pTarget, buffer, buffer_size, file_name, (SCS*&)result, disasm);
Expand Down Expand Up @@ -1576,7 +1529,7 @@ HRESULT CRender::shader_compile(LPCSTR name, DWORD const* pSrcData, UINT SrcData
++len;
}

sh_name[len] = 0;
sh_name[len] = '\0';

// finish
defines[def_it].Name = 0;
Expand Down

0 comments on commit 4a92877

Please sign in to comment.