1
0
mirror of https://github.com/rt64/rt64.git synced 2025-02-14 15:39:56 +00:00

MSAA Workaround for Decals on a non-NoN game (See ).

This commit is contained in:
Dario 2024-05-21 22:16:20 -03:00
parent 051af43bd8
commit 627571e5e6
3 changed files with 10 additions and 7 deletions

@ -42,7 +42,7 @@ namespace RT64 {
this->device = device;
this->desc = desc;
const bool useMSAA = (multisampling.sampleCount > 1);
std::unique_ptr<RenderShader> vertexShader;
std::unique_ptr<RenderShader> pixelShader;
@ -53,7 +53,7 @@ namespace RT64 {
const void *PSBlob = nullptr;
uint32_t VSBlobSize = 0;
uint32_t PSBlobSize = 0;
const bool outputDepth = desc.outputDepth();
const bool outputDepth = desc.outputDepth(useMSAA);
if (desc.flags.smoothShade) {
VSBlob = RasterVSSpecConstantBlobSPIRV;
VSBlobSize = uint32_t(std::size(RasterVSSpecConstantBlobSPIRV));
@ -214,11 +214,11 @@ namespace RT64 {
", [[vk::location(0)]] [[vk::index(0)]] out float4 resultColor : SV_TARGET0"
", [[vk::location(0)]] [[vk::index(1)]] out float4 resultAlpha : SV_TARGET1";
if (desc.outputDepth()) {
if (desc.outputDepth(multisampling)) {
pss << ", out float resultDepth : SV_DEPTH";
}
if (desc.outputDepth()) {
if (desc.outputDepth(multisampling)) {
pss << ") { bool outputDepth = true;";
}
else {

@ -32,11 +32,14 @@ namespace RT64 {
return ss.str();
}
bool ShaderDescription::outputDepth() const {
bool ShaderDescription::outputDepth(bool useMSAA) const {
bool copyMode = (otherMode.cycleType() == G_CYC_COPY);
bool depthClampNear = flags.NoN;
bool depthDecal = (otherMode.zMode() == ZMODE_DEC);
bool zSourcePrim = (otherMode.zSource() == G_ZS_PRIM);
return !copyMode && (depthClampNear || depthDecal || zSourcePrim);
// FIXME: Depth output is forced when using multisampling to avoid problems from interactions when sampling the depth buffer directly on decals.
// The true case of this issue is still pending investigation (https://github.com/rt64/rt64/issues/24).
return !copyMode && (depthClampNear || depthDecal || zSourcePrim || useMSAA);
}
};

@ -25,7 +25,7 @@ namespace RT64 {
void maskUnusedParameters();
uint64_t hash() const;
std::string toShader() const;
bool outputDepth() const;
bool outputDepth(bool useMSAA) const;
};
#pragma pack(pop)
};