mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Work towards unifying ApplyTexture
This commit is contained in:
parent
665ffe34ab
commit
f839f1944e
10 changed files with 47 additions and 25 deletions
|
@ -179,6 +179,7 @@ public:
|
||||||
void Invalidate(u32 addr, int size, GPUInvalidationType type);
|
void Invalidate(u32 addr, int size, GPUInvalidationType type);
|
||||||
void InvalidateAll(GPUInvalidationType type);
|
void InvalidateAll(GPUInvalidationType type);
|
||||||
void ClearNextFrame();
|
void ClearNextFrame();
|
||||||
|
|
||||||
virtual void ForgetLastTexture() = 0;
|
virtual void ForgetLastTexture() = 0;
|
||||||
virtual void Clear(bool delete_them);
|
virtual void Clear(bool delete_them);
|
||||||
|
|
||||||
|
@ -198,6 +199,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual void BindTexture(TexCacheEntry *entry) = 0;
|
||||||
virtual void Unbind() = 0;
|
virtual void Unbind() = 0;
|
||||||
virtual void ReleaseTexture(TexCacheEntry *entry) = 0;
|
virtual void ReleaseTexture(TexCacheEntry *entry) = 0;
|
||||||
void DeleteTexture(TexCache::iterator it);
|
void DeleteTexture(TexCache::iterator it);
|
||||||
|
|
|
@ -312,6 +312,14 @@ void TextureCacheD3D11::UpdateCurrentClut(GEPaletteFormat clutFormat, u32 clutBa
|
||||||
clutLastFormat_ = gstate.clutformat;
|
clutLastFormat_ = gstate.clutformat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextureCacheD3D11::BindTexture(TexCacheEntry *entry) {
|
||||||
|
ID3D11ShaderResourceView *textureView = DxView(entry);
|
||||||
|
if (textureView != lastBoundTexture) {
|
||||||
|
context_->PSSetShaderResources(0, 1, &textureView);
|
||||||
|
lastBoundTexture = textureView;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TextureCacheD3D11::Unbind() {
|
void TextureCacheD3D11::Unbind() {
|
||||||
ID3D11ShaderResourceView *nullView = nullptr;
|
ID3D11ShaderResourceView *nullView = nullptr;
|
||||||
context_->PSSetShaderResources(0, 1, &nullView);
|
context_->PSSetShaderResources(0, 1, &nullView);
|
||||||
|
@ -363,11 +371,7 @@ void TextureCacheD3D11::ApplyTexture() {
|
||||||
if (entry->framebuffer) {
|
if (entry->framebuffer) {
|
||||||
ApplyTextureFramebuffer(entry, entry->framebuffer);
|
ApplyTextureFramebuffer(entry, entry->framebuffer);
|
||||||
} else {
|
} else {
|
||||||
ID3D11ShaderResourceView *textureView = DxView(entry);
|
BindTexture(entry);
|
||||||
if (textureView != lastBoundTexture) {
|
|
||||||
context_->PSSetShaderResources(0, 1, &textureView);
|
|
||||||
lastBoundTexture = textureView;
|
|
||||||
}
|
|
||||||
SamplerCacheKey key;
|
SamplerCacheKey key;
|
||||||
UpdateSamplingParams(*entry, key);
|
UpdateSamplingParams(*entry, key);
|
||||||
ID3D11SamplerState *state = samplerCache_.GetOrCreateSampler(device_, key);
|
ID3D11SamplerState *state = samplerCache_.GetOrCreateSampler(device_, key);
|
||||||
|
|
|
@ -68,6 +68,7 @@ public:
|
||||||
void ApplyTexture();
|
void ApplyTexture();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void BindTexture(TexCacheEntry *entry) override;
|
||||||
void Unbind() override;
|
void Unbind() override;
|
||||||
void ReleaseTexture(TexCacheEntry *entry) override;
|
void ReleaseTexture(TexCacheEntry *entry) override;
|
||||||
|
|
||||||
|
|
|
@ -332,6 +332,14 @@ void TextureCacheDX9::UpdateCurrentClut(GEPaletteFormat clutFormat, u32 clutBase
|
||||||
clutLastFormat_ = gstate.clutformat;
|
clutLastFormat_ = gstate.clutformat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextureCacheDX9::BindTexture(TexCacheEntry *entry) {
|
||||||
|
LPDIRECT3DTEXTURE9 texture = DxTex(entry);
|
||||||
|
if (texture != lastBoundTexture) {
|
||||||
|
pD3Ddevice->SetTexture(0, texture);
|
||||||
|
lastBoundTexture = texture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TextureCacheDX9::Unbind() {
|
void TextureCacheDX9::Unbind() {
|
||||||
pD3Ddevice->SetTexture(0, NULL);
|
pD3Ddevice->SetTexture(0, NULL);
|
||||||
}
|
}
|
||||||
|
@ -382,11 +390,7 @@ void TextureCacheDX9::ApplyTexture() {
|
||||||
if (entry->framebuffer) {
|
if (entry->framebuffer) {
|
||||||
ApplyTextureFramebuffer(entry, entry->framebuffer);
|
ApplyTextureFramebuffer(entry, entry->framebuffer);
|
||||||
} else {
|
} else {
|
||||||
LPDIRECT3DTEXTURE9 texture = DxTex(entry);
|
BindTexture(entry);
|
||||||
if (texture != lastBoundTexture) {
|
|
||||||
pD3Ddevice->SetTexture(0, texture);
|
|
||||||
lastBoundTexture = texture;
|
|
||||||
}
|
|
||||||
UpdateSamplingParams(*entry, false);
|
UpdateSamplingParams(*entry, false);
|
||||||
|
|
||||||
gstate_c.textureFullAlpha = entry->GetAlphaStatus() == TexCacheEntry::STATUS_ALPHA_FULL;
|
gstate_c.textureFullAlpha = entry->GetAlphaStatus() == TexCacheEntry::STATUS_ALPHA_FULL;
|
||||||
|
|
|
@ -61,6 +61,7 @@ public:
|
||||||
void ApplyTexture();
|
void ApplyTexture();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void BindTexture(TexCacheEntry *entry) override;
|
||||||
void Unbind() override;
|
void Unbind() override;
|
||||||
void ReleaseTexture(TexCacheEntry *entry) override;
|
void ReleaseTexture(TexCacheEntry *entry) override;
|
||||||
|
|
||||||
|
|
|
@ -385,6 +385,13 @@ bool SetDebugTexture() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void TextureCacheGLES::BindTexture(TexCacheEntry *entry) {
|
||||||
|
if (entry->textureName != lastBoundTexture) {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, entry->textureName);
|
||||||
|
lastBoundTexture = entry->textureName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void TextureCacheGLES::Unbind() {
|
void TextureCacheGLES::Unbind() {
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
}
|
}
|
||||||
|
@ -434,10 +441,7 @@ void TextureCacheGLES::ApplyTexture() {
|
||||||
if (entry->framebuffer) {
|
if (entry->framebuffer) {
|
||||||
ApplyTextureFramebuffer(entry, entry->framebuffer);
|
ApplyTextureFramebuffer(entry, entry->framebuffer);
|
||||||
} else {
|
} else {
|
||||||
if (entry->textureName != lastBoundTexture) {
|
BindTexture(entry);
|
||||||
glBindTexture(GL_TEXTURE_2D, entry->textureName);
|
|
||||||
lastBoundTexture = entry->textureName;
|
|
||||||
}
|
|
||||||
UpdateSamplingParams(*entry, false);
|
UpdateSamplingParams(*entry, false);
|
||||||
|
|
||||||
gstate_c.textureFullAlpha = entry->GetAlphaStatus() == TexCacheEntry::STATUS_ALPHA_FULL;
|
gstate_c.textureFullAlpha = entry->GetAlphaStatus() == TexCacheEntry::STATUS_ALPHA_FULL;
|
||||||
|
|
|
@ -77,6 +77,7 @@ public:
|
||||||
void ApplyTexture();
|
void ApplyTexture();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void BindTexture(TexCacheEntry *entry) override;
|
||||||
void Unbind() override;
|
void Unbind() override;
|
||||||
void ReleaseTexture(TexCacheEntry *entry) override;
|
void ReleaseTexture(TexCacheEntry *entry) override;
|
||||||
|
|
||||||
|
|
|
@ -668,7 +668,7 @@ void DrawEngineVulkan::DoFlush(VkCommandBuffer cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textureNeedsApply) {
|
if (textureNeedsApply) {
|
||||||
textureCache_->ApplyTexture(frame->pushUBO, imageView, sampler);
|
textureCache_->ApplyTexture(imageView, sampler);
|
||||||
if (imageView == VK_NULL_HANDLE)
|
if (imageView == VK_NULL_HANDLE)
|
||||||
imageView = nullTexture_->GetImageView();
|
imageView = nullTexture_->GetImageView();
|
||||||
if (sampler == VK_NULL_HANDLE)
|
if (sampler == VK_NULL_HANDLE)
|
||||||
|
@ -768,7 +768,7 @@ void DrawEngineVulkan::DoFlush(VkCommandBuffer cmd) {
|
||||||
// to use a "pre-clear" render pass, for high efficiency on tilers.
|
// to use a "pre-clear" render pass, for high efficiency on tilers.
|
||||||
if (result.action == SW_DRAW_PRIMITIVES) {
|
if (result.action == SW_DRAW_PRIMITIVES) {
|
||||||
if (textureNeedsApply) {
|
if (textureNeedsApply) {
|
||||||
textureCache_->ApplyTexture(frame->pushUBO, imageView, sampler);
|
textureCache_->ApplyTexture(imageView, sampler);
|
||||||
if (imageView == VK_NULL_HANDLE)
|
if (imageView == VK_NULL_HANDLE)
|
||||||
imageView = nullTexture_->GetImageView();
|
imageView = nullTexture_->GetImageView();
|
||||||
if (sampler == VK_NULL_HANDLE)
|
if (sampler == VK_NULL_HANDLE)
|
||||||
|
|
|
@ -397,10 +397,14 @@ void TextureCacheVulkan::UpdateCurrentClut(GEPaletteFormat clutFormat, u32 clutB
|
||||||
clutLastFormat_ = gstate.clutformat;
|
clutLastFormat_ = gstate.clutformat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextureCacheVulkan::BindTexture(TexCacheEntry *entry) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void TextureCacheVulkan::Unbind() {
|
void TextureCacheVulkan::Unbind() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCacheVulkan::ApplyTexture(VulkanPushBuffer *uploadBuffer, VkImageView &imageView, VkSampler &sampler) {
|
void TextureCacheVulkan::ApplyTexture(VkImageView &imageView, VkSampler &sampler) {
|
||||||
TexCacheEntry *entry = nextTexture_;
|
TexCacheEntry *entry = nextTexture_;
|
||||||
if (entry == nullptr) {
|
if (entry == nullptr) {
|
||||||
imageView = VK_NULL_HANDLE;
|
imageView = VK_NULL_HANDLE;
|
||||||
|
@ -440,7 +444,7 @@ void TextureCacheVulkan::ApplyTexture(VulkanPushBuffer *uploadBuffer, VkImageVie
|
||||||
|
|
||||||
// Okay, now actually rebuild the texture if needed.
|
// Okay, now actually rebuild the texture if needed.
|
||||||
if (nextNeedsRebuild_) {
|
if (nextNeedsRebuild_) {
|
||||||
BuildTexture(entry, uploadBuffer);
|
BuildTexture(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry->lastFrame = gpuStats.numFlips;
|
entry->lastFrame = gpuStats.numFlips;
|
||||||
|
@ -538,7 +542,7 @@ void TextureCacheVulkan::ApplyTextureFramebuffer(VkCommandBuffer cmd, TexCacheEn
|
||||||
uv[3] = UV(uvleft, uvtop);
|
uv[3] = UV(uvleft, uvtop);
|
||||||
}
|
}
|
||||||
|
|
||||||
shaderManager_->DirtyLastShader();
|
shaderManagerVulkan_->DirtyLastShader();
|
||||||
|
|
||||||
//depalFBO->EndPass(cmd);
|
//depalFBO->EndPass(cmd);
|
||||||
//depalFBO->TransitionToTexture(cmd);
|
//depalFBO->TransitionToTexture(cmd);
|
||||||
|
@ -901,7 +905,7 @@ bool TextureCacheVulkan::HandleTextureChange(TexCacheEntry *const entry, const c
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry, VulkanPushBuffer *uploadBuffer) {
|
void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry) {
|
||||||
entry->status &= ~TexCacheEntry::STATUS_ALPHA_MASK;
|
entry->status &= ~TexCacheEntry::STATUS_ALPHA_MASK;
|
||||||
|
|
||||||
// For the estimate, we assume cluts always point to 8888 for simplicity.
|
// For the estimate, we assume cluts always point to 8888 for simplicity.
|
||||||
|
@ -1079,7 +1083,7 @@ void TextureCacheVulkan::BuildTexture(TexCacheEntry *const entry, VulkanPushBuff
|
||||||
int size = stride * mipHeight;
|
int size = stride * mipHeight;
|
||||||
uint32_t bufferOffset;
|
uint32_t bufferOffset;
|
||||||
VkBuffer texBuf;
|
VkBuffer texBuf;
|
||||||
void *data = uploadBuffer->Push(size, &bufferOffset, &texBuf);
|
void *data = drawEngine_->GetPushBufferForTextureData()->Push(size, &bufferOffset, &texBuf);
|
||||||
if (replaced.Valid()) {
|
if (replaced.Valid()) {
|
||||||
replaced.Load(i, data, stride);
|
replaced.Load(i, data, stride);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
depalShaderCache_ = dpCache;
|
depalShaderCache_ = dpCache;
|
||||||
}
|
}
|
||||||
void SetShaderManager(ShaderManagerVulkan *sm) {
|
void SetShaderManager(ShaderManagerVulkan *sm) {
|
||||||
shaderManager_ = sm;
|
shaderManagerVulkan_ = sm;
|
||||||
}
|
}
|
||||||
void SetDrawEngine(DrawEngineVulkan *td) {
|
void SetDrawEngine(DrawEngineVulkan *td) {
|
||||||
drawEngine_ = td;
|
drawEngine_ = td;
|
||||||
|
@ -90,9 +90,10 @@ public:
|
||||||
gstate_c.Dirty(DIRTY_TEXTURE_PARAMS);
|
gstate_c.Dirty(DIRTY_TEXTURE_PARAMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyTexture(VulkanPushBuffer *uploadBuffer, VkImageView &imageView, VkSampler &sampler);
|
void ApplyTexture(VkImageView &imageView, VkSampler &sampler);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
void BindTexture(TexCacheEntry *entry) override;
|
||||||
void Unbind() override;
|
void Unbind() override;
|
||||||
void ReleaseTexture(TexCacheEntry *entry) override;
|
void ReleaseTexture(TexCacheEntry *entry) override;
|
||||||
|
|
||||||
|
@ -109,7 +110,7 @@ private:
|
||||||
|
|
||||||
bool CheckFullHash(TexCacheEntry *const entry, bool &doDelete);
|
bool CheckFullHash(TexCacheEntry *const entry, bool &doDelete);
|
||||||
bool HandleTextureChange(TexCacheEntry *const entry, const char *reason, bool initialMatch, bool doDelete);
|
bool HandleTextureChange(TexCacheEntry *const entry, const char *reason, bool initialMatch, bool doDelete);
|
||||||
void BuildTexture(TexCacheEntry *const entry, VulkanPushBuffer *uploadBuffer);
|
void BuildTexture(TexCacheEntry *const entry);
|
||||||
|
|
||||||
VulkanContext *vulkan_;
|
VulkanContext *vulkan_;
|
||||||
VulkanDeviceAllocator *allocator_;
|
VulkanDeviceAllocator *allocator_;
|
||||||
|
@ -126,7 +127,7 @@ private:
|
||||||
|
|
||||||
FramebufferManagerVulkan *framebufferManagerVulkan_;
|
FramebufferManagerVulkan *framebufferManagerVulkan_;
|
||||||
DepalShaderCacheVulkan *depalShaderCache_;
|
DepalShaderCacheVulkan *depalShaderCache_;
|
||||||
ShaderManagerVulkan *shaderManager_;
|
ShaderManagerVulkan *shaderManagerVulkan_;
|
||||||
DrawEngineVulkan *drawEngine_;
|
DrawEngineVulkan *drawEngine_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue