mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-24 16:48:18 -05:00
Cleanup.
This commit is contained in:
parent
ee40695502
commit
2cf7eaaefc
2 changed files with 28 additions and 29 deletions
|
@ -61,7 +61,6 @@
|
|||
|
||||
namespace bgfx
|
||||
{
|
||||
|
||||
extern bool g_verbose;
|
||||
|
||||
class LineReader
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace bgfx
|
|||
typedef HRESULT(WINAPI* PFN_D3D_COMPILE)(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData
|
||||
, _In_ SIZE_T SrcDataSize
|
||||
, _In_opt_ LPCSTR pSourceName
|
||||
, _In_reads_opt_(_Inexpressible_(pDefines->Name != NULL)) CONST D3D_SHADER_MACRO* pDefines
|
||||
, _In_reads_opt_(_Inexpressible_(pDefines->Name != NULL) ) CONST D3D_SHADER_MACRO* pDefines
|
||||
, _In_opt_ ID3DInclude* pInclude
|
||||
, _In_opt_ LPCSTR pEntrypoint
|
||||
, _In_ LPCSTR pTarget
|
||||
|
@ -127,7 +127,7 @@ namespace bgfx
|
|||
{
|
||||
const RemapInputSemantic& ris = s_remapInputSemantic[ii];
|
||||
if (0 == strcmp(ris.m_name, _name)
|
||||
&& ris.m_index == _index)
|
||||
&& ris.m_index == _index)
|
||||
{
|
||||
return ris;
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ namespace bgfx
|
|||
const UniformRemap& remap = s_uniformRemap[ii];
|
||||
|
||||
if (remap.paramClass == constDesc.Class
|
||||
&& remap.paramType == constDesc.Type)
|
||||
&& remap.paramType == constDesc.Type)
|
||||
{
|
||||
if (D3D_SVC_MATRIX_COLUMNS != constDesc.Class)
|
||||
{
|
||||
|
@ -172,7 +172,7 @@ namespace bgfx
|
|||
}
|
||||
|
||||
if (remap.columns == constDesc.Columns
|
||||
&& remap.rows == constDesc.Rows)
|
||||
&& remap.rows == constDesc.Rows)
|
||||
{
|
||||
return remap.id;
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ namespace bgfx
|
|||
// parse the shader blob for the constant table
|
||||
const size_t codeSize = _code->GetBufferSize();
|
||||
const uint32_t* ptr = (const uint32_t*)_code->GetBufferPointer();
|
||||
const uint32_t* end = (const uint32_t*)((const uint8_t*)ptr + codeSize);
|
||||
const uint32_t* end = (const uint32_t*)( (const uint8_t*)ptr + codeSize);
|
||||
const CTHeader* header = NULL;
|
||||
|
||||
ptr++; // first byte is shader type / version; skip it since we already know
|
||||
|
@ -230,7 +230,7 @@ namespace bgfx
|
|||
while (ptr < end && *ptr != D3DSIO_END)
|
||||
{
|
||||
uint32_t cur = *ptr++;
|
||||
if ((cur & D3DSI_OPCODE_MASK) != D3DSIO_COMMENT)
|
||||
if ( (cur & D3DSI_OPCODE_MASK) != D3DSIO_COMMENT)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ namespace bgfx
|
|||
// found the constant table data
|
||||
header = (const CTHeader*)(ptr + 1);
|
||||
uint32_t tableSize = (commentSize - 1) * 4;
|
||||
if (tableSize < sizeof(CTHeader) || header->Size != sizeof(CTHeader))
|
||||
if (tableSize < sizeof(CTHeader) || header->Size != sizeof(CTHeader) )
|
||||
{
|
||||
fprintf(stderr, "Error: Invalid constant table data\n");
|
||||
return false;
|
||||
|
@ -322,7 +322,7 @@ namespace bgfx
|
|||
, IID_ID3D11ShaderReflection
|
||||
, (void**)&reflect
|
||||
);
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr) )
|
||||
{
|
||||
fprintf(stderr, "Error: D3DReflect failed 0x%08x\n", (uint32_t)hr);
|
||||
return false;
|
||||
|
@ -330,7 +330,7 @@ namespace bgfx
|
|||
|
||||
D3D11_SHADER_DESC desc;
|
||||
hr = reflect->GetDesc(&desc);
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr) )
|
||||
{
|
||||
fprintf(stderr, "Error: ID3D11ShaderReflection::GetDesc failed 0x%08x\n", (uint32_t)hr);
|
||||
return false;
|
||||
|
@ -382,7 +382,7 @@ namespace bgfx
|
|||
|
||||
_size = (uint16_t)bufferDesc.Size;
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
if (SUCCEEDED(hr) )
|
||||
{
|
||||
BX_TRACE("%s, %d, vars %d, size %d"
|
||||
, bufferDesc.Name
|
||||
|
@ -397,16 +397,16 @@ namespace bgfx
|
|||
ID3D11ShaderReflectionType* type = var->GetType();
|
||||
D3D11_SHADER_VARIABLE_DESC varDesc;
|
||||
hr = var->GetDesc(&varDesc);
|
||||
if (SUCCEEDED(hr))
|
||||
if (SUCCEEDED(hr) )
|
||||
{
|
||||
D3D11_SHADER_TYPE_DESC constDesc;
|
||||
hr = type->GetDesc(&constDesc);
|
||||
if (SUCCEEDED(hr))
|
||||
if (SUCCEEDED(hr) )
|
||||
{
|
||||
UniformType::Enum uniformType = findUniformType(constDesc);
|
||||
|
||||
if (UniformType::Count != uniformType
|
||||
&& 0 != (varDesc.uFlags & D3D_SVF_USED))
|
||||
&& 0 != (varDesc.uFlags & D3D_SVF_USED) )
|
||||
{
|
||||
Uniform un;
|
||||
un.name = varDesc.Name;
|
||||
|
@ -426,7 +426,7 @@ namespace bgfx
|
|||
}
|
||||
else
|
||||
{
|
||||
if (0 == (varDesc.uFlags & D3D_SVF_USED))
|
||||
if (0 == (varDesc.uFlags & D3D_SVF_USED) )
|
||||
{
|
||||
unusedUniforms.push_back(varDesc.Name);
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ namespace bgfx
|
|||
D3D11_SHADER_INPUT_BIND_DESC bindDesc;
|
||||
|
||||
hr = reflect->GetResourceBindingDesc(ii, &bindDesc);
|
||||
if (SUCCEEDED(hr))
|
||||
if (SUCCEEDED(hr) )
|
||||
{
|
||||
if (D3D_SIT_SAMPLER == bindDesc.Type)
|
||||
{
|
||||
|
@ -460,7 +460,7 @@ namespace bgfx
|
|||
if (NULL != end)
|
||||
{
|
||||
Uniform un;
|
||||
un.name.assign(bindDesc.Name, (end - bindDesc.Name));
|
||||
un.name.assign(bindDesc.Name, (end - bindDesc.Name) );
|
||||
un.type = UniformType::Enum(BGFX_UNIFORM_SAMPLERBIT | UniformType::Int1);
|
||||
un.num = 1;
|
||||
un.regIndex = bindDesc.BindPoint;
|
||||
|
@ -528,7 +528,7 @@ namespace bgfx
|
|||
}
|
||||
|
||||
uint32_t optimization = 3;
|
||||
if (_cmdLine.hasArg(optimization, 'O'))
|
||||
if (_cmdLine.hasArg(optimization, 'O') )
|
||||
{
|
||||
optimization = bx::uint32_min(optimization, BX_COUNTOF(s_optimizationLevelD3D11) - 1);
|
||||
flags |= s_optimizationLevelD3D11[optimization];
|
||||
|
@ -553,7 +553,7 @@ namespace bgfx
|
|||
{
|
||||
hlslfp = _cmdLine.findOption('o');
|
||||
hlslfp += ".hlsl";
|
||||
writeFile(hlslfp.c_str(), _code.c_str(), (int32_t)_code.size());
|
||||
writeFile(hlslfp.c_str(), _code.c_str(), (int32_t)_code.size() );
|
||||
}
|
||||
|
||||
HRESULT hr = D3DCompile(_code.c_str()
|
||||
|
@ -569,7 +569,7 @@ namespace bgfx
|
|||
, &errorMsg
|
||||
);
|
||||
if (FAILED(hr)
|
||||
|| (werror && NULL != errorMsg))
|
||||
|| (werror && NULL != errorMsg) )
|
||||
{
|
||||
const char* log = (char*)errorMsg->GetBufferPointer();
|
||||
|
||||
|
@ -579,7 +579,7 @@ namespace bgfx
|
|||
int32_t end = INT32_MAX;
|
||||
|
||||
if (2 == sscanf(log, "(%u,%u):", &line, &column)
|
||||
&& 0 != line)
|
||||
&& 0 != line)
|
||||
{
|
||||
start = bx::uint32_imax(1, line - 10);
|
||||
end = start + 20;
|
||||
|
@ -598,7 +598,7 @@ namespace bgfx
|
|||
|
||||
if (_d3d == 9)
|
||||
{
|
||||
if (!getReflectionDataD3D9(code, uniforms))
|
||||
if (!getReflectionDataD3D9(code, uniforms) )
|
||||
{
|
||||
fprintf(stderr, "Error: Unable to get D3D9 reflection data.\n");
|
||||
goto error;
|
||||
|
@ -620,8 +620,8 @@ namespace bgfx
|
|||
|
||||
// first time through, we just find unused uniforms and get rid of them
|
||||
std::string output;
|
||||
LineReader reader(_code.c_str());
|
||||
while (!reader.isEof())
|
||||
LineReader reader(_code.c_str() );
|
||||
while (!reader.isEof() )
|
||||
{
|
||||
std::string line = reader.getLine();
|
||||
for (UniformNameList::iterator it = unusedUniforms.begin(), itEnd = unusedUniforms.end(); it != itEnd; ++it)
|
||||
|
@ -637,7 +637,7 @@ namespace bgfx
|
|||
// included in the uniform blob that the application must upload
|
||||
// we can't just remove them, because unused functions might still reference
|
||||
// them and cause a compile error when they're gone
|
||||
if (!!bx::findIdentifierMatch(line.c_str(), it->c_str()))
|
||||
if (!!bx::findIdentifierMatch(line.c_str(), it->c_str() ) )
|
||||
{
|
||||
line = line.replace(index, strLength, "static");
|
||||
unusedUniforms.erase(it);
|
||||
|
@ -689,7 +689,7 @@ namespace bgfx
|
|||
, &stripped
|
||||
);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
if (SUCCEEDED(hr) )
|
||||
{
|
||||
code->Release();
|
||||
code = stripped;
|
||||
|
@ -707,12 +707,12 @@ namespace bgfx
|
|||
if (_d3d > 9)
|
||||
{
|
||||
bx::write(_writer, numAttrs);
|
||||
bx::write(_writer, attrs, numAttrs*sizeof(uint16_t));
|
||||
bx::write(_writer, attrs, numAttrs*sizeof(uint16_t) );
|
||||
|
||||
bx::write(_writer, size);
|
||||
}
|
||||
|
||||
if (_cmdLine.hasArg('\0', "disasm"))
|
||||
if (_cmdLine.hasArg('\0', "disasm") )
|
||||
{
|
||||
ID3DBlob* disasm;
|
||||
D3DDisassemble(code->GetBufferPointer()
|
||||
|
@ -727,7 +727,7 @@ namespace bgfx
|
|||
std::string disasmfp = _cmdLine.findOption('o');
|
||||
disasmfp += ".disasm";
|
||||
|
||||
writeFile(disasmfp.c_str(), disasm->GetBufferPointer(), (uint32_t)disasm->GetBufferSize());
|
||||
writeFile(disasmfp.c_str(), disasm->GetBufferPointer(), (uint32_t)disasm->GetBufferSize() );
|
||||
disasm->Release();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue