Basic shader cache.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
#include <xenia/gpu/nop/nop_graphics_driver.h>
|
||||
|
||||
#include <xenia/gpu/gpu-private.h>
|
||||
#include <xenia/gpu/xenos/ucode_disassembler.h>
|
||||
#include <xenia/gpu/shader_cache.h>
|
||||
|
||||
|
||||
using namespace xe;
|
||||
@@ -21,9 +21,11 @@ using namespace xe::gpu::xenos;
|
||||
|
||||
NopGraphicsDriver::NopGraphicsDriver(xe_memory_ref memory) :
|
||||
GraphicsDriver(memory) {
|
||||
shader_cache_ = new ShaderCache();
|
||||
}
|
||||
|
||||
NopGraphicsDriver::~NopGraphicsDriver() {
|
||||
delete shader_cache_;
|
||||
}
|
||||
|
||||
void NopGraphicsDriver::Initialize() {
|
||||
@@ -47,29 +49,20 @@ void NopGraphicsDriver::SetShader(
|
||||
uint32_t address,
|
||||
uint32_t start,
|
||||
uint32_t length) {
|
||||
// Swap shader words.
|
||||
uint32_t dword_count = length / 4;
|
||||
XEASSERT(dword_count <= 512);
|
||||
if (dword_count > 512) {
|
||||
XELOGGPU("NOP: ignoring shader %d at %0.8X (%db): too long",
|
||||
type, address, length);
|
||||
return;
|
||||
}
|
||||
// Find or create shader in the cache.
|
||||
uint8_t* p = xe_memory_addr(memory_, address);
|
||||
uint32_t dwords[512] = {0};
|
||||
for (uint32_t n = 0; n < dword_count; n++) {
|
||||
dwords[n] = XEGETUINT32BE(p + n * 4);
|
||||
}
|
||||
Shader* shader = shader_cache_->FindOrCreate(
|
||||
type, p, length);
|
||||
|
||||
// Disassemble.
|
||||
const char* source = DisassembleShader(type, dwords, dword_count);
|
||||
char* source = shader->Disassemble();
|
||||
if (!source) {
|
||||
source = "<failed to disassemble>";
|
||||
}
|
||||
XELOGGPU("NOP: set shader %d at %0.8X (%db):\n%s",
|
||||
type, address, length, source);
|
||||
if (source) {
|
||||
xe_free((void*)source);
|
||||
xe_free(source);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
|
||||
class ShaderCache;
|
||||
|
||||
namespace nop {
|
||||
|
||||
|
||||
@@ -41,6 +44,7 @@ public:
|
||||
uint32_t index_count);
|
||||
|
||||
protected:
|
||||
ShaderCache* shader_cache_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user