Basic shader cache.
This commit is contained in:
@@ -9,13 +9,35 @@
|
||||
|
||||
#include <xenia/gpu/shader.h>
|
||||
|
||||
#include <xenia/gpu/xenos/ucode_disassembler.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::gpu;
|
||||
using namespace xe::gpu::xenos;
|
||||
|
||||
|
||||
Shader::Shader() {
|
||||
Shader::Shader(
|
||||
XE_GPU_SHADER_TYPE type,
|
||||
const uint8_t* src_ptr, size_t length,
|
||||
uint64_t hash) :
|
||||
type_(type), hash_(hash) {
|
||||
// Verify.
|
||||
dword_count_ = length / 4;
|
||||
XEASSERT(dword_count_ <= 512);
|
||||
|
||||
// Copy bytes and swap.
|
||||
size_t byte_size = dword_count_ * sizeof(uint32_t);
|
||||
dwords_ = (uint32_t*)xe_malloc(byte_size);
|
||||
for (uint32_t n = 0; n < dword_count_; n++) {
|
||||
dwords_[n] = XEGETUINT32BE(src_ptr + n * 4);
|
||||
}
|
||||
}
|
||||
|
||||
Shader::~Shader() {
|
||||
xe_free(dwords_);
|
||||
}
|
||||
|
||||
char* Shader::Disassemble() {
|
||||
return DisassembleShader(type_, dwords_, dword_count_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user