mirror of
https://github.com/libretro/ppsspp.git
synced 2024-11-27 02:10:34 +00:00
thin3d: Remove unused shader language support
This commit is contained in:
parent
956af61ff5
commit
a135dc1547
@ -204,13 +204,8 @@ enum class ShaderLanguage {
|
||||
GLSL_ES_300 = 2,
|
||||
GLSL_410 = 4,
|
||||
GLSL_VULKAN = 8,
|
||||
SPIRV_VULKAN = 16,
|
||||
HLSL_D3D9 = 32,
|
||||
HLSL_D3D11 = 64,
|
||||
HLSL_D3D9_BYTECODE = 128,
|
||||
HLSL_D3D11_BYTECODE = 256,
|
||||
METAL = 512,
|
||||
METAL_BYTECODE = 1024,
|
||||
};
|
||||
|
||||
enum FormatSupport {
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
return deviceList_;
|
||||
}
|
||||
uint32_t GetSupportedShaderLanguages() const override {
|
||||
return (uint32_t)ShaderLanguage::HLSL_D3D11 | (uint32_t)ShaderLanguage::HLSL_D3D11_BYTECODE;
|
||||
return (uint32_t)ShaderLanguage::HLSL_D3D11;
|
||||
}
|
||||
uint32_t GetDataFormatSupport(DataFormat fmt) const override;
|
||||
|
||||
@ -806,11 +806,7 @@ public:
|
||||
};
|
||||
|
||||
ShaderModule *D3D11DrawContext::CreateShaderModule(ShaderStage stage, ShaderLanguage language, const uint8_t *data, size_t dataSize) {
|
||||
switch (language) {
|
||||
case ShaderLanguage::HLSL_D3D11:
|
||||
case ShaderLanguage::HLSL_D3D11_BYTECODE:
|
||||
break;
|
||||
default:
|
||||
if (language != ShaderLanguage::HLSL_D3D11) {
|
||||
ELOG("Unsupported shader language");
|
||||
return nullptr;
|
||||
}
|
||||
@ -826,77 +822,69 @@ ShaderModule *D3D11DrawContext::CreateShaderModule(ShaderStage stage, ShaderLang
|
||||
|
||||
std::string compiled;
|
||||
std::string errors;
|
||||
if (language == ShaderLanguage::HLSL_D3D11) {
|
||||
const char *target = nullptr;
|
||||
switch (stage) {
|
||||
case ShaderStage::FRAGMENT: target = fragmentModel; break;
|
||||
case ShaderStage::VERTEX: target = vertexModel; break;
|
||||
case ShaderStage::GEOMETRY:
|
||||
if (!geometryModel)
|
||||
return nullptr;
|
||||
target = geometryModel;
|
||||
break;
|
||||
case ShaderStage::COMPUTE:
|
||||
case ShaderStage::CONTROL:
|
||||
case ShaderStage::EVALUATION:
|
||||
default:
|
||||
Crash();
|
||||
break;
|
||||
}
|
||||
if (!target) {
|
||||
const char *target = nullptr;
|
||||
switch (stage) {
|
||||
case ShaderStage::FRAGMENT: target = fragmentModel; break;
|
||||
case ShaderStage::VERTEX: target = vertexModel; break;
|
||||
case ShaderStage::GEOMETRY:
|
||||
if (!geometryModel)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ID3DBlob *compiledCode = nullptr;
|
||||
ID3DBlob *errorMsgs = nullptr;
|
||||
HRESULT result = ptr_D3DCompile(data, dataSize, nullptr, nullptr, nullptr, "main", target, 0, 0, &compiledCode, &errorMsgs);
|
||||
if (compiledCode) {
|
||||
compiled = std::string((const char *)compiledCode->GetBufferPointer(), compiledCode->GetBufferSize());
|
||||
compiledCode->Release();
|
||||
}
|
||||
if (errorMsgs) {
|
||||
errors = std::string((const char *)errorMsgs->GetBufferPointer(), errorMsgs->GetBufferSize());
|
||||
ELOG("Failed compiling:\n%s\n%s", data, errors.c_str());
|
||||
errorMsgs->Release();
|
||||
}
|
||||
|
||||
if (result != S_OK) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// OK, we can now proceed
|
||||
language = ShaderLanguage::HLSL_D3D11_BYTECODE;
|
||||
data = (const uint8_t *)compiled.c_str();
|
||||
dataSize = compiled.size();
|
||||
target = geometryModel;
|
||||
break;
|
||||
case ShaderStage::COMPUTE:
|
||||
case ShaderStage::CONTROL:
|
||||
case ShaderStage::EVALUATION:
|
||||
default:
|
||||
Crash();
|
||||
break;
|
||||
}
|
||||
if (!target) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (language == ShaderLanguage::HLSL_D3D11_BYTECODE) {
|
||||
// Easy!
|
||||
D3D11ShaderModule *module = new D3D11ShaderModule();
|
||||
module->stage = stage;
|
||||
module->byteCode_ = std::vector<uint8_t>(data, data + dataSize);
|
||||
HRESULT result = S_OK;
|
||||
switch (stage) {
|
||||
case ShaderStage::VERTEX:
|
||||
result = device_->CreateVertexShader(data, dataSize, nullptr, &module->vs);
|
||||
break;
|
||||
case ShaderStage::FRAGMENT:
|
||||
result = device_->CreatePixelShader(data, dataSize, nullptr, &module->ps);
|
||||
break;
|
||||
case ShaderStage::GEOMETRY:
|
||||
result = device_->CreateGeometryShader(data, dataSize, nullptr, &module->gs);
|
||||
break;
|
||||
default:
|
||||
ELOG("Unsupported shader stage");
|
||||
result = S_FALSE;
|
||||
break;
|
||||
}
|
||||
if (result == S_OK) {
|
||||
return module;
|
||||
} else {
|
||||
delete module;
|
||||
return nullptr;
|
||||
}
|
||||
ID3DBlob *compiledCode = nullptr;
|
||||
ID3DBlob *errorMsgs = nullptr;
|
||||
HRESULT result = ptr_D3DCompile(data, dataSize, nullptr, nullptr, nullptr, "main", target, 0, 0, &compiledCode, &errorMsgs);
|
||||
if (compiledCode) {
|
||||
compiled = std::string((const char *)compiledCode->GetBufferPointer(), compiledCode->GetBufferSize());
|
||||
compiledCode->Release();
|
||||
}
|
||||
if (errorMsgs) {
|
||||
errors = std::string((const char *)errorMsgs->GetBufferPointer(), errorMsgs->GetBufferSize());
|
||||
ELOG("Failed compiling:\n%s\n%s", data, errors.c_str());
|
||||
errorMsgs->Release();
|
||||
}
|
||||
|
||||
if (result != S_OK) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// OK, we can now proceed
|
||||
data = (const uint8_t *)compiled.c_str();
|
||||
dataSize = compiled.size();
|
||||
D3D11ShaderModule *module = new D3D11ShaderModule();
|
||||
module->stage = stage;
|
||||
module->byteCode_ = std::vector<uint8_t>(data, data + dataSize);
|
||||
switch (stage) {
|
||||
case ShaderStage::VERTEX:
|
||||
result = device_->CreateVertexShader(data, dataSize, nullptr, &module->vs);
|
||||
break;
|
||||
case ShaderStage::FRAGMENT:
|
||||
result = device_->CreatePixelShader(data, dataSize, nullptr, &module->ps);
|
||||
break;
|
||||
case ShaderStage::GEOMETRY:
|
||||
result = device_->CreateGeometryShader(data, dataSize, nullptr, &module->gs);
|
||||
break;
|
||||
default:
|
||||
ELOG("Unsupported shader stage");
|
||||
result = S_FALSE;
|
||||
break;
|
||||
}
|
||||
if (result == S_OK) {
|
||||
return module;
|
||||
} else {
|
||||
delete module;
|
||||
return nullptr;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ public:
|
||||
return caps_;
|
||||
}
|
||||
uint32_t GetSupportedShaderLanguages() const override {
|
||||
return (uint32_t)ShaderLanguage::HLSL_D3D9 | (uint32_t)ShaderLanguage::HLSL_D3D9_BYTECODE;
|
||||
return (uint32_t)ShaderLanguage::HLSL_D3D9;
|
||||
}
|
||||
uint32_t GetDataFormatSupport(DataFormat fmt) const override;
|
||||
|
||||
|
@ -353,7 +353,7 @@ public:
|
||||
return list;
|
||||
}
|
||||
uint32_t GetSupportedShaderLanguages() const override {
|
||||
return (uint32_t)ShaderLanguage::GLSL_VULKAN | (uint32_t)ShaderLanguage::SPIRV_VULKAN;
|
||||
return (uint32_t)ShaderLanguage::GLSL_VULKAN;
|
||||
}
|
||||
uint32_t GetDataFormatSupport(DataFormat fmt) const override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user