Start porting TextureCache. Lots of stubbing going on.
This commit is contained in:
parent
5216a24590
commit
cfcfd406fc
18 changed files with 2129 additions and 14 deletions
|
@ -27,7 +27,7 @@
|
||||||
#define WRITE p+=sprintf
|
#define WRITE p+=sprintf
|
||||||
|
|
||||||
// Uses integer instructions available since OpenGL 3.0. Suitable for ES 3.0 as well.
|
// Uses integer instructions available since OpenGL 3.0. Suitable for ES 3.0 as well.
|
||||||
void GenerateDepalShader300(char *buffer, GEBufferFormat pixelFormat) {
|
void GenerateDepalShader300(char *buffer, GEBufferFormat pixelFormat, ShaderLanguage language) {
|
||||||
char *p = buffer;
|
char *p = buffer;
|
||||||
if (gl_extensions.IsGLES) {
|
if (gl_extensions.IsGLES) {
|
||||||
WRITE(p, "#version 300 es\n");
|
WRITE(p, "#version 300 es\n");
|
||||||
|
@ -250,7 +250,8 @@ void GenerateDepalShader(char *buffer, GEBufferFormat pixelFormat, ShaderLanguag
|
||||||
GenerateDepalShaderFloat(buffer, pixelFormat, language);
|
GenerateDepalShaderFloat(buffer, pixelFormat, language);
|
||||||
break;
|
break;
|
||||||
case GLSL_300:
|
case GLSL_300:
|
||||||
GenerateDepalShader300(buffer, pixelFormat);
|
case GLSL_VULKAN:
|
||||||
|
GenerateDepalShader300(buffer, pixelFormat, language);
|
||||||
break;
|
break;
|
||||||
case HLSL_DX9:
|
case HLSL_DX9:
|
||||||
GenerateDepalShaderFloat(buffer, pixelFormat, language);
|
GenerateDepalShaderFloat(buffer, pixelFormat, language);
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
enum ShaderLanguage {
|
enum ShaderLanguage {
|
||||||
GLSL_140,
|
GLSL_140,
|
||||||
GLSL_300,
|
GLSL_300,
|
||||||
|
GLSL_VULKAN,
|
||||||
HLSL_DX9,
|
HLSL_DX9,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,8 @@ namespace DX9 {
|
||||||
struct FBO_DX9;
|
struct FBO_DX9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class VulkanFramebuffer;
|
||||||
|
|
||||||
struct VirtualFramebuffer {
|
struct VirtualFramebuffer {
|
||||||
int last_frame_used;
|
int last_frame_used;
|
||||||
int last_frame_attached;
|
int last_frame_attached;
|
||||||
|
@ -90,6 +92,7 @@ struct VirtualFramebuffer {
|
||||||
union {
|
union {
|
||||||
FBO *fbo;
|
FBO *fbo;
|
||||||
DX9::FBO_DX9 *fbo_dx9;
|
DX9::FBO_DX9 *fbo_dx9;
|
||||||
|
VulkanFramebuffer *fbo_vk;
|
||||||
};
|
};
|
||||||
|
|
||||||
u16 drawnWidth;
|
u16 drawnWidth;
|
||||||
|
|
|
@ -39,6 +39,8 @@ enum FramebufferNotification {
|
||||||
|
|
||||||
struct VirtualFramebuffer;
|
struct VirtualFramebuffer;
|
||||||
|
|
||||||
|
class CachedTextureVulkan;
|
||||||
|
|
||||||
class TextureCacheCommon {
|
class TextureCacheCommon {
|
||||||
public:
|
public:
|
||||||
TextureCacheCommon();
|
TextureCacheCommon();
|
||||||
|
@ -96,6 +98,7 @@ public:
|
||||||
union {
|
union {
|
||||||
u32 textureName;
|
u32 textureName;
|
||||||
void *texturePtr;
|
void *texturePtr;
|
||||||
|
CachedTextureVulkan *vkTex;
|
||||||
};
|
};
|
||||||
int invalidHint;
|
int invalidHint;
|
||||||
u32 fullhash;
|
u32 fullhash;
|
||||||
|
|
|
@ -244,6 +244,7 @@
|
||||||
<ClInclude Include="Software\SoftGpu.h" />
|
<ClInclude Include="Software\SoftGpu.h" />
|
||||||
<ClInclude Include="Software\TransformUnit.h" />
|
<ClInclude Include="Software\TransformUnit.h" />
|
||||||
<ClInclude Include="Common\TextureDecoder.h" />
|
<ClInclude Include="Common\TextureDecoder.h" />
|
||||||
|
<ClInclude Include="Vulkan\DepalettizeShaderVulkan.h" />
|
||||||
<ClInclude Include="Vulkan\DrawEngineVulkan.h" />
|
<ClInclude Include="Vulkan\DrawEngineVulkan.h" />
|
||||||
<ClInclude Include="Vulkan\FragmentShaderGeneratorVulkan.h" />
|
<ClInclude Include="Vulkan\FragmentShaderGeneratorVulkan.h" />
|
||||||
<ClInclude Include="Vulkan\FramebufferVulkan.h" />
|
<ClInclude Include="Vulkan\FramebufferVulkan.h" />
|
||||||
|
@ -251,6 +252,7 @@
|
||||||
<ClInclude Include="Vulkan\PipelineManagerVulkan.h" />
|
<ClInclude Include="Vulkan\PipelineManagerVulkan.h" />
|
||||||
<ClInclude Include="Vulkan\ShaderManagerVulkan.h" />
|
<ClInclude Include="Vulkan\ShaderManagerVulkan.h" />
|
||||||
<ClInclude Include="Vulkan\TextureCacheVulkan.h" />
|
<ClInclude Include="Vulkan\TextureCacheVulkan.h" />
|
||||||
|
<ClInclude Include="Vulkan\TextureScalerVulkan.h" />
|
||||||
<ClInclude Include="Vulkan\VertexShaderGeneratorVulkan.h" />
|
<ClInclude Include="Vulkan\VertexShaderGeneratorVulkan.h" />
|
||||||
<ClInclude Include="Vulkan\VulkanUtil.h" />
|
<ClInclude Include="Vulkan\VulkanUtil.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -339,6 +341,7 @@
|
||||||
<ClCompile Include="Vulkan\ShaderManagerVulkan.cpp" />
|
<ClCompile Include="Vulkan\ShaderManagerVulkan.cpp" />
|
||||||
<ClCompile Include="Vulkan\StateMappingVulkan.cpp" />
|
<ClCompile Include="Vulkan\StateMappingVulkan.cpp" />
|
||||||
<ClCompile Include="Vulkan\TextureCacheVulkan.cpp" />
|
<ClCompile Include="Vulkan\TextureCacheVulkan.cpp" />
|
||||||
|
<ClCompile Include="Vulkan\TextureScalerVulkan.cpp" />
|
||||||
<ClCompile Include="Vulkan\VertexShaderGeneratorVulkan.cpp" />
|
<ClCompile Include="Vulkan\VertexShaderGeneratorVulkan.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -210,6 +210,8 @@
|
||||||
<ClInclude Include="Vulkan\VertexShaderGeneratorVulkan.h" />
|
<ClInclude Include="Vulkan\VertexShaderGeneratorVulkan.h" />
|
||||||
<ClInclude Include="Vulkan\FragmentShaderGeneratorVulkan.h" />
|
<ClInclude Include="Vulkan\FragmentShaderGeneratorVulkan.h" />
|
||||||
<ClInclude Include="Vulkan\ShaderManagerVulkan.h" />
|
<ClInclude Include="Vulkan\ShaderManagerVulkan.h" />
|
||||||
|
<ClInclude Include="Vulkan\TextureScalerVulkan.h" />
|
||||||
|
<ClInclude Include="Vulkan\DepalettizeShaderVulkan.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Math3D.cpp">
|
<ClCompile Include="Math3D.cpp">
|
||||||
|
@ -404,5 +406,6 @@
|
||||||
<ClCompile Include="Vulkan\FragmentShaderGeneratorVulkan.cpp" />
|
<ClCompile Include="Vulkan\FragmentShaderGeneratorVulkan.cpp" />
|
||||||
<ClCompile Include="Vulkan\ShaderManagerVulkan.cpp" />
|
<ClCompile Include="Vulkan\ShaderManagerVulkan.cpp" />
|
||||||
<ClCompile Include="Vulkan\TextureCacheVulkan.cpp" />
|
<ClCompile Include="Vulkan\TextureCacheVulkan.cpp" />
|
||||||
|
<ClCompile Include="Vulkan\TextureScalerVulkan.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
61
GPU/Vulkan/DepalettizeShaderVulkan.h
Normal file
61
GPU/Vulkan/DepalettizeShaderVulkan.h
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
#pragma once
|
||||||
|
// Copyright (c) 2014- PPSSPP Project.
|
||||||
|
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, version 2.0 or later versions.
|
||||||
|
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License 2.0 for more details.
|
||||||
|
|
||||||
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
|
// If not, see http://www.gnu.org/licenses/
|
||||||
|
|
||||||
|
// Official git repository and contact information can be found at
|
||||||
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
#include "Common/CommonTypes.h"
|
||||||
|
#include "GPU/ge_constants.h"
|
||||||
|
|
||||||
|
class DepalShader {
|
||||||
|
public:
|
||||||
|
/*
|
||||||
|
GLuint program;
|
||||||
|
GLuint fragShader;
|
||||||
|
GLint a_position;
|
||||||
|
GLint a_texcoord0;
|
||||||
|
*/
|
||||||
|
};
|
||||||
|
|
||||||
|
class DepalTexture {
|
||||||
|
public:
|
||||||
|
int texture;
|
||||||
|
int lastFrame;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Caches both shaders and palette textures.
|
||||||
|
// Could even avoid bothering with palette texture and just use uniform data...
|
||||||
|
class DepalShaderCacheVulkan {
|
||||||
|
public:
|
||||||
|
DepalShaderCacheVulkan();
|
||||||
|
~DepalShaderCacheVulkan();
|
||||||
|
|
||||||
|
// This also uploads the palette and binds the correct texture.
|
||||||
|
DepalShader *GetDepalettizeShader(GEPaletteFormat clutFormat, GEBufferFormat pixelFormat);
|
||||||
|
VulkanTexture *GetClutTexture(GEPaletteFormat clutFormat, const u32 clutHash, u32 *rawClut);
|
||||||
|
void Clear();
|
||||||
|
void Decimate();
|
||||||
|
|
||||||
|
private:
|
||||||
|
u32 GenerateShaderID(GEPaletteFormat clutFormat, GEBufferFormat pixelFormat);
|
||||||
|
bool CreateVertexShader();
|
||||||
|
|
||||||
|
// GLuint vertexShader_;
|
||||||
|
std::map<u32, DepalShader *> cache_;
|
||||||
|
std::map<u32, DepalTexture *> texCache_;
|
||||||
|
};
|
||||||
|
|
|
@ -433,8 +433,8 @@ void DrawEngineVulkan::DoFlush(VkCommandBuffer cmd) {
|
||||||
};
|
};
|
||||||
vkCmdBindDescriptorSets(cmd_, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout_, 0, 1, &ds, 3, dynamicUBOOffsets);
|
vkCmdBindDescriptorSets(cmd_, VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout_, 0, 1, &ds, 3, dynamicUBOOffsets);
|
||||||
|
|
||||||
ibOffset = (uint32_t)(frame->pushData->Push(decIndex, 2 * indexGen.VertexCount()));
|
ibOffset = (uint32_t)frame->pushData->Push(decIndex, 2 * indexGen.VertexCount());
|
||||||
// vbOffset = frame->pushData->Push(decoded, )
|
vbOffset = (uint32_t)frame->pushData->Push(decoded, vertexCount * dec_->GetDecVtxFmt().stride);
|
||||||
|
|
||||||
VkDeviceSize offsets[1] = { vbOffset };
|
VkDeviceSize offsets[1] = { vbOffset };
|
||||||
if (useElements) {
|
if (useElements) {
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
// Copyright (c) 2015- PPSSPP Project.
|
||||||
|
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, version 2.0 or later versions.
|
||||||
|
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License 2.0 for more details.
|
||||||
|
|
||||||
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
|
// If not, see http://www.gnu.org/licenses/
|
||||||
|
|
||||||
|
// Official git repository and contact information can be found at
|
||||||
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "GPU/Vulkan/FramebufferVulkan.h"
|
||||||
|
|
||||||
|
VulkanFramebuffer *FramebufferManagerVulkan::GetTempFBO(int width, int height, VulkanFBOColorDepth colorDepth) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
|
@ -20,6 +20,14 @@
|
||||||
#include "GPU/Common/FramebufferCommon.h"
|
#include "GPU/Common/FramebufferCommon.h"
|
||||||
#include "GPU/Vulkan/VulkanUtil.h"
|
#include "GPU/Vulkan/VulkanUtil.h"
|
||||||
|
|
||||||
|
// TODO: WTF?
|
||||||
|
enum VulkanFBOColorDepth {
|
||||||
|
VK_FBO_8888,
|
||||||
|
VK_FBO_565,
|
||||||
|
VK_FBO_4444,
|
||||||
|
VK_FBO_5551,
|
||||||
|
};
|
||||||
|
|
||||||
class FramebufferManagerVulkan : public FramebufferManagerCommon {
|
class FramebufferManagerVulkan : public FramebufferManagerCommon {
|
||||||
public:
|
public:
|
||||||
// Subsequent commands will be enqueued on this buffer.
|
// Subsequent commands will be enqueued on this buffer.
|
||||||
|
@ -29,6 +37,7 @@ public:
|
||||||
virtual void ClearBuffer(bool keepState = false) override {
|
virtual void ClearBuffer(bool keepState = false) override {
|
||||||
throw std::logic_error("The method or operation is not implemented.");
|
throw std::logic_error("The method or operation is not implemented.");
|
||||||
}
|
}
|
||||||
|
VulkanFramebuffer *GetTempFBO(int width, int height, VulkanFBOColorDepth colorDepth);
|
||||||
|
|
||||||
virtual void RebindFramebuffer() override {
|
virtual void RebindFramebuffer() override {
|
||||||
throw std::logic_error("The method or operation is not implemented.");
|
throw std::logic_error("The method or operation is not implemented.");
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include "GPU/Vulkan/GPU_Vulkan.h"
|
#include "GPU/Vulkan/GPU_Vulkan.h"
|
||||||
|
|
||||||
GPU_Vulkan::GPU_Vulkan(VulkanContext *vulkan) : transformDraw_(vulkan) {
|
GPU_Vulkan::GPU_Vulkan(VulkanContext *vulkan) : transformDraw_(vulkan), textureCache_(vulkan) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ public:
|
||||||
void Resized() override;
|
void Resized() override;
|
||||||
void ClearShaderCache() override;
|
void ClearShaderCache() override;
|
||||||
bool DecodeTexture(u8 *dest, const GPUgstate &state) override {
|
bool DecodeTexture(u8 *dest, const GPUgstate &state) override {
|
||||||
return textureCache_.DecodeTexture(dest, state);
|
return false;
|
||||||
}
|
}
|
||||||
bool FramebufferDirty() override;
|
bool FramebufferDirty() override;
|
||||||
bool FramebufferReallyDirty() override;
|
bool FramebufferReallyDirty() override;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -17,22 +17,126 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "GPU/Common/TextureCacheCommon.h"
|
#include <map>
|
||||||
|
|
||||||
|
#include "Globals.h"
|
||||||
|
#include "GPU/GPUInterface.h"
|
||||||
#include "GPU/GPUState.h"
|
#include "GPU/GPUState.h"
|
||||||
|
#include "GPU/Vulkan/TextureScalerVulkan.h"
|
||||||
|
#include "GPU/Common/TextureCacheCommon.h"
|
||||||
|
|
||||||
|
struct VirtualFramebuffer;
|
||||||
|
class FramebufferManagerVulkan;
|
||||||
|
class DepalShaderCacheVulkan;
|
||||||
|
class ShaderManagerVulkan;
|
||||||
|
class DrawEngineVulkan;
|
||||||
|
|
||||||
|
class VulkanContext;
|
||||||
|
struct SamplerCacheKey;
|
||||||
|
|
||||||
class TextureCacheVulkan : public TextureCacheCommon {
|
class TextureCacheVulkan : public TextureCacheCommon {
|
||||||
public:
|
public:
|
||||||
bool SetOffsetTexture(u32 offset) override {
|
TextureCacheVulkan(VulkanContext *vulkan);
|
||||||
return false;
|
~TextureCacheVulkan();
|
||||||
|
|
||||||
|
void SetTexture(VkCommandBuffer cmd, VkImageView &imageView);
|
||||||
|
virtual bool SetOffsetTexture(u32 offset) override;
|
||||||
|
|
||||||
|
void Clear(bool delete_them);
|
||||||
|
void StartFrame();
|
||||||
|
void Invalidate(u32 addr, int size, GPUInvalidationType type);
|
||||||
|
void InvalidateAll(GPUInvalidationType type);
|
||||||
|
void ClearNextFrame();
|
||||||
|
|
||||||
|
void SetFramebufferManager(FramebufferManagerVulkan *fbManager) {
|
||||||
|
framebufferManager_ = fbManager;
|
||||||
}
|
}
|
||||||
|
void SetDepalShaderCache(DepalShaderCacheVulkan *dpCache) {
|
||||||
|
depalShaderCache_ = dpCache;
|
||||||
|
}
|
||||||
|
void SetShaderManager(ShaderManagerVulkan *sm) {
|
||||||
|
shaderManager_ = sm;
|
||||||
|
}
|
||||||
|
void SetTransformDrawEngine(DrawEngineVulkan *td) {
|
||||||
|
transformDraw_ = td;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t NumLoadedTextures() const {
|
||||||
|
return cache.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ForgetLastTexture() {
|
||||||
|
lastBoundTexture = nullptr;
|
||||||
|
gstate_c.textureChanged |= TEXCHANGE_PARAMSONLY;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplyTexture(VkImageView &imageView, VkSampler &sampler);
|
||||||
|
|
||||||
bool DecodeTexture(u8 *dest, const GPUgstate &state) {
|
bool DecodeTexture(u8 *dest, const GPUgstate &state) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AttachFramebuffer(TexCacheEntry *entry, u32 address, VirtualFramebuffer *framebuffer, u32 texaddrOffset = 0) override;
|
|
||||||
void DetachFramebuffer(TexCacheEntry *entry, u32 address, VirtualFramebuffer *framebuffer) override;
|
|
||||||
|
|
||||||
void DownloadFramebufferForClut(u32 clutAddr, u32 bytes) override {
|
void DownloadFramebufferForClut(u32 clutAddr, u32 bytes) override {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Decimate(); // Run this once per frame to get rid of old textures.
|
||||||
|
void DeleteTexture(TexCache::iterator it);
|
||||||
|
void *ReadIndexedTex(int level, const u8 *texptr, int bytesPerIndex, VkFormat dstFmt, int bufw);
|
||||||
|
void UpdateSamplingParams(TexCacheEntry &entry, bool force);
|
||||||
|
void LoadTextureLevel(TexCacheEntry &entry, int level, bool replaceImages, int scaleFactor, VkFormat dstFmt);
|
||||||
|
VkFormat GetDestFormat(GETextureFormat format, GEPaletteFormat clutFormat) const;
|
||||||
|
void *DecodeTextureLevel(GETextureFormat format, GEPaletteFormat clutformat, int level, u32 &texByteAlign, VkFormat dstFmt, int scaleFactor, int *bufw = 0);
|
||||||
|
TexCacheEntry::Status CheckAlpha(const u32 *pixelData, VkFormat dstFmt, int stride, int w, int h);
|
||||||
|
template <typename T>
|
||||||
|
const T *GetCurrentClut();
|
||||||
|
u32 GetCurrentClutHash();
|
||||||
|
void UpdateCurrentClut(GEPaletteFormat clutFormat, u32 clutBase, bool clutIndexIsSimple);
|
||||||
|
bool AttachFramebuffer(TexCacheEntry *entry, u32 address, VirtualFramebuffer *framebuffer, u32 texaddrOffset = 0) override;
|
||||||
|
void DetachFramebuffer(TexCacheEntry *entry, u32 address, VirtualFramebuffer *framebuffer) override;
|
||||||
|
void SetTextureFramebuffer(TexCacheEntry *entry, VirtualFramebuffer *framebuffer);
|
||||||
|
void ApplyTextureFramebuffer(VkCommandBuffer cmd, TexCacheEntry *entry, VirtualFramebuffer *framebuffer, VkImageView &image, VkSampler &sampler);
|
||||||
|
void SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHeight, SamplerCacheKey &key);
|
||||||
|
|
||||||
|
VulkanContext *vulkan_;
|
||||||
|
|
||||||
|
TexCache secondCache;
|
||||||
|
std::vector<u32> nameCache_;
|
||||||
|
u32 cacheSizeEstimate_;
|
||||||
|
u32 secondCacheSizeEstimate_;
|
||||||
|
|
||||||
|
// Separate to keep main texture cache size down.
|
||||||
|
struct AttachedFramebufferInfo {
|
||||||
|
u32 xOffset;
|
||||||
|
u32 yOffset;
|
||||||
|
};
|
||||||
|
std::map<u32, AttachedFramebufferInfo> fbTexInfo_;
|
||||||
|
void AttachFramebufferValid(TexCacheEntry *entry, VirtualFramebuffer *framebuffer, const AttachedFramebufferInfo &fbInfo);
|
||||||
|
void AttachFramebufferInvalid(TexCacheEntry *entry, VirtualFramebuffer *framebuffer, const AttachedFramebufferInfo &fbInfo);
|
||||||
|
|
||||||
|
bool clearCacheNextFrame_;
|
||||||
|
bool lowMemoryMode_;
|
||||||
|
|
||||||
|
TextureScalerVulkan scaler;
|
||||||
|
|
||||||
|
u32 *clutBuf_;
|
||||||
|
u32 clutHash_;
|
||||||
|
// True if the clut is just alpha values in the same order (RGBA4444-bit only.)
|
||||||
|
bool clutAlphaLinear_;
|
||||||
|
u16 clutAlphaLinearColor_;
|
||||||
|
|
||||||
|
CachedTextureVulkan *lastBoundTexture;
|
||||||
|
float maxAnisotropyLevel;
|
||||||
|
|
||||||
|
int decimationCounter_;
|
||||||
|
int texelsScaledThisFrame_;
|
||||||
|
int timesInvalidatedAllThisFrame_;
|
||||||
|
|
||||||
|
FramebufferManagerVulkan *framebufferManager_;
|
||||||
|
DepalShaderCacheVulkan *depalShaderCache_;
|
||||||
|
ShaderManagerVulkan *shaderManager_;
|
||||||
|
DrawEngineVulkan *transformDraw_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
VkFormat getClutDestFormatVulkan(GEPaletteFormat format);
|
||||||
|
|
62
GPU/Vulkan/TextureScalerVulkan.cpp
Normal file
62
GPU/Vulkan/TextureScalerVulkan.cpp
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
// Copyright (c) 2012- PPSSPP Project.
|
||||||
|
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, version 2.0 or later versions.
|
||||||
|
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License 2.0 for more details.
|
||||||
|
|
||||||
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
|
// If not, see http://www.gnu.org/licenses/
|
||||||
|
|
||||||
|
// Official git repository and contact information can be found at
|
||||||
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||||
|
|
||||||
|
#if _MSC_VER == 1700
|
||||||
|
// Has to be included before TextureScaler.h, else we get those std::bind errors in VS2012..
|
||||||
|
#include "../native/base/basictypes.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include "gfx/gl_common.h"
|
||||||
|
|
||||||
|
#include "GPU/Common/TextureScalerCommon.h"
|
||||||
|
#include "GPU/Vulkan/TextureScalerVulkan.h"
|
||||||
|
#include "Common/ColorConv.h"
|
||||||
|
#include "Common/Log.h"
|
||||||
|
#include "Common/ThreadPools.h"
|
||||||
|
|
||||||
|
int TextureScalerVulkan::BytesPerPixel(u32 format) {
|
||||||
|
return (format == GL_UNSIGNED_BYTE) ? 4 : 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 TextureScalerVulkan::Get8888Format() {
|
||||||
|
return GL_UNSIGNED_BYTE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextureScalerVulkan::ConvertTo8888(u32 format, u32* source, u32* &dest, int width, int height) {
|
||||||
|
switch (format) {
|
||||||
|
case GL_UNSIGNED_BYTE:
|
||||||
|
dest = source; // already fine
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GL_UNSIGNED_SHORT_4_4_4_4:
|
||||||
|
GlobalThreadPool::Loop(std::bind(&convert4444_gl, (u16*)source, dest, width, placeholder::_1, placeholder::_2), 0, height);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GL_UNSIGNED_SHORT_5_6_5:
|
||||||
|
GlobalThreadPool::Loop(std::bind(&convert565_gl, (u16*)source, dest, width, placeholder::_1, placeholder::_2), 0, height);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GL_UNSIGNED_SHORT_5_5_5_1:
|
||||||
|
GlobalThreadPool::Loop(std::bind(&convert5551_gl, (u16*)source, dest, width, placeholder::_1, placeholder::_2), 0, height);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
dest = source;
|
||||||
|
ERROR_LOG(G3D, "iXBRZTexScaling: unsupported texture format");
|
||||||
|
}
|
||||||
|
}
|
27
GPU/Vulkan/TextureScalerVulkan.h
Normal file
27
GPU/Vulkan/TextureScalerVulkan.h
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
// Copyright (c) 2012- PPSSPP Project.
|
||||||
|
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, version 2.0 or later versions.
|
||||||
|
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License 2.0 for more details.
|
||||||
|
|
||||||
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
|
// If not, see http://www.gnu.org/licenses/
|
||||||
|
|
||||||
|
// Official git repository and contact information can be found at
|
||||||
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Common/CommonTypes.h"
|
||||||
|
#include "GPU/Common/TextureScalerCommon.h"
|
||||||
|
|
||||||
|
class TextureScalerVulkan : public TextureScaler {
|
||||||
|
void ConvertTo8888(u32 format, u32* source, u32* &dest, int width, int height) override;
|
||||||
|
int BytesPerPixel(u32 format) override;
|
||||||
|
u32 Get8888Format() override;
|
||||||
|
};
|
|
@ -1672,3 +1672,22 @@ const char *VulkanResultToString(VkResult res) {
|
||||||
void VulkanAssertImpl(VkResult check, const char *function, const char *file, int line) {
|
void VulkanAssertImpl(VkResult check, const char *function, const char *file, int line) {
|
||||||
const char *error = "(none)";
|
const char *error = "(none)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VulkanFramebuffer::Create(VulkanContext *vulkan, int w, int h, VkFormat format) {
|
||||||
|
|
||||||
|
}
|
||||||
|
// void TransitionToImage()
|
||||||
|
|
||||||
|
void VulkanFramebuffer::BeginPass(VkCommandBuffer cmd) {
|
||||||
|
|
||||||
|
}
|
||||||
|
void VulkanFramebuffer::EndPass(VkCommandBuffer cmd) {
|
||||||
|
|
||||||
|
}
|
||||||
|
void VulkanFramebuffer::TransitionToTexture(VkCommandBuffer cmd) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
VkImageView VulkanFramebuffer::GetColorImageView() {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
|
@ -337,6 +337,24 @@ private:
|
||||||
bool needStaging;
|
bool needStaging;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Placeholder
|
||||||
|
|
||||||
|
class VulkanFramebuffer {
|
||||||
|
public:
|
||||||
|
void Create(VulkanContext *vulkan, int w, int h, VkFormat format);
|
||||||
|
// void TransitionToImage()
|
||||||
|
|
||||||
|
void BeginPass(VkCommandBuffer cmd);
|
||||||
|
void EndPass(VkCommandBuffer cmd);
|
||||||
|
void TransitionToTexture(VkCommandBuffer cmd);
|
||||||
|
|
||||||
|
VkImageView GetColorImageView();
|
||||||
|
|
||||||
|
private:
|
||||||
|
VkImage image_;
|
||||||
|
VkFramebuffer framebuffer_;
|
||||||
|
};
|
||||||
|
|
||||||
// Use these to push vertex, index and uniform data.
|
// Use these to push vertex, index and uniform data.
|
||||||
// TODO: Make it possible to suballocate pushbuffers from a large DeviceMemory block.
|
// TODO: Make it possible to suballocate pushbuffers from a large DeviceMemory block.
|
||||||
// TODO: Make this dynamically grow by chaining new buffers in the future.
|
// TODO: Make this dynamically grow by chaining new buffers in the future.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue