mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-21 06:33:22 +00:00
Add some plumbing to be able to reach DX11.1 features.
This commit is contained in:
parent
6a09d45aee
commit
5a0ee6cc36
@ -103,7 +103,7 @@ bool TranslateShader(std::string *dest, ShaderLanguage destLang, TranslatedShade
|
||||
case GLSL_VULKAN:
|
||||
return false; // TODO
|
||||
#ifdef _WIN32
|
||||
case HLSL_D3D11:
|
||||
case HLSL_DX9:
|
||||
{
|
||||
spirv_cross::CompilerHLSL hlsl(spirv);
|
||||
spirv_cross::CompilerHLSL::Options options{};
|
||||
@ -113,6 +113,16 @@ bool TranslateShader(std::string *dest, ShaderLanguage destLang, TranslatedShade
|
||||
*dest = hlsl.compile();
|
||||
return true;
|
||||
}
|
||||
case HLSL_D3D11:
|
||||
{
|
||||
spirv_cross::CompilerHLSL hlsl(spirv);
|
||||
spirv_cross::CompilerHLSL::Options options{};
|
||||
options.fixup_clipspace = true;
|
||||
options.shader_model = 50;
|
||||
hlsl.set_options(options);
|
||||
*dest = hlsl.compile();
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
case GLSL_140:
|
||||
{
|
||||
|
@ -88,6 +88,14 @@ bool D3D11Context::Init(HINSTANCE hInst, HWND wnd, std::string *error_message) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (FAILED(device_->QueryInterface(__uuidof (ID3D11Device1), (void **)&device1_))) {
|
||||
device1_ = nullptr;
|
||||
}
|
||||
|
||||
if (FAILED(context_->QueryInterface(__uuidof (ID3D11DeviceContext1), (void **)&context1_))) {
|
||||
context1_ = nullptr;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (SUCCEEDED(device_->QueryInterface(__uuidof(ID3D11Debug), (void**)&d3dDebug_))) {
|
||||
if (SUCCEEDED(d3dDebug_->QueryInterface(__uuidof(ID3D11InfoQueue), (void**)&d3dInfoQueue_))) {
|
||||
@ -98,7 +106,7 @@ bool D3D11Context::Init(HINSTANCE hInst, HWND wnd, std::string *error_message) {
|
||||
}
|
||||
#endif
|
||||
|
||||
draw_ = Draw::T3DCreateD3D11Context(device_, context_, hWnd_);
|
||||
draw_ = Draw::T3DCreateD3D11Context(device_, context_, device1_, context1_, hWnd_);
|
||||
draw_->HandleEvent(Draw::Event::GOT_BACKBUFFER);
|
||||
return true;
|
||||
}
|
||||
@ -125,8 +133,13 @@ void D3D11Context::Shutdown() {
|
||||
d3dInfoQueue_->Release();
|
||||
#endif
|
||||
|
||||
if (context1_)
|
||||
context1_->Release();
|
||||
context_->Release();
|
||||
context_ = nullptr;
|
||||
if (device1_)
|
||||
device1_->Release();
|
||||
device1_ = nullptr;
|
||||
device_->Release();
|
||||
device_ = nullptr;
|
||||
hWnd_ = nullptr;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "Common/CommonWindows.h"
|
||||
#include "Windows/GPU/WindowsGraphicsContext.h"
|
||||
#include <d3d11.h>
|
||||
#include <d3d11_1.h>
|
||||
|
||||
class DrawContext;
|
||||
|
||||
@ -41,7 +42,9 @@ public:
|
||||
private:
|
||||
Draw::DrawContext *draw_ = nullptr;
|
||||
ID3D11Device *device_ = nullptr;
|
||||
ID3D11Device1 *device1_ = nullptr;
|
||||
ID3D11DeviceContext *context_ = nullptr;
|
||||
ID3D11DeviceContext1 *context1_ = nullptr;
|
||||
|
||||
#ifdef _DEBUG
|
||||
ID3D11Debug *d3dDebug_ = nullptr;
|
||||
|
@ -27,6 +27,8 @@ struct IDirect3DDevice9Ex;
|
||||
struct IDirect3D9Ex;
|
||||
struct ID3D11Device;
|
||||
struct ID3D11DeviceContext;
|
||||
struct ID3D11Device1;
|
||||
struct ID3D11DeviceContext1;
|
||||
|
||||
#endif
|
||||
|
||||
@ -308,6 +310,7 @@ enum InfoField {
|
||||
|
||||
enum class NativeObject {
|
||||
CONTEXT,
|
||||
CONTEXT_EX,
|
||||
DEVICE,
|
||||
DEVICE_EX,
|
||||
BACKBUFFER_COLOR_VIEW,
|
||||
@ -660,7 +663,7 @@ extern const UniformBufferDesc UBPresetDesc;
|
||||
|
||||
#ifdef _WIN32
|
||||
DrawContext *T3DCreateDX9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, IDirect3DDevice9 *device, IDirect3DDevice9Ex *deviceEx);
|
||||
DrawContext *T3DCreateD3D11Context(ID3D11Device *device, ID3D11DeviceContext *context, HWND hWnd);
|
||||
DrawContext *T3DCreateD3D11Context(ID3D11Device *device, ID3D11DeviceContext *context, ID3D11Device1 *device1, ID3D11DeviceContext1 *context1, HWND hWnd);
|
||||
#endif
|
||||
|
||||
DrawContext *T3DCreateVulkanContext(VulkanContext *context);
|
||||
|
@ -22,7 +22,7 @@ class D3D11RasterState;
|
||||
|
||||
class D3D11DrawContext : public DrawContext {
|
||||
public:
|
||||
D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *deviceContext, HWND hWnd);
|
||||
D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *deviceContext, ID3D11Device1 *device1, ID3D11DeviceContext1 *deviceContext1, HWND hWnd);
|
||||
~D3D11DrawContext();
|
||||
|
||||
const DeviceCaps &GetDeviceCaps() const override {
|
||||
@ -101,6 +101,10 @@ public:
|
||||
return (uintptr_t)device_;
|
||||
case NativeObject::CONTEXT:
|
||||
return (uintptr_t)context_;
|
||||
case NativeObject::DEVICE_EX:
|
||||
return (uintptr_t)device1_;
|
||||
case NativeObject::CONTEXT_EX:
|
||||
return (uintptr_t)context1_;
|
||||
case NativeObject::BACKBUFFER_COLOR_TEX:
|
||||
return (uintptr_t)bbRenderTargetTex_;
|
||||
case NativeObject::BACKBUFFER_DEPTH_TEX:
|
||||
@ -122,6 +126,8 @@ private:
|
||||
HWND hWnd_;
|
||||
ID3D11Device *device_;
|
||||
ID3D11DeviceContext *context_;
|
||||
ID3D11Device1 *device1_;
|
||||
ID3D11DeviceContext1 *context1_;
|
||||
IDXGISwapChain *swapChain_ = nullptr;
|
||||
bool b4g4r4a4Supported_ = false;
|
||||
|
||||
@ -168,7 +174,12 @@ static void GetRes(HWND hWnd, int &xres, int &yres) {
|
||||
yres = rc.bottom - rc.top;
|
||||
}
|
||||
|
||||
D3D11DrawContext::D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *context, HWND hWnd) : device_(device), context_(context), hWnd_(hWnd) {
|
||||
D3D11DrawContext::D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *deviceContext, ID3D11Device1 *device1, ID3D11DeviceContext1 *deviceContext1, HWND hWnd)
|
||||
: device_(device),
|
||||
context_(deviceContext1),
|
||||
device1_(device1),
|
||||
context1_(deviceContext1),
|
||||
hWnd_(hWnd) {
|
||||
HRESULT hr;
|
||||
// Obtain DXGI factory from device (since we used nullptr for pAdapter above)
|
||||
IDXGIFactory1* dxgiFactory = nullptr;
|
||||
@ -1256,8 +1267,8 @@ void D3D11DrawContext::GetFramebufferDimensions(Framebuffer *fbo, int *w, int *h
|
||||
*h = fb->height;
|
||||
}
|
||||
|
||||
DrawContext *T3DCreateD3D11Context(ID3D11Device *device, ID3D11DeviceContext *context, HWND hWnd) {
|
||||
return new D3D11DrawContext(device, context, hWnd);
|
||||
DrawContext *T3DCreateD3D11Context(ID3D11Device *device, ID3D11DeviceContext *context, ID3D11Device1 *device1, ID3D11DeviceContext1 *context1, HWND hWnd) {
|
||||
return new D3D11DrawContext(device, context, device1, context1, hWnd);
|
||||
}
|
||||
|
||||
} // namespace Draw
|
Loading…
x
Reference in New Issue
Block a user