Permalink
Browse files

Simple micro-optimization in AdvanceVerts

  • Loading branch information...
hrydgard committed Aug 15, 2017
1 parent 4e7099b commit c4ccf5b7348aadbf67e3a2eaa79be67627c82cb5
Showing with 18 additions and 20 deletions.
  1. +0 −14 GPU/GPUCommon.cpp
  2. +9 −2 GPU/GPUCommon.h
  3. +3 −3 GPU/Vulkan/DrawEngineVulkan.cpp
  4. +6 −1 GPU/Vulkan/StateMappingVulkan.cpp
View
@@ -2253,20 +2253,6 @@ void GPUCommon::SetCmdValue(u32 op) {
ExecuteOp(op, diff);
}
void GPUCommon::AdvanceVerts(u32 vertType, int count, int bytesRead) {
if ((vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
int indexSize = 1;
if ((vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_16BIT)
indexSize = 2;
else if ((vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_32BIT)
indexSize = 4;
gstate_c.indexAddr += count * indexSize;
} else {
gstate_c.vertexAddr += bytesRead;
}
}
void GPUCommon::DoBlockTransfer(u32 skipDrawReason) {
// TODO: This is used a lot to copy data around between render targets and textures,
// and also to quickly load textures from RAM to VRAM. So we should do checks like the following:
View
@@ -233,7 +233,7 @@ class GPUCommon : public GPUThreadEventQueue, public GPUDebugInterface {
lastDraw_ = type;
}
// Prim == RECTANGLES can cause CanUseHardwareTransform to flip, so we need to dirty.
// Also, culling may be affected.
// Also, culling may be affected so dirty the raster state.
if ((prim == GE_PRIM_RECTANGLES) != (lastPrim_ == GE_PRIM_RECTANGLES)) {
gstate_c.Dirty(DIRTY_RASTER_STATE | DIRTY_VERTEXSHADER_STATE);
lastPrim_ = prim;
@@ -266,7 +266,14 @@ class GPUCommon : public GPUThreadEventQueue, public GPUDebugInterface {
void DoBlockTransfer(u32 skipDrawReason);
void AdvanceVerts(u32 vertType, int count, int bytesRead);
void AdvanceVerts(u32 vertType, int count, int bytesRead) {
if ((vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
int indexShift = ((vertType & GE_VTYPE_IDX_MASK) >> GE_VTYPE_IDX_SHIFT) - 1;
gstate_c.indexAddr += count << indexShift;
} else {
gstate_c.vertexAddr += bytesRead;
}
}
void PerformMemoryCopyInternal(u32 dest, u32 src, int size);
void PerformMemorySetInternal(u32 dest, u8 v, int size);
@@ -479,7 +479,7 @@ VkDescriptorSet DrawEngineVulkan::GetDescriptorSet(VkImageView imageView, VkSamp
memset(writes, 0, sizeof(writes));
// Main texture
int n = 0;
VkDescriptorImageInfo tex;
VkDescriptorImageInfo tex{};
if (imageView) {
// TODO: Also support LAYOUT_GENERAL to be able to texture from framebuffers without transitioning them?
tex.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
@@ -499,7 +499,7 @@ VkDescriptorSet DrawEngineVulkan::GetDescriptorSet(VkImageView imageView, VkSamp
// Tessellation data textures
if (gstate_c.bezier || gstate_c.spline) {
VkDescriptorImageInfo tess_tex[3];
VkDescriptorImageInfo tess_tex[3]{};
VkSampler sampler = ((TessellationDataTransferVulkan *)tessDataTransfer)->GetSampler();
for (int i = 0; i < 3; i++) {
VulkanTexture *texture = ((TessellationDataTransferVulkan *)tessDataTransfer)->GetTexture(i);
@@ -521,7 +521,7 @@ VkDescriptorSet DrawEngineVulkan::GetDescriptorSet(VkImageView imageView, VkSamp
}
// Uniform buffer objects
VkDescriptorBufferInfo buf[3];
VkDescriptorBufferInfo buf[3]{};
int count = 0;
buf[count].buffer = base;
buf[count].offset = 0;
@@ -130,6 +130,12 @@ void ResetShaderBlending() {
// In Vulkan, we simply collect all the state together into a "pipeline key" - we don't actually set any state here
// (the caller is responsible for setting the little dynamic state that is supported, dynState).
void DrawEngineVulkan::ConvertStateToVulkanKey(FramebufferManagerVulkan &fbManager, ShaderManagerVulkan *shaderManager, int prim, VulkanPipelineRasterStateKey &key, VulkanDynamicState &dynState) {
/*
if (!gstate_c.IsDirty(DIRTY_BLEND_STATE | DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_DEPTHRANGE | DIRTY_RASTER_STATE)) {
// nothing to do
return;
}*/
bool useBufferedRendering = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
if (gstate_c.IsDirty(DIRTY_BLEND_STATE)) {
@@ -151,7 +157,6 @@ void DrawEngineVulkan::ConvertStateToVulkanKey(FramebufferManagerVulkan &fbManag
bool colorMask = gstate.isClearModeColorMask();
bool alphaMask = gstate.isClearModeAlphaMask();
key.colorWriteMask = (colorMask ? (VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT) : 0) | (alphaMask ? VK_COLOR_COMPONENT_A_BIT : 0);
} else {
key.logicOpEnable = false;
key.logicOp = VK_LOGIC_OP_CLEAR;

0 comments on commit c4ccf5b

Please sign in to comment.