mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-11 05:26:24 +02:00
D3D11 prep
This commit is contained in:
1 parent
7800bfdf72
commit
da65af832a
8 files changed
+60
-31
No files matched your search
@@ -163,30 +163,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t GetNativeObject(NativeObject obj, void *srcObject) override {
|
||||
switch (obj) {
|
||||
case NativeObject::DEVICE:
|
||||
return (uint64_t)(uintptr_t)device_;
|
||||
case NativeObject::CONTEXT:
|
||||
return (uint64_t)(uintptr_t)context_;
|
||||
case NativeObject::DEVICE_EX:
|
||||
return (uint64_t)(uintptr_t)device1_;
|
||||
case NativeObject::CONTEXT_EX:
|
||||
return (uint64_t)(uintptr_t)context1_;
|
||||
case NativeObject::BACKBUFFER_COLOR_TEX:
|
||||
return (uint64_t)(uintptr_t)bbRenderTargetTex_;
|
||||
case NativeObject::BACKBUFFER_DEPTH_TEX:
|
||||
return (uint64_t)(uintptr_t)bbDepthStencilTex_;
|
||||
case NativeObject::BACKBUFFER_COLOR_VIEW:
|
||||
return (uint64_t)(uintptr_t)bbRenderTargetView_;
|
||||
case NativeObject::BACKBUFFER_DEPTH_VIEW:
|
||||
return (uint64_t)(uintptr_t)bbDepthStencilView_;
|
||||
case NativeObject::FEATURE_LEVEL:
|
||||
return (uint64_t)(uintptr_t)featureLevel_;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
uint64_t GetNativeObject(NativeObject obj, void *srcObject) override;
|
||||
|
||||
void HandleEvent(Event ev, int width, int height, void *param1, void *param2) override;
|
||||
|
||||
@@ -1701,6 +1678,33 @@ void D3D11DrawContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, F
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t D3D11DrawContext::GetNativeObject(NativeObject obj, void *srcObject) {
|
||||
switch (obj) {
|
||||
case NativeObject::DEVICE:
|
||||
return (uint64_t)(uintptr_t)device_;
|
||||
case NativeObject::CONTEXT:
|
||||
return (uint64_t)(uintptr_t)context_;
|
||||
case NativeObject::DEVICE_EX:
|
||||
return (uint64_t)(uintptr_t)device1_;
|
||||
case NativeObject::CONTEXT_EX:
|
||||
return (uint64_t)(uintptr_t)context1_;
|
||||
case NativeObject::BACKBUFFER_COLOR_TEX:
|
||||
return (uint64_t)(uintptr_t)bbRenderTargetTex_;
|
||||
case NativeObject::BACKBUFFER_DEPTH_TEX:
|
||||
return (uint64_t)(uintptr_t)bbDepthStencilTex_;
|
||||
case NativeObject::BACKBUFFER_COLOR_VIEW:
|
||||
return (uint64_t)(uintptr_t)bbRenderTargetView_;
|
||||
case NativeObject::BACKBUFFER_DEPTH_VIEW:
|
||||
return (uint64_t)(uintptr_t)bbDepthStencilView_;
|
||||
case NativeObject::FEATURE_LEVEL:
|
||||
return (uint64_t)(uintptr_t)featureLevel_;
|
||||
case NativeObject::TEXTURE_VIEW:
|
||||
return (uint64_t)(((D3D11Texture *)srcObject)->view);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uintptr_t D3D11DrawContext::GetFramebufferAPITexture(Framebuffer *fbo, int channelBit, int attachment) {
|
||||
D3D11Framebuffer *fb = (D3D11Framebuffer *)fbo;
|
||||
switch (channelBit) {
|
||||
|
||||
@@ -293,6 +293,18 @@ public:
|
||||
D3D9Texture(LPDIRECT3DDEVICE9 device, LPDIRECT3DDEVICE9EX deviceEx, const TextureDesc &desc);
|
||||
~D3D9Texture();
|
||||
void SetToSampler(LPDIRECT3DDEVICE9 device, int sampler);
|
||||
LPDIRECT3DBASETEXTURE9 Texture() const {
|
||||
// TODO: Cleanup
|
||||
if (tex_) {
|
||||
return tex_;
|
||||
} else if (volTex_) {
|
||||
return volTex_;
|
||||
} else if (cubeTex_) {
|
||||
return cubeTex_;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void SetImageData(int x, int y, int z, int width, int height, int depth, int level, int stride, const uint8_t *data, TextureCallback callback);
|
||||
@@ -302,9 +314,9 @@ private:
|
||||
TextureType type_;
|
||||
DataFormat format_;
|
||||
D3DFORMAT d3dfmt_;
|
||||
LPDIRECT3DTEXTURE9 tex_;
|
||||
LPDIRECT3DVOLUMETEXTURE9 volTex_;
|
||||
LPDIRECT3DCUBETEXTURE9 cubeTex_;
|
||||
LPDIRECT3DTEXTURE9 tex_ = nullptr;
|
||||
LPDIRECT3DVOLUMETEXTURE9 volTex_ = nullptr;
|
||||
LPDIRECT3DCUBETEXTURE9 cubeTex_ = nullptr;
|
||||
};
|
||||
|
||||
D3D9Texture::D3D9Texture(LPDIRECT3DDEVICE9 device, LPDIRECT3DDEVICE9EX deviceEx, const TextureDesc &desc)
|
||||
@@ -568,6 +580,8 @@ public:
|
||||
return (uint64_t)(uintptr_t)device_;
|
||||
case NativeObject::DEVICE_EX:
|
||||
return (uint64_t)(uintptr_t)deviceEx_;
|
||||
case NativeObject::TEXTURE_VIEW:
|
||||
return (uint64_t)(((D3D9Texture *)srcObject)->Texture());
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1424,7 +1424,7 @@ uint64_t OpenGLContext::GetNativeObject(NativeObject obj, void *srcObject) {
|
||||
switch (obj) {
|
||||
case NativeObject::RENDER_MANAGER:
|
||||
return (uint64_t)(uintptr_t)&renderManager_;
|
||||
case NativeObject::TEXTURE: // Gets the GLRTexture *
|
||||
case NativeObject::TEXTURE_VIEW: // Gets the GLRTexture *
|
||||
return (uint64_t)(((OpenGLTexture *)srcObject)->GetTex());
|
||||
default:
|
||||
return 0;
|
||||
|
||||
@@ -485,6 +485,8 @@ public:
|
||||
return (uint64_t)(uintptr_t)&renderManager_;
|
||||
case NativeObject::NULL_IMAGEVIEW:
|
||||
return (uint64_t)GetNullTexture()->GetImageView();
|
||||
case NativeObject::TEXTURE_VIEW:
|
||||
return (uint64_t)(((VulkanTexture *)srcObject)->GetImageView());
|
||||
default:
|
||||
Crash();
|
||||
return 0;
|
||||
|
||||
+1
-1
@@ -246,7 +246,7 @@ enum class NativeObject {
|
||||
BOUND_TEXTURE0_IMAGEVIEW,
|
||||
BOUND_TEXTURE1_IMAGEVIEW,
|
||||
RENDER_MANAGER,
|
||||
TEXTURE,
|
||||
TEXTURE_VIEW,
|
||||
NULL_IMAGEVIEW,
|
||||
};
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "GPU/ge_constants.h"
|
||||
#include "GPU/GPUState.h"
|
||||
#include "GPU/Common/GPUStateUtils.h"
|
||||
#include "GPU/Common/DrawEngineCommon.h"
|
||||
#include "GPU/D3D11/TextureCacheD3D11.h"
|
||||
#include "GPU/D3D11/FramebufferManagerD3D11.h"
|
||||
#include "GPU/D3D11/ShaderManagerD3D11.h"
|
||||
@@ -250,6 +251,12 @@ void TextureCacheD3D11::Unbind() {
|
||||
InvalidateLastTexture();
|
||||
}
|
||||
|
||||
void TextureCacheD3D11::BindAsClutTexture(Draw::Texture *tex) {
|
||||
ID3D11ShaderResourceView *clutTexture = (ID3D11ShaderResourceView *)draw_->GetNativeObject(Draw::NativeObject::TEXTURE_VIEW, tex);
|
||||
context_->PSSetShaderResources(TEX_SLOT_CLUT, 1, &clutTexture);
|
||||
context_->PSSetSamplers(3, 1, &stockD3D11.samplerPoint2DWrap);
|
||||
}
|
||||
|
||||
class TextureShaderApplierD3D11 {
|
||||
public:
|
||||
struct Pos {
|
||||
@@ -407,7 +414,8 @@ void TextureCacheD3D11::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer,
|
||||
ID3D11ShaderResourceView *nullTexture = nullptr;
|
||||
context_->PSSetShaderResources(0, 1, &nullTexture); // In case the target was used in the last draw call. Happens in Sega Rally.
|
||||
draw_->BindFramebufferAsRenderTarget(depalFBO, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "ApplyTextureFramebuffer_DepalShader");
|
||||
context_->PSSetShaderResources(3, 1, &clutTexture);
|
||||
// BindAsClutTexture(clutTexture);
|
||||
context_->PSSetShaderResources(TEX_SLOT_CLUT, 1, &clutTexture);
|
||||
context_->PSSetSamplers(3, 1, &stockD3D11.samplerPoint2DWrap);
|
||||
draw_->BindFramebufferAsTexture(framebuffer->fbo, 0, depth ? Draw::FB_DEPTH_BIT : Draw::FB_COLOR_BIT, 0);
|
||||
context_->PSSetSamplers(0, 1, &stockD3D11.samplerPoint2DWrap);
|
||||
|
||||
@@ -65,6 +65,7 @@ protected:
|
||||
void BindTexture(TexCacheEntry *entry) override;
|
||||
void Unbind() override;
|
||||
void ReleaseTexture(TexCacheEntry *entry, bool delete_them) override;
|
||||
void BindAsClutTexture(Draw::Texture *tex) override;
|
||||
|
||||
private:
|
||||
DXGI_FORMAT GetDestFormat(GETextureFormat format, GEPaletteFormat clutFormat) const;
|
||||
|
||||
@@ -232,7 +232,7 @@ void TextureCacheGLES::Unbind() {
|
||||
}
|
||||
|
||||
void TextureCacheGLES::BindAsClutTexture(Draw::Texture *tex) {
|
||||
GLRTexture *glrTex = (GLRTexture *)draw_->GetNativeObject(Draw::NativeObject::TEXTURE, tex);
|
||||
GLRTexture *glrTex = (GLRTexture *)draw_->GetNativeObject(Draw::NativeObject::TEXTURE_VIEW, tex);
|
||||
render_->BindTexture(TEX_SLOT_CLUT, glrTex);
|
||||
render_->SetTextureSampler(TEX_SLOT_CLUT, GL_REPEAT, GL_CLAMP_TO_EDGE, GL_NEAREST, GL_NEAREST, 0.0f);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user