2017-02-08 18:07:34 +01:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
2017-02-08 17:47:07 +01:00
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2017-02-08 18:07:34 +01:00
|
|
|
#include <d3d11.h>
|
|
|
|
|
|
|
|
// Keeps track of allocated FBOs.
|
|
|
|
// Also provides facilities for drawing and later converting raw
|
|
|
|
// pixel data.
|
|
|
|
|
|
|
|
#include "GPU/GPUCommon.h"
|
|
|
|
#include "GPU/Common/FramebufferCommon.h"
|
|
|
|
#include "ext/native/thin3d/thin3d.h"
|
|
|
|
|
|
|
|
class TextureCacheD3D11;
|
|
|
|
class DrawEngineD3D11;
|
|
|
|
class ShaderManagerD3D11;
|
|
|
|
|
|
|
|
class FramebufferManagerD3D11 : public FramebufferManagerCommon {
|
|
|
|
public:
|
|
|
|
FramebufferManagerD3D11(Draw::DrawContext *draw);
|
|
|
|
~FramebufferManagerD3D11();
|
|
|
|
|
|
|
|
void SetTextureCache(TextureCacheD3D11 *tc);
|
2017-02-15 18:32:44 +01:00
|
|
|
void SetShaderManager(ShaderManagerD3D11 *sm);
|
2017-10-18 12:26:02 +02:00
|
|
|
void SetDrawEngine(DrawEngineD3D11 *td);
|
2017-05-31 23:24:56 -07:00
|
|
|
void DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, int flags) override;
|
2017-02-08 18:07:34 +01:00
|
|
|
|
|
|
|
void EndFrame();
|
|
|
|
void DeviceLost();
|
|
|
|
void ReformatFramebufferFrom(VirtualFramebuffer *vfb, GEBufferFormat old) override;
|
|
|
|
|
|
|
|
void BlitFramebufferDepth(VirtualFramebuffer *src, VirtualFramebuffer *dst) override;
|
|
|
|
|
2017-02-17 14:30:42 +01:00
|
|
|
void BindFramebufferAsColorTexture(int stage, VirtualFramebuffer *framebuffer, int flags);
|
2017-02-08 18:07:34 +01:00
|
|
|
|
|
|
|
virtual bool NotifyStencilUpload(u32 addr, int size, bool skipZero = false) override;
|
|
|
|
|
2017-02-13 02:12:49 +01:00
|
|
|
// TODO: Remove
|
|
|
|
ID3D11Buffer *GetDynamicQuadBuffer() {
|
|
|
|
return quadBuffer_;
|
|
|
|
}
|
|
|
|
|
2017-02-08 18:07:34 +01:00
|
|
|
protected:
|
|
|
|
// Used by ReadFramebufferToMemory and later framebuffer block copies
|
|
|
|
void BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp) override;
|
|
|
|
|
|
|
|
bool CreateDownloadTempBuffer(VirtualFramebuffer *nvfb) override;
|
|
|
|
void UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) override;
|
|
|
|
|
|
|
|
private:
|
2017-02-15 16:01:59 +01:00
|
|
|
void Bind2DShader() override;
|
2017-02-08 18:07:34 +01:00
|
|
|
void PackDepthbuffer(VirtualFramebuffer *vfb, int x, int y, int w, int h);
|
2017-02-17 12:51:37 +01:00
|
|
|
void SimpleBlit(
|
|
|
|
Draw::Framebuffer *dest, float destX1, float destY1, float destX2, float destY2,
|
|
|
|
Draw::Framebuffer *src, float srcX1, float srcY1, float srcX2, float srcY2,
|
|
|
|
bool linearFilter);
|
2017-02-08 18:07:34 +01:00
|
|
|
|
|
|
|
ID3D11Device *device_;
|
|
|
|
ID3D11DeviceContext *context_;
|
2017-03-05 12:26:46 +01:00
|
|
|
D3D_FEATURE_LEVEL featureLevel_;
|
2017-02-08 18:07:34 +01:00
|
|
|
|
2017-02-12 11:20:55 +01:00
|
|
|
ID3D11VertexShader *quadVertexShader_;
|
|
|
|
ID3D11PixelShader *quadPixelShader_;
|
2017-02-12 13:55:49 +01:00
|
|
|
ID3D11InputLayout *quadInputLayout_;
|
2017-02-12 11:20:55 +01:00
|
|
|
// Dynamic
|
|
|
|
ID3D11Buffer *quadBuffer_;
|
|
|
|
ID3D11Buffer *fsQuadBuffer_;
|
2017-02-12 13:55:49 +01:00
|
|
|
const UINT quadStride_ = 20;
|
|
|
|
const UINT quadOffset_ = 0;
|
|
|
|
static const D3D11_INPUT_ELEMENT_DESC g_QuadVertexElements[2];
|
2017-02-08 18:07:34 +01:00
|
|
|
|
2017-02-12 13:55:49 +01:00
|
|
|
ID3D11PixelShader *stencilUploadPS_ = nullptr;
|
|
|
|
ID3D11VertexShader *stencilUploadVS_ = nullptr;
|
|
|
|
ID3D11InputLayout *stencilUploadInputLayout_ = nullptr;
|
2017-02-13 17:29:36 +01:00
|
|
|
ID3D11Buffer *stencilValueBuffer_ = nullptr;
|
2017-02-09 13:27:45 +01:00
|
|
|
ID3D11DepthStencilState *stencilMaskStates_[256]{};
|
2017-02-08 18:07:34 +01:00
|
|
|
|
2018-08-30 21:00:21 -07:00
|
|
|
ID3D11Texture2D *nullTexture_ = nullptr;
|
|
|
|
ID3D11ShaderResourceView *nullTextureView_ = nullptr;
|
|
|
|
|
2017-02-08 18:07:34 +01:00
|
|
|
TextureCacheD3D11 *textureCacheD3D11_;
|
2017-02-15 18:32:44 +01:00
|
|
|
ShaderManagerD3D11 *shaderManagerD3D11_;
|
2017-10-18 12:26:02 +02:00
|
|
|
DrawEngineD3D11 *drawEngineD3D11_;
|
2017-02-14 12:42:35 +01:00
|
|
|
};
|