mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 23:10:38 +00:00
d3d9: refactor CompileShaderToByteCodeD3D9
This commit is contained in:
parent
049dd8bb79
commit
3a285bbd2f
@ -15,8 +15,7 @@ using namespace Microsoft::WRL;
|
|||||||
|
|
||||||
struct ID3DXConstantTable;
|
struct ID3DXConstantTable;
|
||||||
|
|
||||||
LPD3DBLOB CompileShaderToByteCodeD3D9(const char *code, const char *target, std::string *errorMessage) {
|
HRESULT CompileShaderToByteCodeD3D9(const char *code, const char *target, std::string *errorMessage, ID3DBlob **ppShaderCode) {
|
||||||
ComPtr<ID3DBlob> pShaderCode;
|
|
||||||
ComPtr<ID3DBlob> pErrorMsg;
|
ComPtr<ID3DBlob> pErrorMsg;
|
||||||
|
|
||||||
// Compile pixel shader.
|
// Compile pixel shader.
|
||||||
@ -29,7 +28,7 @@ LPD3DBLOB CompileShaderToByteCodeD3D9(const char *code, const char *target, std:
|
|||||||
target,
|
target,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
&pShaderCode,
|
ppShaderCode,
|
||||||
&pErrorMsg);
|
&pErrorMsg);
|
||||||
|
|
||||||
if (pErrorMsg) {
|
if (pErrorMsg) {
|
||||||
@ -43,12 +42,13 @@ LPD3DBLOB CompileShaderToByteCodeD3D9(const char *code, const char *target, std:
|
|||||||
errorMessage->clear();
|
errorMessage->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
return pShaderCode.Detach();
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompilePixelShaderD3D9(LPDIRECT3DDEVICE9 device, const char *code, LPDIRECT3DPIXELSHADER9 *pShader, std::string *errorMessage) {
|
bool CompilePixelShaderD3D9(LPDIRECT3DDEVICE9 device, const char *code, LPDIRECT3DPIXELSHADER9 *pShader, std::string *errorMessage) {
|
||||||
ComPtr<ID3DBlob> pShaderCode = CompileShaderToByteCodeD3D9(code, "ps_3_0", errorMessage);
|
ComPtr<ID3DBlob> pShaderCode;
|
||||||
if (pShaderCode) {
|
HRESULT hr = CompileShaderToByteCodeD3D9(code, "ps_3_0", errorMessage, &pShaderCode);
|
||||||
|
if (SUCCEEDED(hr)) {
|
||||||
// Create pixel shader.
|
// Create pixel shader.
|
||||||
device->CreatePixelShader((DWORD*)pShaderCode->GetBufferPointer(), pShader);
|
device->CreatePixelShader((DWORD*)pShaderCode->GetBufferPointer(), pShader);
|
||||||
return true;
|
return true;
|
||||||
@ -58,8 +58,9 @@ bool CompilePixelShaderD3D9(LPDIRECT3DDEVICE9 device, const char *code, LPDIRECT
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CompileVertexShaderD3D9(LPDIRECT3DDEVICE9 device, const char *code, LPDIRECT3DVERTEXSHADER9 *pShader, std::string *errorMessage) {
|
bool CompileVertexShaderD3D9(LPDIRECT3DDEVICE9 device, const char *code, LPDIRECT3DVERTEXSHADER9 *pShader, std::string *errorMessage) {
|
||||||
ComPtr<ID3DBlob> pShaderCode = CompileShaderToByteCodeD3D9(code, "vs_3_0", errorMessage);
|
ComPtr<ID3DBlob> pShaderCode;
|
||||||
if (pShaderCode) {
|
HRESULT hr = CompileShaderToByteCodeD3D9(code, "vs_3_0", errorMessage, &pShaderCode);
|
||||||
|
if (SUCCEEDED(hr)) {
|
||||||
// Create vertex shader.
|
// Create vertex shader.
|
||||||
device->CreateVertexShader((DWORD*)pShaderCode->GetBufferPointer(), pShader);
|
device->CreateVertexShader((DWORD*)pShaderCode->GetBufferPointer(), pShader);
|
||||||
return true;
|
return true;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
struct ID3DXConstantTable;
|
struct ID3DXConstantTable;
|
||||||
|
|
||||||
LPD3DBLOB CompileShaderToByteCodeD3D9(const char *code, const char *target, std::string *errorMessage);
|
HRESULT CompileShaderToByteCodeD3D9(const char *code, const char *target, std::string *errorMessage, LPD3DBLOB *pShaderCode);
|
||||||
|
|
||||||
bool CompilePixelShaderD3D9(LPDIRECT3DDEVICE9 device, const char *code, LPDIRECT3DPIXELSHADER9 *pShader, std::string *errorMessage);
|
bool CompilePixelShaderD3D9(LPDIRECT3DDEVICE9 device, const char *code, LPDIRECT3DPIXELSHADER9 *pShader, std::string *errorMessage);
|
||||||
bool CompileVertexShaderD3D9(LPDIRECT3DDEVICE9 device, const char *code, LPDIRECT3DVERTEXSHADER9 *pShader, std::string *errorMessage);
|
bool CompileVertexShaderD3D9(LPDIRECT3DDEVICE9 device, const char *code, LPDIRECT3DVERTEXSHADER9 *pShader, std::string *errorMessage);
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
#include "GPU/Common/DepalettizeShaderCommon.h"
|
#include "GPU/Common/DepalettizeShaderCommon.h"
|
||||||
|
|
||||||
#if PPSSPP_PLATFORM(WINDOWS)
|
#if PPSSPP_PLATFORM(WINDOWS)
|
||||||
|
#include <wrl/client.h>
|
||||||
#include "GPU/D3D11/D3D11Util.h"
|
#include "GPU/D3D11/D3D11Util.h"
|
||||||
#include "GPU/D3D11/D3D11Loader.h"
|
#include "GPU/D3D11/D3D11Loader.h"
|
||||||
|
|
||||||
@ -164,13 +165,9 @@ bool TestCompileShader(const char *buffer, ShaderLanguage lang, ShaderStage stag
|
|||||||
case ShaderStage::Fragment: programType = "ps_3_0"; break;
|
case ShaderStage::Fragment: programType = "ps_3_0"; break;
|
||||||
default: return false;
|
default: return false;
|
||||||
}
|
}
|
||||||
LPD3DBLOB blob = CompileShaderToByteCodeD3D9(buffer, programType, errorMessage);
|
Microsoft::WRL::ComPtr<ID3DBlob> blob;
|
||||||
if (blob) {
|
HRESULT hr = CompileShaderToByteCodeD3D9(buffer, programType, errorMessage, &blob);
|
||||||
blob->Release();
|
return SUCCEEDED(hr);
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user