Massively disgusting and incomplete shader translator.

This commit is contained in:
Ben Vanik
2013-10-12 22:14:23 -07:00
parent 0ef278325f
commit 96a857e892
10 changed files with 1145 additions and 60 deletions

View File

@@ -83,15 +83,12 @@ void D3D11GraphicsDriver::SetShader(
type, p, length);
// Disassemble.
char* source = shader->Disassemble();
const char* source = shader->disasm_src();
if (!source) {
source = "<failed to disassemble>";
}
XELOGGPU("D3D11: set shader %d at %0.8X (%db):\n%s",
type, address, length, source);
if (source) {
xe_free(source);
}
// Stash for later.
switch (type) {
@@ -289,7 +286,7 @@ int D3D11GraphicsDriver::BindShaders() {
if (ps) {
if (!ps->is_prepared()) {
// Prepare for use.
if (ps->Prepare(&program_cntl)) {
if (ps->Prepare(&program_cntl, vs)) {
XELOGGPU("D3D11: failed to prepare pixel shader");
state_.pixel_shader = NULL;
return 1;

File diff suppressed because it is too large Load Diff

View File

@@ -22,6 +22,13 @@ namespace xe {
namespace gpu {
namespace d3d11 {
struct Output;
typedef struct {
Output* output;
xenos::XE_GPU_SHADER_TYPE type;
} xe_gpu_translate_ctx_t;
class D3D11Shader : public Shader {
public:
@@ -34,8 +41,18 @@ protected:
const uint8_t* src_ptr, size_t length,
uint64_t hash);
const char* translated_src() const { return translated_src_; }
void set_translated_src(char* value);
int TranslateExec(
xe_gpu_translate_ctx_t& ctx, const xenos::instr_cf_exec_t& cf);
ID3D10Blob* Compile(const char* shader_source);
protected:
ID3D11Device* device_;
char* translated_src_;
};
@@ -52,6 +69,9 @@ public:
int Prepare(xenos::xe_gpu_program_cntl_t* program_cntl);
private:
const char* Translate(xenos::xe_gpu_program_cntl_t* program_cntl);
private:
ID3D11VertexShader* handle_;
ID3D11InputLayout* input_layout_;
@@ -68,7 +88,12 @@ public:
ID3D11PixelShader* handle() const { return handle_; }
int Prepare(xenos::xe_gpu_program_cntl_t* program_cntl);
int Prepare(xenos::xe_gpu_program_cntl_t* program_cntl,
D3D11VertexShader* input_shader);
private:
const char* Translate(xenos::xe_gpu_program_cntl_t* program_cntl,
D3D11VertexShader* input_shader);
private:
ID3D11PixelShader* handle_;