summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/src/shader_dx9bc.cpp
diff options
context:
space:
mode:
author ImJezze <jezze@gmx.net>2016-03-12 12:31:13 +0100
committer ImJezze <jezze@gmx.net>2016-03-12 12:31:13 +0100
commita026a582f1a0ea8c1ede3acaddacef506ef3f3b0 (patch)
treee31573822f2359677de519f9f3b600d98e8764cd /3rdparty/bgfx/src/shader_dx9bc.cpp
parent477d2abd43984f076b7e45f5527591fa8fd0d241 (diff)
parentdcab55bf53b94713a6f72e9633f5101c8dd6c08c (diff)
Merge pull request #15 from mamedev/master
Sync to base master
Diffstat (limited to '3rdparty/bgfx/src/shader_dx9bc.cpp')
-rw-r--r--3rdparty/bgfx/src/shader_dx9bc.cpp98
1 files changed, 53 insertions, 45 deletions
diff --git a/3rdparty/bgfx/src/shader_dx9bc.cpp b/3rdparty/bgfx/src/shader_dx9bc.cpp
index 071a9e2705e..bb2b6a0e4db 100644
--- a/3rdparty/bgfx/src/shader_dx9bc.cpp
+++ b/3rdparty/bgfx/src/shader_dx9bc.cpp
@@ -274,12 +274,12 @@ namespace bgfx
};
BX_STATIC_ASSERT(BX_COUNTOF(s_dx9bcDeclUsage) == Dx9bcDeclUsage::Count);
- int32_t read(bx::ReaderI* _reader, Dx9bcSubOperand& _subOperand)
+ int32_t read(bx::ReaderI* _reader, Dx9bcSubOperand& _subOperand, bx::Error* _err)
{
int32_t size = 0;
uint32_t token;
- size += bx::read(_reader, token);
+ size += bx::read(_reader, token, _err);
_subOperand.type = Dx9bcOperandType::Enum( ( (token & UINT32_C(0x70000000) ) >> 28)
| ( (token & UINT32_C(0x00001800) ) >> 8) );
@@ -289,7 +289,7 @@ namespace bgfx
return size;
}
- int32_t write(bx::WriterI* _writer, const Dx9bcSubOperand& _subOperand)
+ int32_t write(bx::WriterI* _writer, const Dx9bcSubOperand& _subOperand, bx::Error* _err)
{
int32_t size = 0;
@@ -298,17 +298,17 @@ namespace bgfx
token |= (_subOperand.type << 8) & UINT32_C(0x00001800);
token |= _subOperand.regIndex & UINT32_C(0x000007ff);
token |= (_subOperand.swizzleBits << 16) & UINT32_C(0x00ff0000);
- size += bx::write(_writer, token);
+ size += bx::write(_writer, token, _err);
return size;
}
- int32_t read(bx::ReaderI* _reader, Dx9bcOperand& _operand)
+ int32_t read(bx::ReaderI* _reader, Dx9bcOperand& _operand, bx::Error* _err)
{
int32_t size = 0;
uint32_t token;
- size += bx::read(_reader, token);
+ size += bx::read(_reader, token, _err);
_operand.type = Dx9bcOperandType::Enum( ( (token & UINT32_C(0x70000000) ) >> 28)
| ( (token & UINT32_C(0x00001800) ) >> 8) );
@@ -339,13 +339,13 @@ namespace bgfx
if (Dx9bcOperandAddrMode::Relative == _operand.addrMode)
{
- size += read(_reader, _operand.subOperand);
+ size += read(_reader, _operand.subOperand, _err);
}
return size;
}
- int32_t write(bx::WriterI* _writer, const Dx9bcOperand& _operand)
+ int32_t write(bx::WriterI* _writer, const Dx9bcOperand& _operand, bx::Error* _err)
{
int32_t size = 0;
@@ -354,22 +354,22 @@ namespace bgfx
token |= (_operand.type << 8) & UINT32_C(0x00001800);
token |= _operand.regIndex & UINT32_C(0x000007ff);
token |= (_operand.addrMode << 13) & UINT32_C(0x00002000);
- size += bx::write(_writer, token);
+ size += bx::write(_writer, token, _err);
if (Dx9bcOperandAddrMode::Relative == _operand.addrMode)
{
- size += write(_writer, _operand.subOperand);
+ size += write(_writer, _operand.subOperand, _err);
}
return size;
}
- int32_t read(bx::ReaderI* _reader, Dx9bcInstruction& _instruction)
+ int32_t read(bx::ReaderI* _reader, Dx9bcInstruction& _instruction, bx::Error* _err)
{
int32_t size = 0;
uint32_t token;
- size += bx::read(_reader, token);
+ size += bx::read(_reader, token, _err);
_instruction.opcode = Dx9bcOpcode::Enum( (token & UINT32_C(0x0000ffff) ) );
@@ -395,7 +395,7 @@ namespace bgfx
for (int32_t ii = 0, num = _instruction.length-1; ii < num; ++ii)
{
uint32_t tmp;
- size += bx::read(_reader, tmp);
+ size += bx::read(_reader, tmp, _err);
}
}
@@ -436,24 +436,24 @@ namespace bgfx
if (valuesBeforeOpcode
&& 0 < info.numValues)
{
- size += read(_reader, _instruction.value, info.numValues*sizeof(uint32_t) );
+ size += read(_reader, _instruction.value, info.numValues*sizeof(uint32_t), _err);
}
_instruction.operand[0].destination = true;
switch (_instruction.numOperands)
{
- case 6: size += read(_reader, _instruction.operand[currOp++]);
- case 5: size += read(_reader, _instruction.operand[currOp++]);
- case 4: size += read(_reader, _instruction.operand[currOp++]);
- case 3: size += read(_reader, _instruction.operand[currOp++]);
- case 2: size += read(_reader, _instruction.operand[currOp++]);
- case 1: size += read(_reader, _instruction.operand[currOp++]);
+ case 6: size += read(_reader, _instruction.operand[currOp++], _err);
+ case 5: size += read(_reader, _instruction.operand[currOp++], _err);
+ case 4: size += read(_reader, _instruction.operand[currOp++], _err);
+ case 3: size += read(_reader, _instruction.operand[currOp++], _err);
+ case 2: size += read(_reader, _instruction.operand[currOp++], _err);
+ case 1: size += read(_reader, _instruction.operand[currOp++], _err);
case 0:
if (!valuesBeforeOpcode
&& 0 < info.numValues)
{
- size += read(_reader, _instruction.value, info.numValues*sizeof(uint32_t) );
+ size += read(_reader, _instruction.value, info.numValues*sizeof(uint32_t), _err);
}
break;
@@ -469,7 +469,7 @@ namespace bgfx
return size;
}
- int32_t write(bx::WriterI* _writer, const Dx9bcInstruction& _instruction)
+ int32_t write(bx::WriterI* _writer, const Dx9bcInstruction& _instruction, bx::Error* _err)
{
int32_t size = 0;
@@ -477,17 +477,17 @@ namespace bgfx
token |= _instruction.opcode & UINT32_C(0x0000ffff);
token |= (_instruction.specific << 16) & UINT32_C(0x00ff0000);
token |= ( (_instruction.length - 1) << 24) & UINT32_C(0x0f000000);
- size += bx::write(_writer, token);
+ size += bx::write(_writer, token, _err);
uint32_t currOp = 0;
switch (_instruction.numOperands)
{
- case 6: size += write(_writer, _instruction.operand[currOp++]);
- case 5: size += write(_writer, _instruction.operand[currOp++]);
- case 4: size += write(_writer, _instruction.operand[currOp++]);
- case 3: size += write(_writer, _instruction.operand[currOp++]);
- case 2: size += write(_writer, _instruction.operand[currOp++]);
- case 1: size += write(_writer, _instruction.operand[currOp++]);
+ case 6: size += write(_writer, _instruction.operand[currOp++], _err);
+ case 5: size += write(_writer, _instruction.operand[currOp++], _err);
+ case 4: size += write(_writer, _instruction.operand[currOp++], _err);
+ case 3: size += write(_writer, _instruction.operand[currOp++], _err);
+ case 2: size += write(_writer, _instruction.operand[currOp++], _err);
+ case 1: size += write(_writer, _instruction.operand[currOp++], _err);
case 0:
break;
}
@@ -626,7 +626,7 @@ namespace bgfx
return size;
}
- int32_t read(bx::ReaderSeekerI* _reader, Dx9bcShader& _shader)
+ int32_t read(bx::ReaderSeekerI* _reader, Dx9bcShader& _shader, bx::Error* _err)
{
int32_t size = 0;
int64_t offset = bx::seek(_reader);
@@ -634,7 +634,7 @@ namespace bgfx
for (;;)
{
Dx9bcInstruction instruction;
- int32_t length = read(_reader, instruction);
+ int32_t length = read(_reader, instruction, _err);
size += length;
if (Dx9bcOpcode::Count > instruction.opcode)
@@ -662,22 +662,22 @@ namespace bgfx
bx::seek(_reader, offset, bx::Whence::Begin);
_shader.byteCode.resize(size);
- bx::read(_reader, _shader.byteCode.data(), size);
+ bx::read(_reader, _shader.byteCode.data(), size, _err);
return size;
}
- int32_t write(bx::WriterI* _writer, const Dx9bcShader& _shader)
+ int32_t write(bx::WriterI* _writer, const Dx9bcShader& _shader, bx::Error* _err)
{
- BX_UNUSED(_writer, _shader);
+ BX_UNUSED(_writer, _shader, _err);
return 0;
}
- int32_t read(bx::ReaderSeekerI* _reader, Dx9bc& _bc)
+ int32_t read(bx::ReaderSeekerI* _reader, Dx9bc& _bc, bx::Error* _err)
{
int32_t size = 0;
- size += bx::read(_reader, _bc.version);
+ size += bx::read(_reader, _bc.version, _err);
bool pixelShader = (0xffff0000 == (_bc.version & 0xffff0000) );
uint32_t versionMajor = (_bc.version>>8)&0xff;
@@ -689,37 +689,45 @@ namespace bgfx
, versionMinor
);
- size += read(_reader, _bc.shader);
+ size += read(_reader, _bc.shader, _err);
return size;
}
- int32_t write(bx::WriterSeekerI* _writer, const Dx9bc& _dxbc)
+ int32_t write(bx::WriterSeekerI* _writer, const Dx9bc& _dxbc, bx::Error* _err)
{
- BX_UNUSED(_writer, _dxbc);
+ BX_UNUSED(_writer, _dxbc, _err);
return 0;
}
- void parse(const Dx9bcShader& _src, Dx9bcParseFn _fn, void* _userData)
+ void parse(const Dx9bcShader& _src, Dx9bcParseFn _fn, void* _userData, bx::Error* _err)
{
+ BX_ERROR_SCOPE(_err);
+
bx::MemoryReader reader(_src.byteCode.data(), uint32_t(_src.byteCode.size() ) );
-//BX_TRACE("parse %d", _src.byteCode.size());
+ bx::Error err;
for (uint32_t token = 0, numTokens = uint32_t(_src.byteCode.size() / sizeof(uint32_t) ); token < numTokens;)
{
Dx9bcInstruction instruction;
- uint32_t size = read(&reader, instruction);
+ uint32_t size = read(&reader, instruction, _err);
BX_CHECK(size/4 == instruction.length, "read %d, expected %d", size/4, instruction.length); BX_UNUSED(size);
- _fn(token * sizeof(uint32_t), instruction, _userData);
+ bool cont = _fn(token * sizeof(uint32_t), instruction, _userData);
+ if (!cont)
+ {
+ return;
+ }
token += instruction.length;
}
}
- void filter(Dx9bcShader& _dst, const Dx9bcShader& _src, Dx9bcFilterFn _fn, void* _userData)
+ void filter(Dx9bcShader& _dst, const Dx9bcShader& _src, Dx9bcFilterFn _fn, void* _userData, bx::Error* _err)
{
+ BX_ERROR_SCOPE(_err);
+
bx::MemoryReader reader(_src.byteCode.data(), uint32_t(_src.byteCode.size() ) );
bx::MemoryBlock mb(g_allocator);
@@ -728,7 +736,7 @@ namespace bgfx
for (uint32_t token = 0, numTokens = uint32_t(_src.byteCode.size() / sizeof(uint32_t) ); token < numTokens;)
{
Dx9bcInstruction instruction;
- uint32_t size = read(&reader, instruction);
+ uint32_t size = read(&reader, instruction, _err);
BX_CHECK(size/4 == instruction.length, "read %d, expected %d", size/4, instruction.length); BX_UNUSED(size);
_fn(instruction, _userData);