Vulkan: Fix Prescale UV
This commit is contained in:
parent
e8758c1ea0
commit
20f227cc4d
4 changed files with 95 additions and 65 deletions
|
@ -121,14 +121,14 @@ TransformDrawEngine::TransformDrawEngine()
|
||||||
: decodedVerts_(0),
|
: decodedVerts_(0),
|
||||||
prevPrim_(GE_PRIM_INVALID),
|
prevPrim_(GE_PRIM_INVALID),
|
||||||
lastVType_(-1),
|
lastVType_(-1),
|
||||||
shaderManager_(0),
|
shaderManager_(nullptr),
|
||||||
textureCache_(0),
|
textureCache_(nullptr),
|
||||||
framebufferManager_(0),
|
framebufferManager_(nullptr),
|
||||||
numDrawCalls(0),
|
numDrawCalls(0),
|
||||||
vertexCountInDrawCalls(0),
|
vertexCountInDrawCalls(0),
|
||||||
decodeCounter_(0),
|
decodeCounter_(0),
|
||||||
dcid_(0),
|
dcid_(0),
|
||||||
uvScale(0),
|
uvScale(nullptr),
|
||||||
fboTexNeedBind_(false),
|
fboTexNeedBind_(false),
|
||||||
fboTexBound_(false) {
|
fboTexBound_(false) {
|
||||||
decimationCounter_ = VERTEXCACHE_DECIMATION_INTERVAL;
|
decimationCounter_ = VERTEXCACHE_DECIMATION_INTERVAL;
|
||||||
|
|
|
@ -71,6 +71,7 @@ DrawEngineVulkan::DrawEngineVulkan(VulkanContext *vulkan)
|
||||||
framebufferManager_(nullptr),
|
framebufferManager_(nullptr),
|
||||||
numDrawCalls(0),
|
numDrawCalls(0),
|
||||||
vertexCountInDrawCalls(0),
|
vertexCountInDrawCalls(0),
|
||||||
|
uvScale(nullptr),
|
||||||
fboTexNeedBind_(false),
|
fboTexNeedBind_(false),
|
||||||
fboTexBound_(false),
|
fboTexBound_(false),
|
||||||
curFrame_(0),
|
curFrame_(0),
|
||||||
|
@ -92,6 +93,10 @@ DrawEngineVulkan::DrawEngineVulkan(VulkanContext *vulkan)
|
||||||
|
|
||||||
indexGen.Setup(decIndex);
|
indexGen.Setup(decIndex);
|
||||||
|
|
||||||
|
if (g_Config.bPrescaleUV) {
|
||||||
|
uvScale = new UVScale[MAX_DEFERRED_DRAW_CALLS];
|
||||||
|
}
|
||||||
|
|
||||||
// All resources we need for PSP drawing. Usually only bindings 0 and 2-4 are populated.
|
// All resources we need for PSP drawing. Usually only bindings 0 and 2-4 are populated.
|
||||||
VkDescriptorSetLayoutBinding bindings[5];
|
VkDescriptorSetLayoutBinding bindings[5];
|
||||||
bindings[0].descriptorCount = 1;
|
bindings[0].descriptorCount = 1;
|
||||||
|
@ -202,6 +207,7 @@ DrawEngineVulkan::~DrawEngineVulkan() {
|
||||||
nullTexture_->Destroy();
|
nullTexture_->Destroy();
|
||||||
delete nullTexture_;
|
delete nullTexture_;
|
||||||
}
|
}
|
||||||
|
delete[] uvScale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawEngineVulkan::BeginFrame() {
|
void DrawEngineVulkan::BeginFrame() {
|
||||||
|
@ -312,6 +318,10 @@ void DrawEngineVulkan::SubmitPrim(void *verts, void *inds, GEPrimitiveType prim,
|
||||||
dc.indexUpperBound = vertexCount - 1;
|
dc.indexUpperBound = vertexCount - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (uvScale) {
|
||||||
|
uvScale[numDrawCalls] = gstate_c.uv;
|
||||||
|
}
|
||||||
|
|
||||||
numDrawCalls++;
|
numDrawCalls++;
|
||||||
vertexCountInDrawCalls += vertexCount;
|
vertexCountInDrawCalls += vertexCount;
|
||||||
|
|
||||||
|
@ -324,26 +334,7 @@ void DrawEngineVulkan::SubmitPrim(void *verts, void *inds, GEPrimitiveType prim,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawEngineVulkan::DecodeVerts(VulkanPushBuffer *push, uint32_t *bindOffset, VkBuffer *vkbuf) {
|
void DrawEngineVulkan::DecodeVertsStep(u8 *dest, int &i, int &decodedVerts) {
|
||||||
int decodedVerts = 0;
|
|
||||||
|
|
||||||
u8 *dest = decoded;
|
|
||||||
|
|
||||||
// Figure out how much pushbuffer space we need to allocate.
|
|
||||||
if (push) {
|
|
||||||
int vertsToDecode = 0;
|
|
||||||
for (int i = 0; i < numDrawCalls; i++) {
|
|
||||||
const DeferredDrawCall &dc = drawCalls[i];
|
|
||||||
if (dc.indexType == GE_VTYPE_IDX_NONE >> GE_VTYPE_IDX_SHIFT) {
|
|
||||||
vertsToDecode += dc.indexUpperBound - dc.indexLowerBound + 1;
|
|
||||||
} else {
|
|
||||||
vertsToDecode += dc.vertexCount;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dest = (u8 *)push->Push(vertsToDecode * dec_->GetDecVtxFmt().stride, bindOffset, vkbuf);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < numDrawCalls; i++) {
|
|
||||||
const DeferredDrawCall &dc = drawCalls[i];
|
const DeferredDrawCall &dc = drawCalls[i];
|
||||||
|
|
||||||
indexGen.SetIndex(decodedVerts);
|
indexGen.SetIndex(decodedVerts);
|
||||||
|
@ -405,7 +396,40 @@ void DrawEngineVulkan::DecodeVerts(VulkanPushBuffer *push, uint32_t *bindOffset,
|
||||||
indexGen.Advance(vertexCount);
|
indexGen.Advance(vertexCount);
|
||||||
i = lastMatch;
|
i = lastMatch;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawEngineVulkan::DecodeVerts(VulkanPushBuffer *push, uint32_t *bindOffset, VkBuffer *vkbuf) {
|
||||||
|
int decodedVerts = 0;
|
||||||
|
|
||||||
|
u8 *dest = decoded;
|
||||||
|
|
||||||
|
// Figure out how much pushbuffer space we need to allocate.
|
||||||
|
if (push) {
|
||||||
|
int vertsToDecode = 0;
|
||||||
|
for (int i = 0; i < numDrawCalls; i++) {
|
||||||
|
const DeferredDrawCall &dc = drawCalls[i];
|
||||||
|
if (dc.indexType == GE_VTYPE_IDX_NONE >> GE_VTYPE_IDX_SHIFT) {
|
||||||
|
vertsToDecode += dc.indexUpperBound - dc.indexLowerBound + 1;
|
||||||
|
} else {
|
||||||
|
vertsToDecode += dc.vertexCount;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
dest = (u8 *)push->Push(vertsToDecode * dec_->GetDecVtxFmt().stride, bindOffset, vkbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uvScale) {
|
||||||
|
const UVScale origUV = gstate_c.uv;
|
||||||
|
for (int i = 0; i < numDrawCalls; i++) {
|
||||||
|
gstate_c.uv = uvScale[i];
|
||||||
|
DecodeVertsStep(dest, i, decodedVerts); // Note that this can modify i
|
||||||
|
}
|
||||||
|
gstate_c.uv = origUV;
|
||||||
|
} else {
|
||||||
|
for (int i = 0; i < numDrawCalls; i++) {
|
||||||
|
DecodeVertsStep(dest, i, decodedVerts); // Note that this can modify i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Sanity check
|
// Sanity check
|
||||||
if (indexGen.Prim() < 0) {
|
if (indexGen.Prim() < 0) {
|
||||||
ERROR_LOG_REPORT(G3D, "DecodeVerts: Failed to deduce prim: %i", indexGen.Prim());
|
ERROR_LOG_REPORT(G3D, "DecodeVerts: Failed to deduce prim: %i", indexGen.Prim());
|
||||||
|
|
|
@ -147,6 +147,8 @@ private:
|
||||||
struct FrameData;
|
struct FrameData;
|
||||||
|
|
||||||
void DecodeVerts(VulkanPushBuffer *push, uint32_t *bindOffset, VkBuffer *vkbuf);
|
void DecodeVerts(VulkanPushBuffer *push, uint32_t *bindOffset, VkBuffer *vkbuf);
|
||||||
|
void DecodeVertsStep(u8 *dest, int &i, int &decodedVerts);
|
||||||
|
|
||||||
void DoFlush(VkCommandBuffer cmd);
|
void DoFlush(VkCommandBuffer cmd);
|
||||||
void UpdateUBOs(FrameData *frame);
|
void UpdateUBOs(FrameData *frame);
|
||||||
|
|
||||||
|
@ -244,6 +246,7 @@ private:
|
||||||
DeferredDrawCall drawCalls[MAX_DEFERRED_DRAW_CALLS];
|
DeferredDrawCall drawCalls[MAX_DEFERRED_DRAW_CALLS];
|
||||||
int numDrawCalls;
|
int numDrawCalls;
|
||||||
int vertexCountInDrawCalls;
|
int vertexCountInDrawCalls;
|
||||||
|
UVScale *uvScale;
|
||||||
|
|
||||||
bool fboTexNeedBind_;
|
bool fboTexNeedBind_;
|
||||||
bool fboTexBound_;
|
bool fboTexBound_;
|
||||||
|
|
|
@ -311,6 +311,9 @@ void GameSettingsScreen::CreateViews() {
|
||||||
CheckBox *depthWrite = graphicsSettings->Add(new CheckBox(&g_Config.bAlwaysDepthWrite, gr->T("Always Depth Write")));
|
CheckBox *depthWrite = graphicsSettings->Add(new CheckBox(&g_Config.bAlwaysDepthWrite, gr->T("Always Depth Write")));
|
||||||
depthWrite->SetDisabledPtr(&g_Config.bSoftwareRendering);
|
depthWrite->SetDisabledPtr(&g_Config.bSoftwareRendering);
|
||||||
|
|
||||||
|
graphicsSettings->Add(new CheckBox(&g_Config.bPrescaleUV, gr->T("Texture Coord Speedhack")));
|
||||||
|
depthWrite->SetDisabledPtr(&g_Config.bSoftwareRendering);
|
||||||
|
|
||||||
static const char *bloomHackOptions[] = { "Off", "Safe", "Balanced", "Aggressive" };
|
static const char *bloomHackOptions[] = { "Off", "Safe", "Balanced", "Aggressive" };
|
||||||
PopupMultiChoice *bloomHack = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iBloomHack, gr->T("Lower resolution for effects (reduces artifacts)"), bloomHackOptions, 0, ARRAY_SIZE(bloomHackOptions), gr->GetName(), screenManager()));
|
PopupMultiChoice *bloomHack = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iBloomHack, gr->T("Lower resolution for effects (reduces artifacts)"), bloomHackOptions, 0, ARRAY_SIZE(bloomHackOptions), gr->GetName(), screenManager()));
|
||||||
bloomHackEnable_ = !g_Config.bSoftwareRendering && (g_Config.iInternalResolution != 1);
|
bloomHackEnable_ = !g_Config.bSoftwareRendering && (g_Config.iInternalResolution != 1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue