mirror of
https://github.com/cemu-project/Cemu.git
synced 2024-12-01 21:44:17 +01:00
check for invalid color formats
This commit is contained in:
parent
cd72ad80d2
commit
4251f3fe55
@ -3215,11 +3215,13 @@ static void _emitExportCode(LatteDecompilerShaderContext* shaderContext, LatteDe
|
|||||||
src->add(") == false) discard_fragment();" _CRLF);
|
src->add(") == false) discard_fragment();" _CRLF);
|
||||||
}
|
}
|
||||||
// pixel color output
|
// pixel color output
|
||||||
//src->addFmt("#ifdef {}" _CRLF, GetColorAttachmentTypeStr(pixelColorOutputIndex));
|
auto dataType = GetColorBufferDataType(pixelColorOutputIndex, *shaderContext->contextRegistersNew);
|
||||||
src->addFmt("out.passPixelColor{} = as_type<{}>(", pixelColorOutputIndex, GetColorBufferDataTypeStr(pixelColorOutputIndex, *shaderContext->contextRegistersNew)/*, GetColorAttachmentTypeStr(pixelColorOutputIndex)*/);
|
if (dataType != MetalDataType::NONE)
|
||||||
_emitExportGPRReadCode(shaderContext, cfInstruction, LATTE_DECOMPILER_DTYPE_FLOAT, i);
|
{
|
||||||
src->add(");" _CRLF);
|
src->addFmt("out.passPixelColor{} = as_type<{}>(", pixelColorOutputIndex, GetDataTypeStr(dataType));
|
||||||
//src->add("#endif" _CRLF);
|
_emitExportGPRReadCode(shaderContext, cfInstruction, LATTE_DECOMPILER_DTYPE_FLOAT, i);
|
||||||
|
src->add(");" _CRLF);
|
||||||
|
}
|
||||||
|
|
||||||
if( cfInstruction->exportArrayBase+i >= 8 )
|
if( cfInstruction->exportArrayBase+i >= 8 )
|
||||||
cemu_assert_unimplemented();
|
cemu_assert_unimplemented();
|
||||||
|
@ -281,9 +281,11 @@ namespace LatteDecompiler
|
|||||||
{
|
{
|
||||||
if ((decompilerContext->shader->pixelColorOutputMask & (1 << i)) != 0)
|
if ((decompilerContext->shader->pixelColorOutputMask & (1 << i)) != 0)
|
||||||
{
|
{
|
||||||
//src->addFmt("#ifdef {}" _CRLF, GetColorAttachmentTypeStr(i));
|
auto dataType = GetColorBufferDataType(i, *decompilerContext->contextRegistersNew);
|
||||||
src->addFmt("{} passPixelColor{} [[color({})]];" _CRLF, GetColorBufferDataTypeStr(i, *decompilerContext->contextRegistersNew)/*, GetColorAttachmentTypeStr(i)*/, i, i);
|
if (dataType != MetalDataType::NONE)
|
||||||
//src->add("#endif" _CRLF);
|
{
|
||||||
|
src->addFmt("{} passPixelColor{} [[color({})]];" _CRLF, GetDataTypeStr(dataType), i, i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "Cafe/HW/Latte/Core/LatteConst.h"
|
#include "Cafe/HW/Latte/Core/LatteConst.h"
|
||||||
//#include "Cafe/HW/Latte/Core/FetchShader.h"
|
//#include "Cafe/HW/Latte/Core/FetchShader.h"
|
||||||
#include "Cafe/HW/Latte/Renderer/Renderer.h"
|
#include "Cafe/HW/Latte/Renderer/Renderer.h"
|
||||||
|
#include "Common/precompiled.h"
|
||||||
|
|
||||||
struct Uvec2 {
|
struct Uvec2 {
|
||||||
uint32 x;
|
uint32 x;
|
||||||
@ -32,10 +33,14 @@ const MetalPixelFormatInfo GetMtlPixelFormatInfo(Latte::E_GX2SURFFMT format, boo
|
|||||||
|
|
||||||
MTL::PixelFormat GetMtlPixelFormat(Latte::E_GX2SURFFMT format, bool isDepth, const MetalPixelFormatSupport& pixelFormatSupport);
|
MTL::PixelFormat GetMtlPixelFormat(Latte::E_GX2SURFFMT format, bool isDepth, const MetalPixelFormatSupport& pixelFormatSupport);
|
||||||
|
|
||||||
inline const char* GetColorBufferDataTypeStr(const uint32 index, const LatteContextRegister& lcr)
|
inline MetalDataType GetColorBufferDataType(const uint32 index, const LatteContextRegister& lcr)
|
||||||
{
|
{
|
||||||
auto format = LatteMRT::GetColorBufferFormat(index, lcr);
|
auto format = LatteMRT::GetColorBufferFormat(index, lcr);
|
||||||
auto dataType = GetMtlPixelFormatInfo(format, false).dataType;
|
return GetMtlPixelFormatInfo(format, false).dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* GetDataTypeStr(MetalDataType dataType)
|
||||||
|
{
|
||||||
switch (dataType)
|
switch (dataType)
|
||||||
{
|
{
|
||||||
case MetalDataType::INT:
|
case MetalDataType::INT:
|
||||||
@ -45,7 +50,8 @@ inline const char* GetColorBufferDataTypeStr(const uint32 index, const LatteCont
|
|||||||
case MetalDataType::FLOAT:
|
case MetalDataType::FLOAT:
|
||||||
return "float4";
|
return "float4";
|
||||||
default:
|
default:
|
||||||
return "unknown";
|
cemu_assert_suspicious();
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user