mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
Fixed Issue #128 caused by read from unaligned memory (undefined behavior? when running asmjs).
This commit is contained in:
parent
659feeec61
commit
e42d878fe8
1 changed files with 8 additions and 7 deletions
15
src/bgfx_p.h
15
src/bgfx_p.h
|
@ -808,14 +808,14 @@ namespace bgfx
|
|||
static void decodeOpcode(uint32_t _opcode, UniformType::Enum& _type, uint16_t& _loc, uint16_t& _num, uint16_t& _copy)
|
||||
{
|
||||
const uint32_t type = (_opcode&CONSTANT_OPCODE_TYPE_MASK) >> CONSTANT_OPCODE_TYPE_SHIFT;
|
||||
const uint32_t loc = (_opcode&CONSTANT_OPCODE_LOC_MASK) >> CONSTANT_OPCODE_LOC_SHIFT;
|
||||
const uint32_t num = (_opcode&CONSTANT_OPCODE_NUM_MASK) >> CONSTANT_OPCODE_NUM_SHIFT;
|
||||
const uint32_t copy = (_opcode&CONSTANT_OPCODE_COPY_MASK) >> CONSTANT_OPCODE_COPY_SHIFT;
|
||||
const uint32_t loc = (_opcode&CONSTANT_OPCODE_LOC_MASK ) >> CONSTANT_OPCODE_LOC_SHIFT;
|
||||
const uint32_t num = (_opcode&CONSTANT_OPCODE_NUM_MASK ) >> CONSTANT_OPCODE_NUM_SHIFT;
|
||||
const uint32_t copy = (_opcode&CONSTANT_OPCODE_COPY_MASK); // >> CONSTANT_OPCODE_COPY_SHIFT;
|
||||
|
||||
_type = (UniformType::Enum)(type);
|
||||
_copy = (uint16_t)copy;
|
||||
_num = (uint16_t)num;
|
||||
_loc = (uint16_t)loc;
|
||||
_num = (uint16_t)num;
|
||||
_loc = (uint16_t)loc;
|
||||
}
|
||||
|
||||
void write(const void* _data, uint32_t _size)
|
||||
|
@ -844,8 +844,9 @@ namespace bgfx
|
|||
|
||||
uint32_t read()
|
||||
{
|
||||
const char* result = read(sizeof(uint32_t) );
|
||||
return *( (uint32_t*)result);
|
||||
uint32_t result;
|
||||
memcpy(&result, read(sizeof(uint32_t) ), sizeof(uint32_t) );
|
||||
return result;
|
||||
}
|
||||
|
||||
bool isEmpty() const
|
||||
|
|
Loading…
Reference in a new issue