Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement pixel history for dual source output and blend src/dest on Vulkan #3011

Closed
34 changes: 28 additions & 6 deletions renderdoc/api/replay/data_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -2100,12 +2100,13 @@ struct PixelModification
{
return eventId == o.eventId && directShaderWrite == o.directShaderWrite &&
unboundPS == o.unboundPS && fragIndex == o.fragIndex && primitiveID == o.primitiveID &&
preMod == o.preMod && shaderOut == o.shaderOut && postMod == o.postMod &&
sampleMasked == o.sampleMasked && backfaceCulled == o.backfaceCulled &&
depthClipped == o.depthClipped && depthBoundsFailed == o.depthBoundsFailed &&
viewClipped == o.viewClipped && scissorClipped == o.scissorClipped &&
shaderDiscarded == o.shaderDiscarded && depthTestFailed == o.depthTestFailed &&
stencilTestFailed == o.stencilTestFailed;
preMod == o.preMod && shaderOut == o.shaderOut &&
shaderOutDualSrc == o.shaderOutDualSrc && blendSrc == o.blendSrc &&
blendDst == o.blendDst && postMod == o.postMod && sampleMasked == o.sampleMasked &&
backfaceCulled == o.backfaceCulled && depthClipped == o.depthClipped &&
depthBoundsFailed == o.depthBoundsFailed && viewClipped == o.viewClipped &&
scissorClipped == o.scissorClipped && shaderDiscarded == o.shaderDiscarded &&
depthTestFailed == o.depthTestFailed && stencilTestFailed == o.stencilTestFailed;
}
bool operator<(const PixelModification &o) const
{
Expand All @@ -2123,6 +2124,12 @@ struct PixelModification
return preMod < o.preMod;
if(!(shaderOut == o.shaderOut))
return shaderOut < o.shaderOut;
if(!(shaderOutDualSrc == o.shaderOutDualSrc))
return shaderOutDualSrc < o.shaderOutDualSrc;
if(!(blendSrc == o.blendSrc))
return blendSrc < o.blendSrc;
if(!(blendDst == o.blendDst))
return blendDst < o.blendDst;
if(!(postMod == o.postMod))
return postMod < o.postMod;
if(!(sampleMasked == o.sampleMasked))
Expand Down Expand Up @@ -2175,6 +2182,21 @@ pixel.
:type: ModificationValue
)");
ModificationValue shaderOut;
DOCUMENT(R"(The value that this fragment wrote from the pixel shader to the second output.

:type: ModificationValue
)");
ModificationValue shaderOutDualSrc;
DOCUMENT(R"(The source component in the blend equation for this fragment.

:type: ModificationValue
)");
ModificationValue blendSrc;
DOCUMENT(R"(The destination component in the blend equation for this fragment.

:type: ModificationValue
)");
ModificationValue blendDst;
DOCUMENT(R"(The value of the texture after this fragment ran.

:type: ModificationValue
Expand Down
6 changes: 6 additions & 0 deletions renderdoc/driver/d3d11/d3d11_pixelhistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1940,6 +1940,9 @@ rdcarray<PixelModification> D3D11Replay::PixelHistory(rdcarray<EventUsage> event
// data[3].x (depth) unused
// fragments writing to the pixel in this event with original shader
mod.shaderOut.col.intValue[1] = int32_t(data[3].y);
mod.shaderOutDualSrc.SetInvalid();
mod.blendSrc.SetInvalid();
mod.blendDst.SetInvalid();
}
}

Expand Down Expand Up @@ -2316,6 +2319,9 @@ rdcarray<PixelModification> D3D11Replay::PixelHistory(rdcarray<EventUsage> event
byte *data = shadoutStoreData + sizeof(Vec4f) * pixstoreStride * offsettedSlot;

memcpy(&history[h].shaderOut.col.uintValue[0], data, 4 * sizeof(float));
history[h].shaderOutDualSrc.SetInvalid();
history[h].blendSrc.SetInvalid();
history[h].blendDst.SetInvalid();

// primitive ID is in the next slot after that
memcpy(&history[h].primitiveID, data + sizeof(Vec4f), sizeof(uint32_t));
Expand Down
6 changes: 6 additions & 0 deletions renderdoc/driver/gl/gl_pixelhistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,9 @@ std::map<uint32_t, uint32_t> QueryNumFragmentsByEvent(
numFragments = history[i].shaderOut.stencil;
history[i].shaderOut.stencil = history[i].postMod.stencil;
}
history[i].shaderOutDualSrc.SetInvalid();
history[i].blendSrc.SetInvalid();
history[i].blendDst.SetInvalid();

eventFragments.emplace(modEvents[i].eventId, numFragments);

Expand Down Expand Up @@ -1587,6 +1590,9 @@ void QueryShaderOutPerFragment(WrappedOpenGL *driver, GLReplay *replay,
int(historyIndex - history.begin()));
historyIndex->shaderOut.stencil = oldStencil;
}
historyIndex->shaderOutDualSrc.SetInvalid();
historyIndex->blendSrc.SetInvalid();
historyIndex->blendDst.SetInvalid();
historyIndex++;
}

Expand Down
6 changes: 2 additions & 4 deletions renderdoc/driver/vulkan/vk_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ struct VKMeshDisplayPipelines
uint32_t secondaryStridePadding = 0;
};

struct VkCopyPixelParams;

struct PixelHistoryResources;

class VulkanResourceManager;
Expand Down Expand Up @@ -97,10 +95,10 @@ class VulkanDebugManager
bool PixelHistorySetupResources(PixelHistoryResources &resources, VkImage targetImage,
VkExtent3D extent, VkFormat format, VkSampleCountFlagBits samples,
const Subresource &sub, uint32_t numEvents);
bool PixelHistorySetupPerFragResources(PixelHistoryResources &resources, uint32_t numEvents,
uint32_t numFragments);
bool PixelHistoryDestroyResources(const PixelHistoryResources &resources);

void PixelHistoryCopyPixel(VkCommandBuffer cmd, VkCopyPixelParams &p, size_t offset);

VkImageLayout GetImageLayout(ResourceId image, VkImageAspectFlagBits aspect, uint32_t mip,
uint32_t slice);

Expand Down
Loading