Shader type read for translation.
This commit is contained in:
parent
1378fad3c0
commit
04aad708c9
|
@ -69,6 +69,11 @@ void D3D11GraphicsDriver::SetShader(
|
|||
if (source) {
|
||||
xe_free(source);
|
||||
}
|
||||
|
||||
// Prepare for use.
|
||||
if (shader->Prepare()) {
|
||||
XELOGGPU("D3D11: failed to prepare shader");
|
||||
}
|
||||
}
|
||||
|
||||
void D3D11GraphicsDriver::DrawIndexed(
|
||||
|
|
|
@ -22,8 +22,56 @@ D3D11Shader::D3D11Shader(
|
|||
const uint8_t* src_ptr, size_t length,
|
||||
uint64_t hash) :
|
||||
Shader(type, src_ptr, length, hash) {
|
||||
// TODO(benvanik): create shader/translate/etc.
|
||||
device_ = device;
|
||||
device_->AddRef();
|
||||
}
|
||||
|
||||
D3D11Shader::~D3D11Shader() {
|
||||
device_->Release();
|
||||
}
|
||||
|
||||
|
||||
D3D11VertexShader::D3D11VertexShader(
|
||||
ID3D11Device* device,
|
||||
const uint8_t* src_ptr, size_t length,
|
||||
uint64_t hash) :
|
||||
handle_(0),
|
||||
D3D11Shader(device, XE_GPU_SHADER_TYPE_VERTEX,
|
||||
src_ptr, length, hash) {
|
||||
}
|
||||
|
||||
D3D11VertexShader::~D3D11VertexShader() {
|
||||
if (handle_) handle_->Release();
|
||||
}
|
||||
|
||||
int D3D11VertexShader::Prepare() {
|
||||
if (handle_) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO(benvanik): translate/etc.
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
D3D11PixelShader::D3D11PixelShader(
|
||||
ID3D11Device* device,
|
||||
const uint8_t* src_ptr, size_t length,
|
||||
uint64_t hash) :
|
||||
handle_(0),
|
||||
D3D11Shader(device, XE_GPU_SHADER_TYPE_PIXEL,
|
||||
src_ptr, length, hash) {
|
||||
}
|
||||
|
||||
D3D11PixelShader::~D3D11PixelShader() {
|
||||
if (handle_) handle_->Release();
|
||||
}
|
||||
|
||||
int D3D11PixelShader::Prepare() {
|
||||
if (handle_) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// TODO(benvanik): translate/etc.
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -24,12 +24,47 @@ namespace d3d11 {
|
|||
|
||||
class D3D11Shader : public Shader {
|
||||
public:
|
||||
virtual ~D3D11Shader();
|
||||
|
||||
protected:
|
||||
D3D11Shader(
|
||||
ID3D11Device* device,
|
||||
xenos::XE_GPU_SHADER_TYPE type,
|
||||
const uint8_t* src_ptr, size_t length,
|
||||
uint64_t hash);
|
||||
virtual ~D3D11Shader();
|
||||
|
||||
protected:
|
||||
ID3D11Device* device_;
|
||||
};
|
||||
|
||||
|
||||
class D3D11VertexShader : public D3D11Shader {
|
||||
public:
|
||||
D3D11VertexShader(
|
||||
ID3D11Device* device,
|
||||
const uint8_t* src_ptr, size_t length,
|
||||
uint64_t hash);
|
||||
virtual ~D3D11VertexShader();
|
||||
|
||||
virtual int Prepare();
|
||||
|
||||
private:
|
||||
ID3D11VertexShader* handle_;
|
||||
};
|
||||
|
||||
|
||||
class D3D11PixelShader : public D3D11Shader {
|
||||
public:
|
||||
D3D11PixelShader(
|
||||
ID3D11Device* device,
|
||||
const uint8_t* src_ptr, size_t length,
|
||||
uint64_t hash);
|
||||
virtual ~D3D11PixelShader();
|
||||
|
||||
virtual int Prepare();
|
||||
|
||||
private:
|
||||
ID3D11PixelShader* handle_;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
using namespace xe;
|
||||
using namespace xe::gpu;
|
||||
using namespace xe::gpu::d3d11;
|
||||
using namespace xe::gpu::xenos;
|
||||
|
||||
|
||||
D3D11ShaderCache::D3D11ShaderCache(ID3D11Device* device) {
|
||||
|
@ -30,9 +31,15 @@ Shader* D3D11ShaderCache::CreateCore(
|
|||
xenos::XE_GPU_SHADER_TYPE type,
|
||||
const uint8_t* src_ptr, size_t length,
|
||||
uint32_t hash) {
|
||||
return new D3D11Shader(
|
||||
device_,
|
||||
type,
|
||||
src_ptr, length,
|
||||
hash);
|
||||
switch (type) {
|
||||
case XE_GPU_SHADER_TYPE_VERTEX:
|
||||
return new D3D11VertexShader(
|
||||
device_, src_ptr, length, hash);
|
||||
case XE_GPU_SHADER_TYPE_PIXEL:
|
||||
return new D3D11PixelShader(
|
||||
device_, src_ptr, length, hash);
|
||||
default:
|
||||
XEASSERTALWAYS();
|
||||
return NULL;
|
||||
}
|
||||
}
|
|
@ -64,6 +64,11 @@ void NopGraphicsDriver::SetShader(
|
|||
if (source) {
|
||||
xe_free(source);
|
||||
}
|
||||
|
||||
// Prepare for use.
|
||||
if (shader->Prepare()) {
|
||||
XELOGGPU("NOP: failed to prepare shader");
|
||||
}
|
||||
}
|
||||
|
||||
void NopGraphicsDriver::DrawIndexed(
|
||||
|
|
|
@ -41,3 +41,7 @@ Shader::~Shader() {
|
|||
char* Shader::Disassemble() {
|
||||
return DisassembleShader(type_, dwords_, dword_count_);
|
||||
}
|
||||
|
||||
int Shader::Prepare() {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,8 @@ public:
|
|||
// NOTE: xe_free() the returned string!
|
||||
char* Disassemble();
|
||||
|
||||
virtual int Prepare();
|
||||
|
||||
protected:
|
||||
xenos::XE_GPU_SHADER_TYPE type_;
|
||||
uint32_t* dwords_;
|
||||
|
|
Loading…
Reference in New Issue