GE Debugger D3D11: Support displaying the current texture

This commit is contained in:
Henrik Rydgård
2017-03-06 16:46:15 +01:00
parent 07bfde357d
commit 90e0079c98
6 changed files with 54 additions and 4 deletions
+2
View File
@@ -206,6 +206,8 @@ public:
return PSP_CoreParameter().compat.flags().FakeMipmapChange && gstate.getTexLevelMode() == GE_TEXLEVEL_MODE_CONST;
}
virtual bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) { return false; }
protected:
virtual void BindTexture(TexCacheEntry *entry) = 0;
virtual void Unbind() = 0;
+1 -4
View File
@@ -1054,10 +1054,7 @@ bool GPU_D3D11::GetCurrentTexture(GPUDebugBuffer &buffer, int level) {
if (!gstate.isTextureMapEnabled()) {
return false;
}
// TODO: Implement!
return false;
return textureCacheD3D11_->GetCurrentTextureDebug(buffer, level);
}
bool GPU_D3D11::GetCurrentClut(GPUDebugBuffer &buffer) {
+45
View File
@@ -769,3 +769,48 @@ bool TextureCacheD3D11::DecodeTexture(u8 *output, const GPUgstate &state) {
OutputDebugStringA("TextureCache::DecodeTexture : FixMe\r\n");
return true;
}
bool TextureCacheD3D11::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) {
ApplyTexture();
SetTexture(false);
if (!nextTexture_)
return false;
ID3D11Texture2D *texture = (ID3D11Texture2D *)nextTexture_->texturePtr;
if (!texture)
return false;
D3D11_TEXTURE2D_DESC desc;
texture->GetDesc(&desc);
if (desc.Format != DXGI_FORMAT_B8G8R8A8_UNORM) {
// TODO: Support the other formats
return false;
}
desc.BindFlags = 0;
desc.Usage = D3D11_USAGE_STAGING;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
ID3D11Texture2D *stagingCopy = nullptr;
device_->CreateTexture2D(&desc, nullptr, &stagingCopy);
context_->CopyResource(stagingCopy, texture);
int width = desc.Width >> level;
int height = desc.Height >> level;
buffer.Allocate(width, height, GPU_DBG_FORMAT_8888);
D3D11_MAPPED_SUBRESOURCE map;
if (FAILED(context_->Map(stagingCopy, level, D3D11_MAP_READ, 0, &map))) {
stagingCopy->Release();
return false;
}
for (int y = 0; y < height; y++) {
memcpy(buffer.GetData() + 4 * width * y, (const uint8_t *)map.pData + map.RowPitch * y, 4 * width);
}
context_->Unmap(stagingCopy, level);
stagingCopy->Release();
return true;
}
+1
View File
@@ -64,6 +64,7 @@ public:
void InvalidateLastTexture(TexCacheEntry *entry = nullptr) override;
void SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHeight, SamplerCacheKey &key);
bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) override;
protected:
void BindTexture(TexCacheEntry *entry) override;
+4
View File
@@ -2149,3 +2149,7 @@ bool GPUCommon::GetCurrentStencilbuffer(GPUDebugBuffer &buffer) {
bool GPUCommon::GetOutputFramebuffer(GPUDebugBuffer &buffer) {
return framebufferManager_->GetOutputFramebuffer(buffer);
}
bool GPUCommon::GetCurrentTexture(GPUDebugBuffer &buffer, int level) {
return textureCache_->GetCurrentTextureDebug(buffer, level);
}
+1
View File
@@ -165,6 +165,7 @@ public:
bool GetCurrentFramebuffer(GPUDebugBuffer &buffer, GPUDebugFramebufferType type, int maxRes) override;
bool GetCurrentDepthbuffer(GPUDebugBuffer &buffer) override;
bool GetCurrentStencilbuffer(GPUDebugBuffer &buffer) override;
bool GetCurrentTexture(GPUDebugBuffer &buffer, int level) override;
bool GetOutputFramebuffer(GPUDebugBuffer &buffer) override;
std::vector<DisplayList> ActiveDisplayLists() override;