mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-27 15:30:35 +00:00
Cleanup in FramebufferVulkan to reduce the size of future diffs
This commit is contained in:
parent
0a8d74728a
commit
40d05e292c
@ -37,11 +37,19 @@ public:
|
||||
int GetNumMips() const { return numMips_; }
|
||||
void Destroy();
|
||||
|
||||
// Used in image copies, etc.
|
||||
VkImage GetImage() const { return image; }
|
||||
|
||||
// Used for sampling, generally.
|
||||
VkImageView GetImageView() const { return view; }
|
||||
|
||||
int32_t GetWidth() const { return tex_width; }
|
||||
int32_t GetHeight() const { return tex_height; }
|
||||
|
||||
private:
|
||||
void CreateMappableImage();
|
||||
void Wipe();
|
||||
|
||||
VulkanContext *vulkan_;
|
||||
VkImage image;
|
||||
VkDeviceMemory mem;
|
||||
@ -51,7 +59,7 @@ private:
|
||||
VkImage mappableImage;
|
||||
VkDeviceMemory mappableMemory;
|
||||
VkMemoryRequirements mem_reqs;
|
||||
bool needStaging;
|
||||
VulkanDeviceAllocator *allocator_;
|
||||
size_t offset_;
|
||||
bool needStaging;
|
||||
};
|
||||
|
@ -175,7 +175,6 @@ public:
|
||||
|
||||
virtual void ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool sync, int x, int y, int w, int h) = 0;
|
||||
virtual void DownloadFramebufferForClut(u32 fb_address, u32 loadBytes) = 0;
|
||||
virtual void MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) = 0;
|
||||
virtual void DrawPixels(VirtualFramebuffer *vfb, int dstX, int dstY, const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) = 0;
|
||||
virtual void DrawFramebufferToOutput(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, bool applyPostShader) = 0;
|
||||
|
||||
|
@ -55,7 +55,6 @@ public:
|
||||
transformDraw_ = td;
|
||||
}
|
||||
|
||||
virtual void MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) override;
|
||||
virtual void DrawPixels(VirtualFramebuffer *vfb, int dstX, int dstY, const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) override;
|
||||
virtual void DrawFramebufferToOutput(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, bool applyPostShader) override;
|
||||
|
||||
@ -109,6 +108,7 @@ protected:
|
||||
virtual void UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) override;
|
||||
|
||||
private:
|
||||
void MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height);
|
||||
void CompileDraw2DProgram();
|
||||
void DestroyDraw2DProgram();
|
||||
|
||||
|
@ -75,7 +75,6 @@ public:
|
||||
transformDraw_ = td;
|
||||
}
|
||||
|
||||
void MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) override;
|
||||
void DrawPixels(VirtualFramebuffer *vfb, int dstX, int dstY, const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) override;
|
||||
void DrawFramebufferToOutput(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, bool applyPostShader) override;
|
||||
|
||||
@ -137,6 +136,7 @@ protected:
|
||||
virtual void UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) override;
|
||||
|
||||
private:
|
||||
void MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height);
|
||||
void UpdatePostShaderUniforms(int bufferWidth, int bufferHeight, int renderWidth, int renderHeight);
|
||||
void CompileDraw2DProgram();
|
||||
void DestroyDraw2DProgram();
|
||||
|
@ -555,6 +555,28 @@ void DrawEngineVulkan::DirtyAllUBOs() {
|
||||
gstate_c.textureChanged = TEXCHANGE_UPDATED;
|
||||
}
|
||||
|
||||
//void DrawEngineVulkan::ApplyDrawStateLate() {
|
||||
/*
|
||||
// At this point, we know if the vertices are full alpha or not.
|
||||
// TODO: Set the nearest/linear here (since we correctly know if alpha/color tests are needed)?
|
||||
if (!gstate.isModeClear()) {
|
||||
// TODO: Test texture?
|
||||
|
||||
textureCache_->ApplyTexture();
|
||||
|
||||
if (fboTexNeedBind_) {
|
||||
// Note that this is positions, not UVs, that we need the copy from.
|
||||
framebufferManager_->BindFramebufferColor(1, nullptr, BINDFBCOLOR_MAY_COPY);
|
||||
// If we are rendering at a higher resolution, linear is probably best for the dest color.
|
||||
pD3Ddevice->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||
pD3Ddevice->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||
fboTexBound_ = true;
|
||||
fboTexNeedBind_ = false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
//}
|
||||
|
||||
// The inline wrapper in the header checks for numDrawCalls == 0d
|
||||
void DrawEngineVulkan::DoFlush(VkCommandBuffer cmd) {
|
||||
gpuStats.numFlushes++;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -43,6 +43,12 @@ struct PostShaderUniforms {
|
||||
float time[4];
|
||||
};
|
||||
|
||||
static const char *ub_post_shader =
|
||||
R"( vec2 texelDelta;
|
||||
vec2 pixelDelta;
|
||||
vec4 time;
|
||||
)";
|
||||
|
||||
// Simple struct for asynchronous PBO readbacks
|
||||
// TODO: Probably will need a complete redesign.
|
||||
struct AsyncPBOVulkan {
|
||||
@ -81,7 +87,6 @@ public:
|
||||
transformDraw_ = td;
|
||||
}
|
||||
|
||||
void MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) override;
|
||||
void DrawPixels(VirtualFramebuffer *vfb, int dstX, int dstY, const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) override;
|
||||
void DrawFramebufferToOutput(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, bool applyPostShader) override;
|
||||
|
||||
@ -144,13 +149,10 @@ protected:
|
||||
|
||||
|
||||
private:
|
||||
void MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height);
|
||||
void UpdatePostShaderUniforms(int bufferWidth, int bufferHeight, int renderWidth, int renderHeight);
|
||||
void CompileDraw2DProgram();
|
||||
void DestroyDraw2DProgram();
|
||||
|
||||
void SetNumExtraFBOs(int num);
|
||||
|
||||
void PackFramebufferAsync_(VirtualFramebuffer *vfb); // Not used under ES currently
|
||||
void PackFramebufferAsync_(VirtualFramebuffer *vfb);
|
||||
void PackFramebufferSync_(VirtualFramebuffer *vfb, int x, int y, int w, int h);
|
||||
|
||||
VulkanContext *vulkan_;
|
||||
@ -166,9 +168,6 @@ private:
|
||||
VulkanTexture *drawPixelsTex_;
|
||||
GEBufferFormat drawPixelsTexFormat_;
|
||||
|
||||
int drawPixelsTexW_;
|
||||
int drawPixelsTexH_;
|
||||
|
||||
u8 *convBuf_;
|
||||
u32 convBufSize_;
|
||||
|
||||
@ -176,9 +175,6 @@ private:
|
||||
ShaderManagerVulkan *shaderManager_;
|
||||
DrawEngineVulkan *transformDraw_;
|
||||
|
||||
// Used by post-processing shader
|
||||
std::vector<FBO *> extraFBOs_;
|
||||
|
||||
bool resized_;
|
||||
|
||||
struct TempFBO {
|
||||
|
@ -326,25 +326,3 @@ void ConvertStateToVulkanKey(FramebufferManagerVulkan &fbManager, ShaderManagerV
|
||||
shaderManager->DirtyUniform(DIRTY_DEPTHRANGE);
|
||||
}
|
||||
}
|
||||
|
||||
//void DrawEngineVulkan::ApplyDrawStateLate() {
|
||||
/*
|
||||
// At this point, we know if the vertices are full alpha or not.
|
||||
// TODO: Set the nearest/linear here (since we correctly know if alpha/color tests are needed)?
|
||||
if (!gstate.isModeClear()) {
|
||||
// TODO: Test texture?
|
||||
|
||||
textureCache_->ApplyTexture();
|
||||
|
||||
if (fboTexNeedBind_) {
|
||||
// Note that this is positions, not UVs, that we need the copy from.
|
||||
framebufferManager_->BindFramebufferColor(1, nullptr, BINDFBCOLOR_MAY_COPY);
|
||||
// If we are rendering at a higher resolution, linear is probably best for the dest color.
|
||||
pD3Ddevice->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
|
||||
pD3Ddevice->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||
fboTexBound_ = true;
|
||||
fboTexNeedBind_ = false;
|
||||
}
|
||||
}
|
||||
*/
|
||||
//}
|
||||
|
@ -643,48 +643,6 @@ inline u32 TextureCacheVulkan::GetCurrentClutHash() {
|
||||
return clutHash_;
|
||||
}
|
||||
|
||||
// #define DEBUG_TEXTURES
|
||||
|
||||
#ifdef DEBUG_TEXTURES
|
||||
bool SetDebugTexture() {
|
||||
static const int highlightFrames = 30;
|
||||
|
||||
static int numTextures = 0;
|
||||
static int lastFrames = 0;
|
||||
static int mostTextures = 1;
|
||||
|
||||
if (lastFrames != gpuStats.numFlips) {
|
||||
mostTextures = std::max(mostTextures, numTextures);
|
||||
numTextures = 0;
|
||||
lastFrames = gpuStats.numFlips;
|
||||
}
|
||||
|
||||
static GLuint solidTexture = 0;
|
||||
|
||||
bool changed = false;
|
||||
if (((gpuStats.numFlips / highlightFrames) % mostTextures) == numTextures) {
|
||||
if (gpuStats.numFlips % highlightFrames == 0) {
|
||||
NOTICE_LOG(G3D, "Highlighting texture # %d / %d", numTextures, mostTextures);
|
||||
}
|
||||
static const u32 solidTextureData[] = { 0x99AA99FF };
|
||||
|
||||
if (solidTexture == 0) {
|
||||
glGenTextures(1, &solidTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, solidTexture);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, solidTextureData);
|
||||
} else {
|
||||
glBindTexture(GL_TEXTURE_2D, solidTexture);
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
|
||||
++numTextures;
|
||||
return changed;
|
||||
}
|
||||
#endif
|
||||
|
||||
void TextureCacheVulkan::SetTextureFramebuffer(TexCacheEntry *entry, VirtualFramebuffer *framebuffer) {
|
||||
_dbg_assert_msg_(G3D, framebuffer != nullptr, "Framebuffer must not be null.");
|
||||
|
||||
@ -858,51 +816,6 @@ void TextureCacheVulkan::ApplyTextureFramebuffer(VkCommandBuffer cmd, TexCacheEn
|
||||
|
||||
shaderManager_->DirtyLastShader();
|
||||
|
||||
/*
|
||||
glUseProgram(depal->program);
|
||||
|
||||
// Restore will rebind all of the state below.
|
||||
if (gstate_c.Supports(GPU_SUPPORTS_VAO)) {
|
||||
transformDraw_->BindBuffer(pos, sizeof(pos), uv, sizeof(uv));
|
||||
transformDraw_->BindElementBuffer(indices, sizeof(indices));
|
||||
} else {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
}
|
||||
glEnableVertexAttribArray(depal->a_position);
|
||||
glEnableVertexAttribArray(depal->a_texcoord0);
|
||||
|
||||
glActiveTexture(GL_TEXTURE3);
|
||||
glBindTexture(GL_TEXTURE_2D, clutTexture);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
|
||||
framebufferManager_->BindFramebufferColor(GL_TEXTURE0, gstate.getFrameBufRawAddress(), framebuffer, BINDFBCOLOR_SKIP_COPY);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
|
||||
glstate.blend.force(false);
|
||||
glstate.colorMask.force(true, true, true, true);
|
||||
glstate.scissorTest.force(false);
|
||||
glstate.cullFace.force(false);
|
||||
glstate.depthTest.force(false);
|
||||
glstate.stencilTest.force(false);
|
||||
#if !defined(USING_GLES2)
|
||||
glstate.colorLogicOp.force(false);
|
||||
#endif
|
||||
glViewport(0, 0, framebuffer->renderWidth, framebuffer->renderHeight);
|
||||
|
||||
if (gstate_c.Supports(GPU_SUPPORTS_VAO)) {
|
||||
glVertexAttribPointer(depal->a_position, 3, GL_FLOAT, GL_FALSE, 12, 0);
|
||||
glVertexAttribPointer(depal->a_texcoord0, 2, GL_FLOAT, GL_FALSE, 8, (void *)sizeof(pos));
|
||||
glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, 0);
|
||||
} else {
|
||||
glVertexAttribPointer(depal->a_position, 3, GL_FLOAT, GL_FALSE, 12, pos);
|
||||
glVertexAttribPointer(depal->a_texcoord0, 2, GL_FLOAT, GL_FALSE, 8, uv);
|
||||
glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, indices);
|
||||
}
|
||||
glDisableVertexAttribArray(depal->a_position);
|
||||
glDisableVertexAttribArray(depal->a_texcoord0);
|
||||
*/
|
||||
//depalFBO->EndPass(cmd);
|
||||
//depalFBO->TransitionToTexture(cmd);
|
||||
//imageView = depalFBO->GetColorImageView();
|
||||
|
Loading…
Reference in New Issue
Block a user