Add way to bind cached textures to a DrawContext
This commit is contained in:
parent
f745e94899
commit
abd58199ce
10 changed files with 33 additions and 6 deletions
|
@ -2163,7 +2163,7 @@ void TextureCacheCommon::ApplyTextureDepal(TexCacheEntry *entry) {
|
||||||
Draw::Viewport vp{ 0.0f, 0.0f, (float)texWidth, (float)texHeight, 0.0f, 1.0f };
|
Draw::Viewport vp{ 0.0f, 0.0f, (float)texWidth, (float)texHeight, 0.0f, 1.0f };
|
||||||
draw_->SetViewports(1, &vp);
|
draw_->SetViewports(1, &vp);
|
||||||
|
|
||||||
draw_->BindNativeTexture(0, framebuffer->fbo);
|
draw_->BindNativeTexture(0, GetNativeTextureView(entry));
|
||||||
draw_->BindFramebufferAsTexture(clutFbo, 1, Draw::FB_COLOR_BIT, 0);
|
draw_->BindFramebufferAsTexture(clutFbo, 1, Draw::FB_COLOR_BIT, 0);
|
||||||
Draw::SamplerState *nearest = textureShaderCache_->GetSampler(false);
|
Draw::SamplerState *nearest = textureShaderCache_->GetSampler(false);
|
||||||
Draw::SamplerState *clutSampler = textureShaderCache_->GetSampler(false);
|
Draw::SamplerState *clutSampler = textureShaderCache_->GetSampler(false);
|
||||||
|
@ -2185,8 +2185,8 @@ void TextureCacheCommon::ApplyTextureDepal(TexCacheEntry *entry) {
|
||||||
const u32 bytesPerColor = clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16);
|
const u32 bytesPerColor = clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16);
|
||||||
const u32 clutTotalColors = clutMaxBytes_ / bytesPerColor;
|
const u32 clutTotalColors = clutMaxBytes_ / bytesPerColor;
|
||||||
|
|
||||||
CheckAlphaResult alphaStatus = CheckCLUTAlpha((const uint8_t *)clutBufRaw_, clutFormat, clutTotalColors);
|
// We don't know about alpha at all.
|
||||||
gstate_c.SetTextureFullAlpha(alphaStatus == CHECKALPHA_FULL);
|
gstate_c.SetTextureFullAlpha(false);
|
||||||
|
|
||||||
draw_->InvalidateCachedState();
|
draw_->InvalidateCachedState();
|
||||||
shaderManager_->DirtyLastShader();
|
shaderManager_->DirtyLastShader();
|
||||||
|
|
|
@ -108,6 +108,8 @@ struct TextureDefinition {
|
||||||
|
|
||||||
// NOTE: These only handle textures loaded directly from PSP memory contents.
|
// NOTE: These only handle textures loaded directly from PSP memory contents.
|
||||||
// Framebuffer textures do not have entries, we bind the framebuffers directly.
|
// Framebuffer textures do not have entries, we bind the framebuffers directly.
|
||||||
|
// At one point we might merge the concepts of framebuffers and textures, but that
|
||||||
|
// moment is far away.
|
||||||
struct TexCacheEntry {
|
struct TexCacheEntry {
|
||||||
~TexCacheEntry() {
|
~TexCacheEntry() {
|
||||||
if (texturePtr || textureName || vkTex)
|
if (texturePtr || textureName || vkTex)
|
||||||
|
@ -345,6 +347,7 @@ public:
|
||||||
virtual bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) { return false; }
|
virtual bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual void *GetNativeTextureView(const TexCacheEntry *entry) = 0;
|
||||||
bool PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEntry *entry);
|
bool PrepareBuildTexture(BuildTexturePlan &plan, TexCacheEntry *entry);
|
||||||
|
|
||||||
virtual void BindTexture(TexCacheEntry *entry) = 0;
|
virtual void BindTexture(TexCacheEntry *entry) = 0;
|
||||||
|
|
|
@ -525,3 +525,8 @@ bool TextureCacheD3D11::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level
|
||||||
stagingCopy->Release();
|
stagingCopy->Release();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *TextureCacheD3D11::GetNativeTextureView(const TexCacheEntry *entry) {
|
||||||
|
ID3D11ShaderResourceView *textureView = DxView(entry);
|
||||||
|
return (void *)textureView;
|
||||||
|
}
|
||||||
|
|
|
@ -61,6 +61,7 @@ protected:
|
||||||
void ReleaseTexture(TexCacheEntry *entry, bool delete_them) override;
|
void ReleaseTexture(TexCacheEntry *entry, bool delete_them) override;
|
||||||
void BindAsClutTexture(Draw::Texture *tex, bool smooth) override;
|
void BindAsClutTexture(Draw::Texture *tex, bool smooth) override;
|
||||||
void ApplySamplingParams(const SamplerCacheKey &key) override;
|
void ApplySamplingParams(const SamplerCacheKey &key) override;
|
||||||
|
void *GetNativeTextureView(const TexCacheEntry *entry) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DXGI_FORMAT GetDestFormat(GETextureFormat format, GEPaletteFormat clutFormat) const;
|
DXGI_FORMAT GetDestFormat(GETextureFormat format, GEPaletteFormat clutFormat) const;
|
||||||
|
@ -72,10 +73,10 @@ private:
|
||||||
ID3D11Device *device_;
|
ID3D11Device *device_;
|
||||||
ID3D11DeviceContext *context_;
|
ID3D11DeviceContext *context_;
|
||||||
|
|
||||||
ID3D11Resource *&DxTex(TexCacheEntry *entry) {
|
ID3D11Resource *&DxTex(const TexCacheEntry *entry) {
|
||||||
return (ID3D11Resource *&)entry->texturePtr;
|
return (ID3D11Resource *&)entry->texturePtr;
|
||||||
}
|
}
|
||||||
ID3D11ShaderResourceView *DxView(TexCacheEntry *entry) {
|
ID3D11ShaderResourceView *DxView(const TexCacheEntry *entry) {
|
||||||
return (ID3D11ShaderResourceView *)entry->textureView;
|
return (ID3D11ShaderResourceView *)entry->textureView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -454,3 +454,8 @@ bool TextureCacheDX9::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level)
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *TextureCacheDX9::GetNativeTextureView(const TexCacheEntry *entry) {
|
||||||
|
LPDIRECT3DBASETEXTURE9 tex = DxTex(entry);
|
||||||
|
return (void *)tex;
|
||||||
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ protected:
|
||||||
void Unbind() override;
|
void Unbind() override;
|
||||||
void ReleaseTexture(TexCacheEntry *entry, bool delete_them) override;
|
void ReleaseTexture(TexCacheEntry *entry, bool delete_them) override;
|
||||||
void BindAsClutTexture(Draw::Texture *tex, bool smooth) override;
|
void BindAsClutTexture(Draw::Texture *tex, bool smooth) override;
|
||||||
|
void *GetNativeTextureView(const TexCacheEntry *entry) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ApplySamplingParams(const SamplerCacheKey &key) override;
|
void ApplySamplingParams(const SamplerCacheKey &key) override;
|
||||||
|
@ -60,7 +61,7 @@ private:
|
||||||
|
|
||||||
void BuildTexture(TexCacheEntry *const entry) override;
|
void BuildTexture(TexCacheEntry *const entry) override;
|
||||||
|
|
||||||
LPDIRECT3DBASETEXTURE9 &DxTex(TexCacheEntry *entry) {
|
LPDIRECT3DBASETEXTURE9 &DxTex(const TexCacheEntry *entry) const {
|
||||||
return *(LPDIRECT3DBASETEXTURE9 *)&entry->texturePtr;
|
return *(LPDIRECT3DBASETEXTURE9 *)&entry->texturePtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -443,3 +443,8 @@ void TextureCacheGLES::DeviceRestore(Draw::DrawContext *draw) {
|
||||||
render_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
render_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||||
textureShaderCache_->DeviceRestore(draw);
|
textureShaderCache_->DeviceRestore(draw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *TextureCacheGLES::GetNativeTextureView(const TexCacheEntry *entry) {
|
||||||
|
GLRTexture *tex = entry->textureName;
|
||||||
|
return (void *)tex;
|
||||||
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@ protected:
|
||||||
void ReleaseTexture(TexCacheEntry *entry, bool delete_them) override;
|
void ReleaseTexture(TexCacheEntry *entry, bool delete_them) override;
|
||||||
|
|
||||||
void BindAsClutTexture(Draw::Texture *tex, bool smooth) override;
|
void BindAsClutTexture(Draw::Texture *tex, bool smooth) override;
|
||||||
|
void *GetNativeTextureView(const TexCacheEntry *entry) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ApplySamplingParams(const SamplerCacheKey &key) override;
|
void ApplySamplingParams(const SamplerCacheKey &key) override;
|
||||||
|
|
|
@ -857,3 +857,8 @@ std::vector<std::string> TextureCacheVulkan::DebugGetSamplerIDs() const {
|
||||||
std::string TextureCacheVulkan::DebugGetSamplerString(std::string id, DebugShaderStringType stringType) {
|
std::string TextureCacheVulkan::DebugGetSamplerString(std::string id, DebugShaderStringType stringType) {
|
||||||
return samplerCache_.DebugGetSamplerString(id, stringType);
|
return samplerCache_.DebugGetSamplerString(id, stringType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *TextureCacheVulkan::GetNativeTextureView(const TexCacheEntry *entry) {
|
||||||
|
VkImageView view = entry->vkTex->GetImageView();
|
||||||
|
return (void *)view;
|
||||||
|
}
|
||||||
|
|
|
@ -97,6 +97,7 @@ protected:
|
||||||
void BindAsClutTexture(Draw::Texture *tex, bool smooth) override;
|
void BindAsClutTexture(Draw::Texture *tex, bool smooth) override;
|
||||||
void ApplySamplingParams(const SamplerCacheKey &key) override;
|
void ApplySamplingParams(const SamplerCacheKey &key) override;
|
||||||
void BoundFramebufferTexture() override;
|
void BoundFramebufferTexture() override;
|
||||||
|
void *GetNativeTextureView(const TexCacheEntry *entry) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePtr, int rowPitch, int level, int scaleFactor, VkFormat dstFmt);
|
void LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePtr, int rowPitch, int level, int scaleFactor, VkFormat dstFmt);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue