This commit is contained in:
Branimir Karadžić 2016-10-01 12:38:41 -07:00
parent 15349a45a9
commit e5b9b8d7aa
6 changed files with 55 additions and 31 deletions

View File

@ -58,6 +58,7 @@ Languages:
* [Go language API bindings](https://github.com/james4k/go-bgfx)
* [Haskell language API bindings](https://github.com/haskell-game/bgfx)
* [Java language API bindings](https://github.com/enleeten/twilight-bgfx)
* [Lightweight Java Game Library 3 bindings](https://github.com/LWJGL/lwjgl3)
* [Lua language API bindings](https://github.com/excessive/lua-bgfx)
* [Nim language API bindings](https://github.com/Halsys/nim-bgfx)
* [Python language API bindings](https://github.com/jnadro/pybgfx#pybgf)

View File

@ -15,14 +15,14 @@ ifndef TARGET
.PHONY: all
all:
@echo Usage: make TARGET=# [clean, all, rebuild]
@echo " TARGET=0 (hlsl - dx9)"
@echo " TARGET=1 (hlsl - dx11)"
@echo " TARGET=0 (hlsl - d3d9)"
@echo " TARGET=1 (hlsl - d3d11)"
@echo " TARGET=2 (essl - nacl)"
@echo " TARGET=3 (essl - android)"
@echo " TARGET=4 (glsl - linux)"
@echo " TARGET=5 (metal - osx/ios)"
@echo " TARGET=6 (pssl - ps4)"
@echo " VERBOSE=1 show build commands."
@echo " TARGET=4 (glsl)"
@echo " TARGET=5 (metal)"
@echo " TARGET=6 (pssl)"
@echo " TARGET=7 (spriv)"
else
ifeq ($(TARGET), 0)

View File

@ -377,7 +377,7 @@ namespace bgfx
strReplace(_str, "\r", "\n");
}
void printCode(const char* _code, int32_t _line, int32_t _start, int32_t _end)
void printCode(const char* _code, int32_t _line, int32_t _start, int32_t _end, int32_t _column)
{
fprintf(stderr, "Code:\n---\n");
@ -386,7 +386,20 @@ namespace bgfx
{
if (line >= _start)
{
fprintf(stderr, "%s%3d: %s", _line == line ? ">>> " : " ", line, lr.getLine().c_str() );
if (_line == line)
{
fprintf(stderr, "\n");
fprintf(stderr, ">>> %3d: %s", line, lr.getLine().c_str() );
if (-1 != _column)
{
fprintf(stderr, ">>> %3d: %*s\n", _column, _column, "^");
}
fprintf(stderr, "\n");
}
else
{
fprintf(stderr, " %3d: %s", line, lr.getLine().c_str() );
}
}
else
{

View File

@ -15,7 +15,7 @@ namespace bgfx
BX_MACRO_BLOCK_BEGIN \
if (bgfx::g_verbose) \
{ \
fprintf(stderr, BX_FILE_LINE_LITERAL "" _format "\n", ##__VA_ARGS__); \
fprintf(stdout, BX_FILE_LINE_LITERAL "" _format "\n", ##__VA_ARGS__); \
} \
BX_MACRO_BLOCK_END
@ -107,8 +107,8 @@ namespace bgfx
uint32_t m_size;
};
#define BGFX_UNIFORM_FRAGMENTBIT UINT8_C(0x10)
#define BGFX_UNIFORM_SAMPLERBIT UINT8_C(0x20)
#define BGFX_UNIFORM_FRAGMENTBIT UINT8_C(0x10)
#define BGFX_UNIFORM_SAMPLERBIT UINT8_C(0x20)
const char* getUniformTypeName(UniformType::Enum _enum);
UniformType::Enum nameToUniformTypeEnum(const char* _name);
@ -124,7 +124,7 @@ namespace bgfx
typedef std::vector<Uniform> UniformArray;
void printCode(const char* _code, int32_t _line = 0, int32_t _start = 0, int32_t _end = INT32_MAX);
void printCode(const char* _code, int32_t _line = 0, int32_t _start = 0, int32_t _end = INT32_MAX, int32_t _column = -1);
void strReplace(char* _str, const char* _find, const char* _replace);
int32_t writef(bx::WriterI* _writer, const char* _format, ...);
void writeFile(const char* _filePath, const void* _data, int32_t _size);

View File

@ -42,20 +42,24 @@ namespace bgfx { namespace glsl
if (!glslopt_get_status(shader) )
{
const char* log = glslopt_get_log(shader);
int32_t source = 0;
int32_t line = 0;
int32_t column = 0;
int32_t start = 0;
int32_t end = INT32_MAX;
int32_t source = 0;
int32_t line = 0;
int32_t column = 0;
int32_t start = 0;
int32_t end = INT32_MAX;
if (3 == sscanf(log, "%u:%u(%u):", &source, &line, &column)
bool found = false
|| 3 == sscanf(log, "%u:%u(%u):", &source, &line, &column)
;
if (found
&& 0 != line)
{
start = bx::uint32_imax(1, line-10);
end = start + 20;
end = start + 20;
}
printCode(_code.c_str(), line, start, end);
printCode(_code.c_str(), line, start, end, column);
fprintf(stderr, "Error: %s\n", log);
glslopt_cleanup(ctx);
return false;

View File

@ -13,6 +13,7 @@
# define __out
#endif // defined(__MINGW32__)
#define COM_NO_WINDOWS_H
#include <d3dcompiler.h>
#include <d3d11shader.h>
#include <bx/os.h>
@ -67,7 +68,7 @@ namespace bgfx { namespace hlsl
};
static const D3DCompiler s_d3dcompiler[] =
{ // BK - the only different in interface is GetRequiresFlags at the end
{ // BK - the only different method in interface is GetRequiresFlags at the end
// of IID_ID3D11ShaderReflection47 (which is not used anyway).
{ "D3DCompiler_47.dll", { 0x8d536ca1, 0x0cca, 0x4956, { 0xa8, 0x37, 0x78, 0x69, 0x63, 0x75, 0x55, 0x84 } } },
{ "D3DCompiler_46.dll", { 0x0a233719, 0x3960, 0x4578, { 0x9d, 0x7c, 0x20, 0x3b, 0x8b, 0x1d, 0x9c, 0xc1 } } },
@ -536,7 +537,7 @@ namespace bgfx { namespace hlsl
return true;
}
static bool compile(bx::CommandLine& _cmdLine, uint32_t _d3d, const std::string& _code, bx::WriterI* _writer, bool _firstPass)
static bool compile(bx::CommandLine& _cmdLine, uint32_t _version, const std::string& _code, bx::WriterI* _writer, bool _firstPass)
{
const char* profile = _cmdLine.findOption('p', "profile");
if (NULL == profile)
@ -611,19 +612,24 @@ namespace bgfx { namespace hlsl
{
const char* log = (char*)errorMsg->GetBufferPointer();
int32_t line = 0;
int32_t line = 0;
int32_t column = 0;
int32_t start = 0;
int32_t end = INT32_MAX;
int32_t start = 0;
int32_t end = INT32_MAX;
if (2 == sscanf(log, "(%u,%u):", &line, &column)
bool found = false
|| 2 == sscanf(log, "(%u,%u):", &line, &column)
|| 2 == sscanf(log, " :%u:%u: ", &line, &column)
;
if (found
&& 0 != line)
{
start = bx::uint32_imax(1, line - 10);
end = start + 20;
end = start + 20;
}
printCode(_code.c_str(), line, start, end);
printCode(_code.c_str(), line, start, end, column);
fprintf(stderr, "Error: D3DCompile failed 0x%08x %s\n", (uint32_t)hr, log);
errorMsg->Release();
return false;
@ -634,7 +640,7 @@ namespace bgfx { namespace hlsl
uint16_t attrs[bgfx::Attrib::Count];
uint16_t size = 0;
if (_d3d == 9)
if (_version == 9)
{
if (!getReflectionDataD3D9(code, uniforms) )
{
@ -687,7 +693,7 @@ namespace bgfx { namespace hlsl
}
// recompile with the unused uniforms converted to statics
return compileHLSLShader(_cmdLine, _d3d, output.c_str(), _writer);
return compileHLSLShader(_cmdLine, _version, output.c_str(), _writer);
}
}
@ -742,7 +748,7 @@ namespace bgfx { namespace hlsl
bx::write(_writer, nul);
}
if (_d3d > 9)
if (_version > 9)
{
bx::write(_writer, numAttrs);
bx::write(_writer, attrs, numAttrs*sizeof(uint16_t) );