Basic shader cache.

This commit is contained in:
Ben Vanik
2013-10-11 21:45:20 -07:00
parent 6e4fb87992
commit 1378fad3c0
20 changed files with 981 additions and 40 deletions

View File

@@ -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_);
}