CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Common/GPU/D3D9/D3D9ShaderCompiler.cpp
Views: 1401
#include "ppsspp_config.h"12#ifdef _WIN3234#include "Common/CommonWindows.h"5#include "Common/GPU/D3D9/D3DCompilerLoader.h"6#include "Common/GPU/D3D9/D3D9ShaderCompiler.h"7#include "Common/CommonFuncs.h"8#include "Common/SysError.h"9#include "Common/Log.h"10#include "Common/StringUtils.h"11#include <wrl/client.h>1213using namespace Microsoft::WRL;1415struct ID3DXConstantTable;1617LPD3DBLOB CompileShaderToByteCodeD3D9(const char *code, const char *target, std::string *errorMessage) {18ComPtr<ID3DBlob> pShaderCode;19ComPtr<ID3DBlob> pErrorMsg;2021// Compile pixel shader.22HRESULT hr = dyn_D3DCompile(code,23(UINT)strlen(code),24nullptr,25nullptr,26nullptr,27"main",28target,290,300,31&pShaderCode,32&pErrorMsg);3334if (pErrorMsg) {35*errorMessage = std::string((CHAR *)pErrorMsg->GetBufferPointer());3637OutputDebugStringUTF8(LineNumberString(std::string(code)).c_str());38OutputDebugStringUTF8(errorMessage->c_str());39} else if (FAILED(hr)) {40*errorMessage = GetStringErrorMsg(hr);41} else {42errorMessage->clear();43}4445return pShaderCode.Detach();46}4748bool CompilePixelShaderD3D9(LPDIRECT3DDEVICE9 device, const char *code, LPDIRECT3DPIXELSHADER9 *pShader, std::string *errorMessage) {49ComPtr<ID3DBlob> pShaderCode = CompileShaderToByteCodeD3D9(code, "ps_3_0", errorMessage);50if (pShaderCode) {51// Create pixel shader.52device->CreatePixelShader((DWORD*)pShaderCode->GetBufferPointer(), pShader);53return true;54} else {55return false;56}57}5859bool CompileVertexShaderD3D9(LPDIRECT3DDEVICE9 device, const char *code, LPDIRECT3DVERTEXSHADER9 *pShader, std::string *errorMessage) {60ComPtr<ID3DBlob> pShaderCode = CompileShaderToByteCodeD3D9(code, "vs_3_0", errorMessage);61if (pShaderCode) {62// Create vertex shader.63device->CreateVertexShader((DWORD*)pShaderCode->GetBufferPointer(), pShader);64return true;65} else {66return false;67}68}6970#endif717273