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);
|
||||
}
|
||||
// pixel color output
|
||||
//src->addFmt("#ifdef {}" _CRLF, GetColorAttachmentTypeStr(pixelColorOutputIndex));
|
||||
src->addFmt("out.passPixelColor{} = as_type<{}>(", pixelColorOutputIndex, GetColorBufferDataTypeStr(pixelColorOutputIndex, *shaderContext->contextRegistersNew)/*, GetColorAttachmentTypeStr(pixelColorOutputIndex)*/);
|
||||
_emitExportGPRReadCode(shaderContext, cfInstruction, LATTE_DECOMPILER_DTYPE_FLOAT, i);
|
||||
src->add(");" _CRLF);
|
||||
//src->add("#endif" _CRLF);
|
||||
auto dataType = GetColorBufferDataType(pixelColorOutputIndex, *shaderContext->contextRegistersNew);
|
||||
if (dataType != MetalDataType::NONE)
|
||||
{
|
||||
src->addFmt("out.passPixelColor{} = as_type<{}>(", pixelColorOutputIndex, GetDataTypeStr(dataType));
|
||||
_emitExportGPRReadCode(shaderContext, cfInstruction, LATTE_DECOMPILER_DTYPE_FLOAT, i);
|
||||
src->add(");" _CRLF);
|
||||
}
|
||||
|
||||
if( cfInstruction->exportArrayBase+i >= 8 )
|
||||
cemu_assert_unimplemented();
|
||||
|
@ -281,9 +281,11 @@ namespace LatteDecompiler
|
||||
{
|
||||
if ((decompilerContext->shader->pixelColorOutputMask & (1 << i)) != 0)
|
||||
{
|
||||
//src->addFmt("#ifdef {}" _CRLF, GetColorAttachmentTypeStr(i));
|
||||
src->addFmt("{} passPixelColor{} [[color({})]];" _CRLF, GetColorBufferDataTypeStr(i, *decompilerContext->contextRegistersNew)/*, GetColorAttachmentTypeStr(i)*/, i, i);
|
||||
//src->add("#endif" _CRLF);
|
||||
auto dataType = GetColorBufferDataType(i, *decompilerContext->contextRegistersNew);
|
||||
if (dataType != MetalDataType::NONE)
|
||||
{
|
||||
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/FetchShader.h"
|
||||
#include "Cafe/HW/Latte/Renderer/Renderer.h"
|
||||
#include "Common/precompiled.h"
|
||||
|
||||
struct Uvec2 {
|
||||
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);
|
||||
|
||||
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 dataType = GetMtlPixelFormatInfo(format, false).dataType;
|
||||
return GetMtlPixelFormatInfo(format, false).dataType;
|
||||
}
|
||||
|
||||
inline const char* GetDataTypeStr(MetalDataType dataType)
|
||||
{
|
||||
switch (dataType)
|
||||
{
|
||||
case MetalDataType::INT:
|
||||
@ -45,7 +50,8 @@ inline const char* GetColorBufferDataTypeStr(const uint32 index, const LatteCont
|
||||
case MetalDataType::FLOAT:
|
||||
return "float4";
|
||||
default:
|
||||
return "unknown";
|
||||
cemu_assert_suspicious();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user