Integrating github/staging through commit ab87ed9
This commit is contained in:
@@ -52,11 +52,10 @@ AZ_POP_DISABLE_WARNING
|
||||
|
||||
static char* cJSON_strdup(const char* str)
|
||||
{
|
||||
size_t len;
|
||||
char* copy;
|
||||
size_t len = strlen(str) + 1;
|
||||
char* copy = (char*)cJSON_malloc(len);
|
||||
|
||||
len = strlen(str) + 1;
|
||||
if (!(copy = (char*)cJSON_malloc(len))) return 0;
|
||||
if (!copy) return 0;
|
||||
memcpy(copy,str,len);
|
||||
return copy;
|
||||
}
|
||||
@@ -209,7 +208,15 @@ static char *print_string_ptr(const char *str)
|
||||
const char *ptr;char *ptr2,*out;int len=0;unsigned char token;
|
||||
|
||||
if (!str) return cJSON_strdup("");
|
||||
ptr=str;while ((token=*ptr) && ++len) {if (strchr("\"\\\b\f\n\r\t",token)) len++; else if (token<32) len+=5;ptr++;}
|
||||
ptr=str;
|
||||
token = *ptr;
|
||||
while (token && ++len)
|
||||
{
|
||||
if (strchr("\"\\\b\f\n\r\t",token)) len++;
|
||||
else if (token<32) len+=5;
|
||||
ptr++;
|
||||
token = *ptr;
|
||||
}
|
||||
|
||||
out=(char*)cJSON_malloc(len+3);
|
||||
if (!out) return 0;
|
||||
@@ -325,8 +332,8 @@ static const char *parse_array(cJSON *item,const char *value)
|
||||
|
||||
while (*value==',')
|
||||
{
|
||||
cJSON *new_item;
|
||||
if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
|
||||
cJSON *new_item = cJSON_New_Item();
|
||||
if (!new_item) return 0; /* memory fail */
|
||||
child->next=new_item;new_item->prev=child;child=new_item;
|
||||
value=skip(parse_value(child,skip(value+1)));
|
||||
if (!value) return 0; /* memory fail */
|
||||
@@ -415,8 +422,8 @@ static const char *parse_object(cJSON *item,const char *value)
|
||||
|
||||
while (*value==',')
|
||||
{
|
||||
cJSON *new_item;
|
||||
if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */
|
||||
cJSON *new_item = cJSON_New_Item();
|
||||
if (!new_item) return 0; /* memory fail */
|
||||
child->next=new_item;new_item->prev=child;child=new_item;
|
||||
value=skip(parse_string(child,skip(value+1)));
|
||||
if (!value) return 0;
|
||||
|
||||
@@ -352,7 +352,6 @@ int GetOptions(int argc, char** argv, Options* psOptions)
|
||||
{
|
||||
int i;
|
||||
int fullShaderChain = -1;
|
||||
int hashOut = 0;
|
||||
|
||||
InitOptions(psOptions);
|
||||
|
||||
@@ -415,9 +414,6 @@ int GetOptions(int argc, char** argv, Options* psOptions)
|
||||
|
||||
uint64_t hash = hash64((const uint8_t*)psOptions->outputShaderFile, (uint32_t)strlen(psOptions->outputShaderFile), 0);
|
||||
|
||||
uint32_t high = (uint32_t)(hash >> 32);
|
||||
uint32_t low = (uint32_t)(hash & 0x00000000FFFFFFFF);
|
||||
|
||||
dir = strrchr(psOptions->outputShaderFile, '\\');
|
||||
|
||||
if (!dir)
|
||||
|
||||
@@ -186,7 +186,6 @@ void MarkTextureAsShadow(ShaderInfo* psShaderInfo, Declaration* psDeclList, cons
|
||||
{
|
||||
(void)psShaderInfo;
|
||||
|
||||
ResourceBinding* psBinding = 0;
|
||||
Declaration* psDecl = psDeclList;
|
||||
uint32_t i;
|
||||
|
||||
@@ -733,11 +732,6 @@ const uint32_t* DecodeDeclaration(ShaderData* psShader, const uint32_t* pui32Tok
|
||||
{
|
||||
ui32TokenLength = pui32Token[1];
|
||||
{
|
||||
int iTupleSrc = 0, iTupleDest = 0;
|
||||
//const uint32_t ui32ConstCount = pui32Token[1] - 2;
|
||||
//const uint32_t ui32TupleCount = (ui32ConstCount / 4);
|
||||
CUSTOMDATA_CLASS eClass = DecodeCustomDataClass(pui32Token[0]);
|
||||
|
||||
const uint32_t ui32NumVec4 = (ui32TokenLength - 2) / 4;
|
||||
uint32_t uIdx = 0;
|
||||
|
||||
@@ -776,9 +770,6 @@ const uint32_t* DecodeDeclaration(ShaderData* psShader, const uint32_t* pui32Tok
|
||||
}
|
||||
case OPCODE_DCL_UNORDERED_ACCESS_VIEW_RAW:
|
||||
{
|
||||
ResourceBinding* psBinding = NULL;
|
||||
ConstantBuffer* psBuffer = NULL;
|
||||
|
||||
psDecl->ui32NumOperands = 1;
|
||||
psDecl->sUAV.ui32GloballyCoherentAccess = DecodeAccessCoherencyFlags(*pui32Token);
|
||||
psDecl->sUAV.bCounter = 0;
|
||||
@@ -830,9 +821,6 @@ const uint32_t* DecodeDeclaration(ShaderData* psShader, const uint32_t* pui32Tok
|
||||
}
|
||||
case OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_STRUCTURED:
|
||||
{
|
||||
ResourceBinding* psBinding = NULL;
|
||||
ConstantBuffer* psBuffer = NULL;
|
||||
|
||||
psDecl->ui32NumOperands = 1;
|
||||
psDecl->sUAV.ui32GloballyCoherentAccess = 0;
|
||||
|
||||
@@ -844,9 +832,6 @@ const uint32_t* DecodeDeclaration(ShaderData* psShader, const uint32_t* pui32Tok
|
||||
}
|
||||
case OPCODE_DCL_THREAD_GROUP_SHARED_MEMORY_RAW:
|
||||
{
|
||||
ResourceBinding* psBinding = NULL;
|
||||
ConstantBuffer* psBuffer = NULL;
|
||||
|
||||
psDecl->ui32NumOperands = 1;
|
||||
psDecl->sUAV.ui32GloballyCoherentAccess = 0;
|
||||
|
||||
@@ -1512,7 +1497,6 @@ void AllocateHullPhaseArrays(const uint32_t* pui32Tokens,
|
||||
while (1) //Keep going until we reach the first non-declaration token, or the end of the shader.
|
||||
{
|
||||
uint32_t ui32TokenLength = DecodeInstructionLength(*pui32CurrentToken);
|
||||
const uint32_t bExtended = DecodeIsOpcodeExtended(*pui32CurrentToken);
|
||||
const OPCODE_TYPE eOpcode = DecodeOpcodeType(*pui32CurrentToken);
|
||||
|
||||
if (eOpcode == OPCODE_CUSTOMDATA)
|
||||
|
||||
@@ -408,8 +408,6 @@ static void SetupRegisterUsage(const ShaderData* psShader, const uint32_t ui32To
|
||||
// In dx9 there is only one constant buffer per shader.
|
||||
static void DeclareConstantBuffer(const ShaderData* psShader, Declaration* psDecl)
|
||||
{
|
||||
DECLUSAGE_DX9 eUsage = (DECLUSAGE_DX9)0;
|
||||
uint32_t ui32UsageIndex = 0;
|
||||
// Pick any constant register in the table. Might not start at c0 (e.g. when register(cX) is used).
|
||||
uint32_t ui32RegNum = psShader->sInfo.psConstantBuffers->asVars[0].ui32StartOffset / 16;
|
||||
OPERAND_TYPE_DX9 ui32RegType = OPERAND_TYPE_DX9_CONST;
|
||||
@@ -447,9 +445,7 @@ static void DeclareConstantBuffer(const ShaderData* psShader, Declaration* psDec
|
||||
|
||||
static void DecodeDeclarationDX9(const ShaderData* psShader, const uint32_t ui32Token0, const uint32_t ui32Token1, Declaration* psDecl)
|
||||
{
|
||||
DECLUSAGE_DX9 eUsage = DecodeUsageDX9(ui32Token0);
|
||||
uint32_t ui32UsageIndex = DecodeUsageIndexDX9(ui32Token0);
|
||||
uint32_t ui32RegNum = DecodeOperandRegisterNumberDX9(ui32Token1);
|
||||
/*uint32_t ui32UsageIndex = DecodeUsageIndexDX9(ui32Token0);*/
|
||||
uint32_t ui32RegType = DecodeOperandTypeDX9(ui32Token1);
|
||||
|
||||
if (psShader->eShaderType == VERTEX_SHADER)
|
||||
|
||||
@@ -9,7 +9,29 @@
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
void* (*hlslcc_malloc)(size_t size) = malloc;
|
||||
void* (*hlslcc_calloc)(size_t num,size_t size) = calloc;
|
||||
void (*hlslcc_free)(void *p) = free;
|
||||
void* (*hlslcc_realloc)(void *p,size_t size) = realloc;
|
||||
// Wrapping these functions since we are taking the address of them and the std functions are dllimport which produce
|
||||
// warning C4232
|
||||
void* std_malloc(size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void* std_calloc(size_t num, size_t size)
|
||||
{
|
||||
return calloc(num, size);
|
||||
}
|
||||
|
||||
void std_free(void* p)
|
||||
{
|
||||
free(p);
|
||||
}
|
||||
|
||||
void* std_realloc(void* p, size_t size)
|
||||
{
|
||||
return realloc(p, size);
|
||||
}
|
||||
|
||||
void* (*hlslcc_malloc)(size_t size) = std_malloc;
|
||||
void* (*hlslcc_calloc)(size_t num,size_t size) = std_calloc;
|
||||
void (*hlslcc_free)(void *p) = std_free;
|
||||
void* (*hlslcc_realloc)(void *p,size_t size) = std_realloc;
|
||||
|
||||
@@ -12,4 +12,4 @@ extern void* (*hlslcc_realloc)(void *p,size_t size);
|
||||
#define bstr__alloc hlslcc_malloc
|
||||
#define bstr__free hlslcc_free
|
||||
#define bstr__realloc hlslcc_realloc
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -64,7 +64,7 @@ static void ReadInputSignatures(const uint32_t* pui32Tokens,
|
||||
InOutSignature* psSignatures;
|
||||
const uint32_t* pui32FirstSignatureToken = pui32Tokens;
|
||||
const uint32_t ui32ElementCount = *pui32Tokens++;
|
||||
const uint32_t ui32Key = *pui32Tokens++;
|
||||
/*const uint32_t ui32Key =*/ *pui32Tokens++;
|
||||
|
||||
psSignatures = hlslcc_malloc(sizeof(InOutSignature) * ui32ElementCount);
|
||||
psShaderInfo->psInputSignatures = psSignatures;
|
||||
@@ -114,7 +114,7 @@ static void ReadOutputSignatures(const uint32_t* pui32Tokens,
|
||||
InOutSignature* psSignatures;
|
||||
const uint32_t* pui32FirstSignatureToken = pui32Tokens;
|
||||
const uint32_t ui32ElementCount = *pui32Tokens++;
|
||||
const uint32_t ui32Key = *pui32Tokens++;
|
||||
/*const uint32_t ui32Key =*/ *pui32Tokens++;
|
||||
|
||||
psSignatures = hlslcc_malloc(sizeof(InOutSignature) * ui32ElementCount);
|
||||
psShaderInfo->psOutputSignatures = psSignatures;
|
||||
@@ -170,7 +170,7 @@ static void ReadPatchConstantSignatures(const uint32_t* pui32Tokens,
|
||||
InOutSignature* psSignatures;
|
||||
const uint32_t* pui32FirstSignatureToken = pui32Tokens;
|
||||
const uint32_t ui32ElementCount = *pui32Tokens++;
|
||||
const uint32_t ui32Key = *pui32Tokens++;
|
||||
/*const uint32_t ui32Key =*/ *pui32Tokens++;
|
||||
|
||||
psSignatures = hlslcc_malloc(sizeof(InOutSignature) * ui32ElementCount);
|
||||
psShaderInfo->psPatchConstantSignatures = psSignatures;
|
||||
@@ -338,10 +338,10 @@ static const uint32_t* ReadConstantBuffer(ShaderInfo* psShaderInfo,
|
||||
|
||||
if (psShaderInfo->ui32MajorVersion >= 5)
|
||||
{
|
||||
uint32_t StartTexture = *pui32VarToken++;
|
||||
uint32_t TextureSize = *pui32VarToken++;
|
||||
uint32_t StartSampler = *pui32VarToken++;
|
||||
uint32_t SamplerSize = *pui32VarToken++;
|
||||
/* uint32_t StartTexture = */ *pui32VarToken++;
|
||||
/* uint32_t TextureSize = */ *pui32VarToken++;
|
||||
/* uint32_t StartSampler = */ *pui32VarToken++;
|
||||
/* uint32_t SamplerSize = */ *pui32VarToken++;
|
||||
}
|
||||
|
||||
psVar->haveDefaultValue = 0;
|
||||
@@ -395,8 +395,8 @@ static void ReadResources(const uint32_t* pui32Tokens,//in
|
||||
|
||||
uint32_t ui32NumResourceBindings = *pui32Tokens++;
|
||||
uint32_t ui32ResourceBindingOffset = *pui32Tokens++;
|
||||
uint32_t ui32ShaderModel = *pui32Tokens++;
|
||||
uint32_t ui32CompileFlags = *pui32Tokens++;//D3DCompile flags? http://msdn.microsoft.com/en-us/library/gg615083(v=vs.85).aspx
|
||||
/*uint32_t ui32ShaderModel =*/ *pui32Tokens++;
|
||||
/*uint32_t ui32CompileFlags =*/ *pui32Tokens++;//D3DCompile flags? http://msdn.microsoft.com/en-us/library/gg615083(v=vs.85).aspx
|
||||
|
||||
//Resources
|
||||
pui32ResourceBindings = (const uint32_t*)((const char*)pui32FirstToken + ui32ResourceBindingOffset);
|
||||
@@ -490,7 +490,7 @@ static void ReadInterfaces(const uint32_t* pui32Tokens,
|
||||
const uint32_t ui32ClassInstanceCount = *pui32Tokens++;
|
||||
const uint32_t ui32ClassTypeCount = *pui32Tokens++;
|
||||
const uint32_t ui32InterfaceSlotRecordCount = *pui32Tokens++;
|
||||
const uint32_t ui32InterfaceSlotCount = *pui32Tokens++;
|
||||
/*const uint32_t ui32InterfaceSlotCount =*/ *pui32Tokens++;
|
||||
const uint32_t ui32ClassInstanceOffset = *pui32Tokens++;
|
||||
const uint32_t ui32ClassTypeOffset = *pui32Tokens++;
|
||||
const uint32_t ui32InterfaceSlotOffset = *pui32Tokens++;
|
||||
@@ -788,7 +788,6 @@ int GetShaderVarFromOffset(const uint32_t ui32Vec4Offset,
|
||||
int32_t* pi32Rebase)
|
||||
{
|
||||
uint32_t i;
|
||||
const uint32_t ui32BaseByteOffset = ui32Vec4Offset * 16;
|
||||
|
||||
uint32_t ui32ByteOffset = ui32Vec4Offset * 16;
|
||||
|
||||
@@ -870,7 +869,6 @@ void LoadShaderInfo(const uint32_t ui32MajorVersion,
|
||||
const uint32_t* pui32Outputs11 = psChunks->pui32Outputs11;
|
||||
const uint32_t* pui32OutputsWithStreams = psChunks->pui32OutputsWithStreams;
|
||||
const uint32_t* pui32PatchConstants = psChunks->pui32PatchConstants;
|
||||
const uint32_t* pui32Effects10Data = psChunks->pui32Effects10Data;
|
||||
|
||||
psInfo->eTessOutPrim = TESSELLATOR_OUTPUT_UNDEFINED;
|
||||
psInfo->eTessPartitioning = TESSELLATOR_PARTITIONING_UNDEFINED;
|
||||
|
||||
@@ -227,9 +227,9 @@ void PreDeclareStructType(bstring glsl, const char* Name, const struct ShaderVar
|
||||
|
||||
if(psType->Class == SVC_STRUCT)
|
||||
{
|
||||
|
||||
#if defined(_DEBUG)
|
||||
uint32_t unnamed_struct = strcmp(Name, "$Element") == 0 ? 1 : 0;
|
||||
|
||||
#endif
|
||||
//Not supported at the moment
|
||||
ASSERT(!unnamed_struct);
|
||||
|
||||
@@ -307,13 +307,16 @@ const char* GetDeclaredOutputName(const HLSLCrossCompilerContext* psContext,
|
||||
char* cstr;
|
||||
InOutSignature* psOut;
|
||||
|
||||
int foundOutput = GetOutputSignatureFromRegister(
|
||||
psContext->currentPhase,
|
||||
psOperand->ui32RegisterNumber,
|
||||
psOperand->ui32CompMask,
|
||||
psContext->psShader->ui32CurrentVertexOutputStream,
|
||||
&psContext->psShader->sInfo,
|
||||
&psOut);
|
||||
#if defined(_DEBUG)
|
||||
int foundOutput =
|
||||
#endif
|
||||
GetOutputSignatureFromRegister(
|
||||
psContext->currentPhase,
|
||||
psOperand->ui32RegisterNumber,
|
||||
psOperand->ui32CompMask,
|
||||
psContext->psShader->ui32CurrentVertexOutputStream,
|
||||
&psContext->psShader->sInfo,
|
||||
&psOut);
|
||||
|
||||
ASSERT(foundOutput);
|
||||
|
||||
@@ -463,7 +466,6 @@ static void DeclareInput(
|
||||
{
|
||||
if(iNumComponents == 1)
|
||||
{
|
||||
const uint32_t regNum = psDecl->asOperands[0].ui32RegisterNumber;
|
||||
const uint32_t arraySize = psDecl->asOperands[0].aui32ArraySizes[0];
|
||||
|
||||
psContext->psShader->abScalarInput[psDecl->asOperands[0].ui32RegisterNumber] = -1;
|
||||
@@ -1154,7 +1156,10 @@ void DeclareBufferVariable(HLSLCrossCompilerContext* psContext, const uint32_t u
|
||||
bstring glsl)
|
||||
{
|
||||
bstring StructName;
|
||||
uint32_t unnamed_struct = strcmp(psCBuf->asVars[0].Name, "$Element") == 0 ? 1 : 0;
|
||||
#if defined(_DEBUG)
|
||||
uint32_t unnamed_struct =
|
||||
#endif
|
||||
strcmp(psCBuf->asVars[0].Name, "$Element") == 0 ? 1 : 0;
|
||||
|
||||
ASSERT(psCBuf->ui32NumVars == 1);
|
||||
ASSERT(unnamed_struct);
|
||||
@@ -1868,7 +1873,6 @@ Would generate a vec2 and a vec3. We discard the second one making .z invalid!
|
||||
}
|
||||
case OPCODE_DCL_TEMPS:
|
||||
{
|
||||
uint32_t i = 0;
|
||||
const uint32_t ui32NumTemps = psDecl->value.ui32NumTemps;
|
||||
|
||||
if(ui32NumTemps > 0)
|
||||
|
||||
@@ -289,7 +289,6 @@ static void GLSLAddComparision(HLSLCrossCompilerContext* psContext, Instruction*
|
||||
static void GLSLAddMOVBinaryOp(HLSLCrossCompilerContext* psContext, const Operand* pDest, Operand* pSrc)
|
||||
{
|
||||
int numParenthesis = 0;
|
||||
int destComponents = GetMaxComponentFromComponentMask(pDest);
|
||||
int srcSwizzleCount = GetNumSwizzleElements(pSrc);
|
||||
uint32_t writeMask = GetOperandWriteMask(pDest);
|
||||
|
||||
@@ -318,7 +317,6 @@ static void GLSLAddMOVCBinaryOp(HLSLCrossCompilerContext* psContext, const Opera
|
||||
uint32_t destElem;
|
||||
|
||||
const SHADER_VARIABLE_TYPE eDestType = GetOperandDataType(psContext, pDest);
|
||||
const SHADER_VARIABLE_TYPE eSrc0Type = GetOperandDataType(psContext, src0);
|
||||
/*
|
||||
for each component in dest[.mask]
|
||||
if the corresponding component in src0 (POS-swizzle)
|
||||
@@ -499,9 +497,6 @@ static void GLSLCallTernaryOp(HLSLCrossCompilerContext* psContext,
|
||||
uint32_t dataType)
|
||||
{
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
uint32_t src2SwizCount = GetNumSwizzleElements(&psInst->asOperands[src2]);
|
||||
uint32_t src1SwizCount = GetNumSwizzleElements(&psInst->asOperands[src1]);
|
||||
uint32_t src0SwizCount = GetNumSwizzleElements(&psInst->asOperands[src0]);
|
||||
uint32_t dstSwizCount = GetNumSwizzleElements(&psInst->asOperands[dest]);
|
||||
uint32_t destMask = GetOperandWriteMask(&psInst->asOperands[dest]);
|
||||
|
||||
@@ -532,9 +527,6 @@ static void GLSLCallHelper3(HLSLCrossCompilerContext* psContext,
|
||||
uint32_t ui32Flags = TO_AUTO_BITCAST_TO_FLOAT;
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMask(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
|
||||
uint32_t src2SwizCount = GetNumSwizzleElements(&psInst->asOperands[src2]);
|
||||
uint32_t src1SwizCount = GetNumSwizzleElements(&psInst->asOperands[src1]);
|
||||
uint32_t src0SwizCount = GetNumSwizzleElements(&psInst->asOperands[src0]);
|
||||
uint32_t dstSwizCount = GetNumSwizzleElements(&psInst->asOperands[dest]);
|
||||
int numParenthesis = 0;
|
||||
|
||||
@@ -558,8 +550,6 @@ GLSLCallHelper2(HLSLCrossCompilerContext* psContext, const char* name, Instructi
|
||||
uint32_t ui32Flags = TO_AUTO_BITCAST_TO_FLOAT;
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMask(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
|
||||
uint32_t src1SwizCount = GetNumSwizzleElements(&psInst->asOperands[src1]);
|
||||
uint32_t src0SwizCount = GetNumSwizzleElements(&psInst->asOperands[src0]);
|
||||
uint32_t dstSwizCount = GetNumSwizzleElements(&psInst->asOperands[dest]);
|
||||
|
||||
int isDotProduct = (strncmp(name, "dot", 3) == 0) ? 1 : 0;
|
||||
@@ -583,8 +573,6 @@ GLSLCallHelper2Int(HLSLCrossCompilerContext* psContext, const char* name, Instru
|
||||
{
|
||||
uint32_t ui32Flags = TO_AUTO_BITCAST_TO_INT;
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
uint32_t src1SwizCount = GetNumSwizzleElements(&psInst->asOperands[src1]);
|
||||
uint32_t src0SwizCount = GetNumSwizzleElements(&psInst->asOperands[src0]);
|
||||
uint32_t dstSwizCount = GetNumSwizzleElements(&psInst->asOperands[dest]);
|
||||
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMask(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
|
||||
int numParenthesis = 0;
|
||||
@@ -606,8 +594,6 @@ GLSLCallHelper2UInt(HLSLCrossCompilerContext* psContext, const char* name, Instr
|
||||
{
|
||||
uint32_t ui32Flags = TO_AUTO_BITCAST_TO_UINT;
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
uint32_t src1SwizCount = GetNumSwizzleElements(&psInst->asOperands[src1]);
|
||||
uint32_t src0SwizCount = GetNumSwizzleElements(&psInst->asOperands[src0]);
|
||||
uint32_t dstSwizCount = GetNumSwizzleElements(&psInst->asOperands[dest]);
|
||||
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMask(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
|
||||
int numParenthesis = 0;
|
||||
@@ -628,7 +614,6 @@ static void GLSLCallHelper1(HLSLCrossCompilerContext* psContext, const char* nam
|
||||
{
|
||||
uint32_t ui32Flags = TO_AUTO_BITCAST_TO_FLOAT;
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
uint32_t src0SwizCount = GetNumSwizzleElements(&psInst->asOperands[src0]);
|
||||
uint32_t dstSwizCount = GetNumSwizzleElements(&psInst->asOperands[dest]);
|
||||
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMask(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
|
||||
int numParenthesis = 0;
|
||||
@@ -653,7 +638,6 @@ static void GLSLCallHelper1Int(HLSLCrossCompilerContext* psContext,
|
||||
{
|
||||
uint32_t ui32Flags = TO_AUTO_BITCAST_TO_INT;
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
uint32_t src0SwizCount = GetNumSwizzleElements(&psInst->asOperands[src0]);
|
||||
uint32_t dstSwizCount = GetNumSwizzleElements(&psInst->asOperands[dest]);
|
||||
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMask(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
|
||||
int numParenthesis = 0;
|
||||
@@ -818,9 +802,7 @@ static void GLSLTranslateTexelFetchOffset(HLSLCrossCompilerContext* psContext, I
|
||||
// Currently supports floating point coord only, so not used for texelFetch.
|
||||
static void GLSLTranslateTexCoord(HLSLCrossCompilerContext* psContext, const RESOURCE_DIMENSION eResDim, Operand* psTexCoordOperand)
|
||||
{
|
||||
int numParenthesis = 0;
|
||||
uint32_t flags = TO_AUTO_BITCAST_TO_FLOAT;
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
uint32_t opMask = OPERAND_4_COMPONENT_MASK_ALL;
|
||||
|
||||
switch (eResDim)
|
||||
@@ -866,9 +848,7 @@ static void GLSLTranslateTexCoord(HLSLCrossCompilerContext* psContext, const RES
|
||||
|
||||
static int GLSLGetNumTextureDimensions(HLSLCrossCompilerContext* psContext, const RESOURCE_DIMENSION eResDim)
|
||||
{
|
||||
int constructor = 0;
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
|
||||
(void)psContext;
|
||||
switch (eResDim)
|
||||
{
|
||||
case RESOURCE_DIMENSION_TEXTURE1D:
|
||||
@@ -1299,7 +1279,6 @@ static void GLSLTranslateShaderStorageStore(HLSLCrossCompilerContext* psContext,
|
||||
{
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
ShaderVarType* psVarType = NULL;
|
||||
uint32_t ui32DataTypeFlag = TO_FLAG_INTEGER;
|
||||
int component;
|
||||
int srcComponent = 0;
|
||||
|
||||
@@ -1308,7 +1287,6 @@ static void GLSLTranslateShaderStorageStore(HLSLCrossCompilerContext* psContext,
|
||||
Operand* psDestByteOff = 0;
|
||||
Operand* psSrc = 0;
|
||||
int structured = 0;
|
||||
int groupshared = 0;
|
||||
|
||||
switch (psInst->eOpcode)
|
||||
{
|
||||
@@ -1329,11 +1307,9 @@ static void GLSLTranslateShaderStorageStore(HLSLCrossCompilerContext* psContext,
|
||||
|
||||
for (component = 0; component < 4; component++)
|
||||
{
|
||||
const char* swizzleString[] = {".x", ".y", ".z", ".w"};
|
||||
ASSERT(psInst->asOperands[0].eSelMode == OPERAND_4_COMPONENT_MASK_MODE);
|
||||
if (psInst->asOperands[0].ui32CompMask & (1 << component))
|
||||
{
|
||||
SHADER_VARIABLE_TYPE eSrcDataType = GetOperandDataType(psContext, psSrc);
|
||||
|
||||
if (structured && psDest->eType != OPERAND_TYPE_THREAD_GROUP_SHARED_MEMORY)
|
||||
{
|
||||
@@ -1432,11 +1408,7 @@ static void GLSLTranslateShaderStorageStore(HLSLCrossCompilerContext* psContext,
|
||||
static void GLSLTranslateShaderStorageLoad(HLSLCrossCompilerContext* psContext, Instruction* psInst)
|
||||
{
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
ShaderVarType* psVarType = NULL;
|
||||
uint32_t aui32Swizzle[4] = {OPERAND_4_COMPONENT_X};
|
||||
uint32_t ui32DataTypeFlag = TO_FLAG_INTEGER;
|
||||
int component;
|
||||
int destComponent = 0;
|
||||
Operand* psDest = 0;
|
||||
Operand* psSrcAddr = 0;
|
||||
Operand* psSrcByteOff = 0;
|
||||
@@ -2268,7 +2240,6 @@ void SetDataTypes(HLSLCrossCompilerContext* psContext, Instruction* psInst, cons
|
||||
// Only ever to int->float promotion (or int->uint), never the other way around
|
||||
for (i = 0; i < i32InstCount; ++i, psInst++)
|
||||
{
|
||||
int k = 0;
|
||||
if (psInst->ui32NumOperands == 0)
|
||||
continue;
|
||||
|
||||
@@ -2644,9 +2615,6 @@ void TranslateInstruction(HLSLCrossCompilerContext* psContext, Instruction* psIn
|
||||
{
|
||||
uint32_t dstCount = GetNumSwizzleElements(&psInst->asOperands[0]);
|
||||
uint32_t srcCount = GetNumSwizzleElements(&psInst->asOperands[1]);
|
||||
uint32_t ui32DstFlags = TO_FLAG_DESTINATION;
|
||||
const SHADER_VARIABLE_TYPE eSrcType = GetOperandDataType(psContext, &psInst->asOperands[1]);
|
||||
const SHADER_VARIABLE_TYPE eDestType = GetOperandDataType(psContext, &psInst->asOperands[0]);
|
||||
|
||||
#ifdef _DEBUG
|
||||
AddIndentation(psContext);
|
||||
@@ -2683,8 +2651,6 @@ void TranslateInstruction(HLSLCrossCompilerContext* psContext, Instruction* psIn
|
||||
case OPCODE_ITOF: // signed to float
|
||||
case OPCODE_UTOF: // unsigned to float
|
||||
{
|
||||
const SHADER_VARIABLE_TYPE eDestType = GetOperandDataType(psContext, &psInst->asOperands[0]);
|
||||
const SHADER_VARIABLE_TYPE eSrcType = GetOperandDataType(psContext, &psInst->asOperands[1]);
|
||||
uint32_t dstCount = GetNumSwizzleElements(&psInst->asOperands[0]);
|
||||
uint32_t srcCount = GetNumSwizzleElements(&psInst->asOperands[1]);
|
||||
|
||||
@@ -2886,7 +2852,6 @@ void TranslateInstruction(HLSLCrossCompilerContext* psContext, Instruction* psIn
|
||||
|
||||
case OPCODE_DP2:
|
||||
{
|
||||
SHADER_VARIABLE_TYPE eDestDataType = GetOperandDataType(psContext, &psInst->asOperands[0]);
|
||||
int numParenthesis2 = 0;
|
||||
#ifdef _DEBUG
|
||||
AddIndentation(psContext);
|
||||
@@ -3918,7 +3883,6 @@ void TranslateInstruction(HLSLCrossCompilerContext* psContext, Instruction* psIn
|
||||
case OPCODE_LD_MS:
|
||||
{
|
||||
ResourceBinding* psBinding = 0;
|
||||
uint32_t dstSwizCount = GetNumSwizzleElements(&psInst->asOperands[0]);
|
||||
#ifdef _DEBUG
|
||||
AddIndentation(psContext);
|
||||
if (psInst->eOpcode == OPCODE_LD)
|
||||
@@ -4463,8 +4427,6 @@ void TranslateInstruction(HLSLCrossCompilerContext* psContext, Instruction* psIn
|
||||
}
|
||||
case OPCODE_RESINFO:
|
||||
{
|
||||
const RESOURCE_DIMENSION eResDim = psContext->psShader->aeResourceDims[psInst->asOperands[2].ui32RegisterNumber];
|
||||
const RESINFO_RETURN_TYPE eResInfoReturnType = psInst->eResInfoReturnType;
|
||||
uint32_t destElemCount = GetNumSwizzleElements(&psInst->asOperands[0]);
|
||||
uint32_t destElem;
|
||||
#ifdef _DEBUG
|
||||
@@ -4474,7 +4436,6 @@ void TranslateInstruction(HLSLCrossCompilerContext* psContext, Instruction* psIn
|
||||
|
||||
for (destElem = 0; destElem < destElemCount; ++destElem)
|
||||
{
|
||||
const char* swizzle[] = {".x", ".y", ".z", ".w"};
|
||||
|
||||
GetResInfoData(psContext, psInst, psInst->asOperands[2].aui32Swizzle[destElem], destElem);
|
||||
}
|
||||
|
||||
@@ -1677,7 +1677,6 @@ void TranslateOperandWithMask(HLSLCrossCompilerContext* psContext, const Operand
|
||||
{
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
uint32_t ui32IgnoreSwizzle = 0;
|
||||
SHADER_VARIABLE_TYPE eType = GetOperandDataTypeEx(psContext, psOperand, TypeFlagsToSVTType(ui32TOFlag));
|
||||
|
||||
if (psContext->psShader->ui32MajorVersion <= 3)
|
||||
{
|
||||
|
||||
@@ -113,7 +113,6 @@ void TranslateToMETAL(HLSLCrossCompilerContext* psContext, ShaderLang* planguage
|
||||
{
|
||||
int hasStageInput = 0;
|
||||
int hasOutput = 0;
|
||||
int inputDeclLength = blength(psContext->parameterDeclarations);
|
||||
if (blength(psContext->stagedInputDeclarations) > 0)
|
||||
{
|
||||
hasStageInput = 1;
|
||||
@@ -189,7 +188,6 @@ void TranslateToMETAL(HLSLCrossCompilerContext* psContext, ShaderLang* planguage
|
||||
{
|
||||
int hasStageInput = 0;
|
||||
int hasOutput = 0;
|
||||
int inputDeclLength = blength(psContext->parameterDeclarations);
|
||||
if (blength(psContext->stagedInputDeclarations) > 0)
|
||||
{
|
||||
hasStageInput = 1;
|
||||
|
||||
@@ -284,7 +284,9 @@ void PreDeclareStructTypeMETAL(bstring metal, const char* Name, const struct Sha
|
||||
|
||||
if (psType->Class == SVC_STRUCT)
|
||||
{
|
||||
#if defined(_DEBUG)
|
||||
uint32_t unnamed_struct = strcmp(Name, "$Element") == 0 ? 1 : 0;
|
||||
#endif
|
||||
|
||||
//Not supported at the moment
|
||||
ASSERT(!unnamed_struct);
|
||||
@@ -335,7 +337,10 @@ char* GetDeclaredOutputNameMETAL(const HLSLCrossCompilerContext* psContext,
|
||||
char* cstr;
|
||||
InOutSignature* psOut;
|
||||
|
||||
int foundOutput = GetOutputSignatureFromRegister(
|
||||
#if defined(_DEBUG)
|
||||
int foundOutput =
|
||||
#endif
|
||||
GetOutputSignatureFromRegister(
|
||||
psContext->currentPhase,
|
||||
psOperand->ui32RegisterNumber,
|
||||
psOperand->ui32CompMask,
|
||||
@@ -422,7 +427,6 @@ static void DeclareInput(
|
||||
{
|
||||
|
||||
InOutSignature* psSignature = NULL;
|
||||
int emptyQualifier = 0;
|
||||
|
||||
const char* type = "float";
|
||||
if (minPrecision == OPERAND_MIN_PRECISION_FLOAT_16)
|
||||
@@ -506,7 +510,6 @@ static void DeclareInput(
|
||||
psContext->psShader->abScalarInput[psDecl->asOperands[0].ui32RegisterNumber] = -1;
|
||||
}
|
||||
|
||||
const uint32_t regNum = psDecl->asOperands[0].ui32RegisterNumber;
|
||||
const uint32_t arraySize = psDecl->asOperands[0].aui32ArraySizes[0];
|
||||
|
||||
bformata(metal, " [%d]", arraySize);
|
||||
@@ -714,7 +717,6 @@ void AddBuiltinOutputMETAL(HLSLCrossCompilerContext* psContext, const Declaratio
|
||||
|
||||
if (OutputNeedsDeclaringMETAL(psContext, &psDecl->asOperands[0], arrayElements ? arrayElements : 1))
|
||||
{
|
||||
char* OutputName = GetDeclaredOutputNameMETAL(psContext, VERTEX_SHADER, &psDecl->asOperands[0]);
|
||||
psContext->currentShaderString = &psContext->declaredOutputs;
|
||||
metal = *psContext->currentShaderString;
|
||||
InOutSignature* psSignature = NULL;
|
||||
@@ -826,8 +828,6 @@ void AddUserOutputMETAL(HLSLCrossCompilerContext* psContext, const Declaration*
|
||||
case VERTEX_SHADER:
|
||||
{
|
||||
int iNumComponents = 4;//GetMaxComponentFromComponentMaskMETAL(&psDecl->asOperands[0]);
|
||||
const char* Interpolation = "";
|
||||
int stream = 0;
|
||||
char* OutputName = GetDeclaredOutputNameMETAL(psContext, VERTEX_SHADER, psOperand);
|
||||
|
||||
bformata(metal, "%s%d %s [[ user(varying%d) ]];\n", type, iNumComponents, OutputName, psDecl->asOperands[0].ui32RegisterNumber);
|
||||
@@ -850,7 +850,9 @@ void DeclareBufferVariableMETAL(HLSLCrossCompilerContext* psContext, const uint3
|
||||
(void)ui32BindingPoint;
|
||||
|
||||
bstring StructName;
|
||||
#if !defined(NDEBUG)
|
||||
uint32_t unnamed_struct = strcmp(psCBuf->asVars[0].Name, "$Element") == 0 ? 1 : 0;
|
||||
#endif
|
||||
|
||||
ASSERT(psCBuf->ui32NumVars == 1);
|
||||
ASSERT(unnamed_struct);
|
||||
@@ -1320,7 +1322,6 @@ char* GetSamplerTypeMETAL(HLSLCrossCompilerContext* psContext,
|
||||
static void TranslateResourceTexture(HLSLCrossCompilerContext* psContext, const Declaration* psDecl, uint32_t samplerCanDoShadowCmp)
|
||||
{
|
||||
bstring metal = *psContext->currentShaderString;
|
||||
ShaderData* psShader = psContext->psShader;
|
||||
|
||||
const char* samplerTypeName = GetSamplerTypeMETAL(psContext,
|
||||
psDecl->value.eResourceDimension,
|
||||
@@ -1534,9 +1535,7 @@ void TranslateDeclarationMETAL(HLSLCrossCompilerContext* psContext, const Declar
|
||||
{
|
||||
const Operand* psOperand = &psDecl->asOperands[0];
|
||||
int iNumComponents = 4;//GetMaxComponentFromComponentMask(psOperand);
|
||||
const char* StorageQualifier = "";
|
||||
const char* InputName = GetDeclaredInputNameMETAL(psContext, PIXEL_SHADER, psOperand);
|
||||
const char* Interpolation = "";
|
||||
|
||||
DeclareInput(psContext, psDecl,
|
||||
"user", (OPERAND_MIN_PRECISION)psOperand->eMinPrecision, iNumComponents, INDEX_1D, InputName);
|
||||
@@ -1545,7 +1544,6 @@ void TranslateDeclarationMETAL(HLSLCrossCompilerContext* psContext, const Declar
|
||||
}
|
||||
case OPCODE_DCL_TEMPS:
|
||||
{
|
||||
uint32_t i = 0;
|
||||
const uint32_t ui32NumTemps = psDecl->value.ui32NumTemps;
|
||||
|
||||
if (ui32NumTemps > 0)
|
||||
|
||||
@@ -327,7 +327,6 @@ static void METALAddComparision(HLSLCrossCompilerContext* psContext, Instruction
|
||||
static void METALAddMOVBinaryOp(HLSLCrossCompilerContext* psContext, const Operand* pDest, Operand* pSrc)
|
||||
{
|
||||
int numParenthesis = 0;
|
||||
int destComponents = GetMaxComponentFromComponentMaskMETAL(pDest);
|
||||
int srcSwizzleCount = GetNumSwizzleElementsMETAL(pSrc);
|
||||
uint32_t writeMask = GetOperandWriteMaskMETAL(pDest);
|
||||
|
||||
@@ -356,7 +355,6 @@ static void METALAddMOVCBinaryOp(HLSLCrossCompilerContext* psContext, const Oper
|
||||
uint32_t destElem;
|
||||
|
||||
const SHADER_VARIABLE_TYPE eDestType = GetOperandDataTypeMETAL(psContext, pDest);
|
||||
const SHADER_VARIABLE_TYPE eSrc0Type = GetOperandDataTypeMETAL(psContext, src0);
|
||||
/*
|
||||
for each component in dest[.mask]
|
||||
if the corresponding component in src0 (POS-swizzle)
|
||||
@@ -566,9 +564,6 @@ static void METALCallTernaryOp(HLSLCrossCompilerContext* psContext, const char*
|
||||
int dest, int src0, int src1, int src2, uint32_t dataType)
|
||||
{
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
uint32_t src2SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src2]);
|
||||
uint32_t src1SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src1]);
|
||||
uint32_t src0SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src0]);
|
||||
uint32_t dstSwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[dest]);
|
||||
uint32_t destMask = GetOperandWriteMaskMETAL(&psInst->asOperands[dest]);
|
||||
|
||||
@@ -596,9 +591,6 @@ static void METALCallHelper3(HLSLCrossCompilerContext* psContext, const char* na
|
||||
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMaskMETAL(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
|
||||
uint32_t src2SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src2]);
|
||||
uint32_t src1SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src1]);
|
||||
uint32_t src0SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src0]);
|
||||
uint32_t dstSwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[dest]);
|
||||
int numParenthesis = 0;
|
||||
|
||||
@@ -625,8 +617,6 @@ static void METALCallHelper2(HLSLCrossCompilerContext* psContext, const char* na
|
||||
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMaskMETAL(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
|
||||
uint32_t src1SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src1]);
|
||||
uint32_t src0SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src0]);
|
||||
uint32_t dstSwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[dest]);
|
||||
|
||||
int isDotProduct = (strncmp(name, "dot", 3) == 0) ? 1 : 0;
|
||||
@@ -650,8 +640,6 @@ static void METALCallHelper2Int(HLSLCrossCompilerContext* psContext, const char*
|
||||
{
|
||||
uint32_t ui32Flags = TO_AUTO_BITCAST_TO_INT;
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
uint32_t src1SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src1]);
|
||||
uint32_t src0SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src0]);
|
||||
uint32_t dstSwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[dest]);
|
||||
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMaskMETAL(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
|
||||
int numParenthesis = 0;
|
||||
@@ -673,8 +661,6 @@ static void METALCallHelper2UInt(HLSLCrossCompilerContext* psContext, const char
|
||||
{
|
||||
uint32_t ui32Flags = TO_AUTO_BITCAST_TO_UINT;
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
uint32_t src1SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src1]);
|
||||
uint32_t src0SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src0]);
|
||||
uint32_t dstSwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[dest]);
|
||||
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMaskMETAL(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
|
||||
int numParenthesis = 0;
|
||||
@@ -696,7 +682,6 @@ static void METALCallHelper1(HLSLCrossCompilerContext* psContext, const char* na
|
||||
{
|
||||
uint32_t ui32Flags = TO_AUTO_BITCAST_TO_FLOAT;
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
uint32_t src0SwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[src0]);
|
||||
uint32_t dstSwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[dest]);
|
||||
uint32_t destMask = paramsShouldFollowWriteMask ? GetOperandWriteMaskMETAL(&psInst->asOperands[dest]) : OPERAND_4_COMPONENT_MASK_ALL;
|
||||
int numParenthesis = 0;
|
||||
@@ -742,7 +727,6 @@ static void METALTranslateTexelFetch(HLSLCrossCompilerContext* psContext,
|
||||
bstring metal)
|
||||
{
|
||||
int numParenthesis = 0;
|
||||
uint32_t destCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[0]);
|
||||
AddIndentation(psContext);
|
||||
METALAddAssignToDest(psContext, &psInst->asOperands[0], TypeFlagsToSVTTypeMETAL(METALResourceReturnTypeToFlag(psBinding->ui32ReturnType)), 4, &numParenthesis);
|
||||
|
||||
@@ -998,7 +982,6 @@ static void METALTranslateTexCoord(HLSLCrossCompilerContext* psContext,
|
||||
const RESOURCE_DIMENSION eResDim,
|
||||
Operand* psTexCoordOperand)
|
||||
{
|
||||
int numParenthesis = 0;
|
||||
uint32_t flags = TO_AUTO_BITCAST_TO_FLOAT;
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
uint32_t opMask = OPERAND_4_COMPONENT_MASK_ALL;
|
||||
@@ -1059,9 +1042,7 @@ static void METALTranslateTexCoord(HLSLCrossCompilerContext* psContext,
|
||||
static int METALGetNumTextureDimensions(HLSLCrossCompilerContext* psContext,
|
||||
const RESOURCE_DIMENSION eResDim)
|
||||
{
|
||||
int constructor = 0;
|
||||
bstring glsl = *psContext->currentShaderString;
|
||||
|
||||
(void)psContext;
|
||||
switch (eResDim)
|
||||
{
|
||||
case RESOURCE_DIMENSION_TEXTURE1D:
|
||||
@@ -1176,7 +1157,6 @@ static void METALTranslateTextureSample(HLSLCrossCompilerContext* psContext, Ins
|
||||
int numParenthesis = 0;
|
||||
|
||||
const char* funcName = "sample";
|
||||
const char* offset = "";
|
||||
const char* depthCmpCoordType = "";
|
||||
const char* gradSwizzle = "";
|
||||
|
||||
@@ -1515,7 +1495,6 @@ static void METALTranslateShaderStorageStore(HLSLCrossCompilerContext* psContext
|
||||
{
|
||||
bstring metal = *psContext->currentShaderString;
|
||||
ShaderVarType* psVarType = NULL;
|
||||
uint32_t ui32DataTypeFlag = TO_FLAG_INTEGER;
|
||||
int component;
|
||||
int srcComponent = 0;
|
||||
|
||||
@@ -1524,7 +1503,6 @@ static void METALTranslateShaderStorageStore(HLSLCrossCompilerContext* psContext
|
||||
Operand* psDestByteOff = 0;
|
||||
Operand* psSrc = 0;
|
||||
int structured = 0;
|
||||
int groupshared = 0;
|
||||
|
||||
switch (psInst->eOpcode)
|
||||
{
|
||||
@@ -1549,7 +1527,6 @@ static void METALTranslateShaderStorageStore(HLSLCrossCompilerContext* psContext
|
||||
ASSERT(psInst->asOperands[0].eSelMode == OPERAND_4_COMPONENT_MASK_MODE);
|
||||
if (psInst->asOperands[0].ui32CompMask & (1 << component))
|
||||
{
|
||||
SHADER_VARIABLE_TYPE eSrcDataType = GetOperandDataTypeMETAL(psContext, psSrc);
|
||||
|
||||
if (structured && psDest->eType != OPERAND_TYPE_THREAD_GROUP_SHARED_MEMORY)
|
||||
{
|
||||
@@ -1764,11 +1741,7 @@ static void METALTranslateShaderStorageStore(HLSLCrossCompilerContext* psContext
|
||||
static void METALTranslateShaderStorageLoad(HLSLCrossCompilerContext* psContext, Instruction* psInst)
|
||||
{
|
||||
bstring metal = *psContext->currentShaderString;
|
||||
ShaderVarType* psVarType = NULL;
|
||||
uint32_t aui32Swizzle[4] = { OPERAND_4_COMPONENT_X };
|
||||
uint32_t ui32DataTypeFlag = TO_FLAG_INTEGER;
|
||||
int component;
|
||||
int destComponent = 0;
|
||||
Operand* psDest = 0;
|
||||
Operand* psSrcAddr = 0;
|
||||
Operand* psSrcByteOff = 0;
|
||||
@@ -1939,11 +1912,6 @@ static void METALTranslateShaderStorageLoad(HLSLCrossCompilerContext* psContext,
|
||||
if (psVar->Class != SVC_SCALAR)
|
||||
{
|
||||
static const char* const m_swizzlers[] = { "x", "y", "z", "w" };
|
||||
if (bytes > 16)
|
||||
{
|
||||
int i = 0;
|
||||
}
|
||||
|
||||
int offset = (bytes % 16) / 4;
|
||||
if (offset == 0)
|
||||
{
|
||||
@@ -2338,7 +2306,10 @@ void TranslateAtomicMemOpMETAL(HLSLCrossCompilerContext* psContext, Instruction*
|
||||
else
|
||||
{
|
||||
ResourceBinding* psRes;
|
||||
int foundResource = GetResourceFromBindingPoint(RGROUP_UAV,
|
||||
#if defined(_DEBUG)
|
||||
int foundResource =
|
||||
#endif
|
||||
GetResourceFromBindingPoint(RGROUP_UAV,
|
||||
dest->ui32RegisterNumber,
|
||||
&psContext->psShader->sInfo,
|
||||
&psRes);
|
||||
@@ -2655,7 +2626,6 @@ void SetDataTypesMETAL(HLSLCrossCompilerContext* psContext, Instruction* psInst,
|
||||
// Only ever to int->float promotion (or int->uint), never the other way around
|
||||
for (i = 0; i < i32InstCount; ++i, psInst++)
|
||||
{
|
||||
int k = 0;
|
||||
if (psInst->ui32NumOperands == 0)
|
||||
{
|
||||
continue;
|
||||
@@ -3065,14 +3035,16 @@ void DetectAtomicInstructionMETAL(HLSLCrossCompilerContext* psContext, Instructi
|
||||
return;
|
||||
}
|
||||
|
||||
ShaderVarType* psVarType = NULL;
|
||||
if (dest->eType == OPERAND_TYPE_THREAD_GROUP_SHARED_MEMORY)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
ResourceBinding* psRes;
|
||||
int foundResource = GetResourceFromBindingPoint(RGROUP_UAV,
|
||||
#if defined(_DEBUG)
|
||||
int foundResource =
|
||||
#endif
|
||||
GetResourceFromBindingPoint(RGROUP_UAV,
|
||||
dest->ui32RegisterNumber,
|
||||
&psContext->psShader->sInfo,
|
||||
&psRes);
|
||||
@@ -3120,9 +3092,6 @@ void TranslateInstructionMETAL(HLSLCrossCompilerContext* psContext, Instruction*
|
||||
{
|
||||
uint32_t dstCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[0]);
|
||||
uint32_t srcCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[1]);
|
||||
uint32_t ui32DstFlags = TO_FLAG_DESTINATION;
|
||||
const SHADER_VARIABLE_TYPE eSrcType = GetOperandDataTypeMETAL(psContext, &psInst->asOperands[1]);
|
||||
const SHADER_VARIABLE_TYPE eDestType = GetOperandDataTypeMETAL(psContext, &psInst->asOperands[0]);
|
||||
|
||||
#ifdef _DEBUG
|
||||
AddIndentation(psContext);
|
||||
@@ -3165,8 +3134,6 @@ void TranslateInstructionMETAL(HLSLCrossCompilerContext* psContext, Instruction*
|
||||
case OPCODE_ITOF://signed to float
|
||||
case OPCODE_UTOF://unsigned to float
|
||||
{
|
||||
const SHADER_VARIABLE_TYPE eDestType = GetOperandDataTypeMETAL(psContext, &psInst->asOperands[0]);
|
||||
const SHADER_VARIABLE_TYPE eSrcType = GetOperandDataTypeMETAL(psContext, &psInst->asOperands[1]);
|
||||
uint32_t dstCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[0]);
|
||||
uint32_t srcCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[1]);
|
||||
uint32_t destMask = GetOperandWriteMaskMETAL(&psInst->asOperands[0]);
|
||||
@@ -3676,7 +3643,6 @@ void TranslateInstructionMETAL(HLSLCrossCompilerContext* psContext, Instruction*
|
||||
case OPCODE_GATHER4_PO_C:
|
||||
{
|
||||
//dest, coords, offset, tex, sampler, srcReferenceValue
|
||||
const RESOURCE_DIMENSION eResDim = psContext->psShader->aeResourceDims[psInst->asOperands[3].ui32RegisterNumber];
|
||||
|
||||
#ifdef _DEBUG
|
||||
AddIndentation(psContext);
|
||||
@@ -4303,7 +4269,6 @@ void TranslateInstructionMETAL(HLSLCrossCompilerContext* psContext, Instruction*
|
||||
case OPCODE_LD_MS:
|
||||
{
|
||||
ResourceBinding* psBinding = 0;
|
||||
uint32_t dstSwizCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[0]);
|
||||
#ifdef _DEBUG
|
||||
AddIndentation(psContext);
|
||||
if (psInst->eOpcode == OPCODE_LD)
|
||||
@@ -4830,8 +4795,6 @@ void TranslateInstructionMETAL(HLSLCrossCompilerContext* psContext, Instruction*
|
||||
}
|
||||
case OPCODE_RESINFO:
|
||||
{
|
||||
const RESOURCE_DIMENSION eResDim = psContext->psShader->aeResourceDims[psInst->asOperands[2].ui32RegisterNumber];
|
||||
const RESINFO_RETURN_TYPE eResInfoReturnType = psInst->eResInfoReturnType;
|
||||
uint32_t destElemCount = GetNumSwizzleElementsMETAL(&psInst->asOperands[0]);
|
||||
uint32_t destElem;
|
||||
#ifdef _DEBUG
|
||||
@@ -4841,7 +4804,6 @@ void TranslateInstructionMETAL(HLSLCrossCompilerContext* psContext, Instruction*
|
||||
|
||||
for (destElem = 0; destElem < destElemCount; ++destElem)
|
||||
{
|
||||
const char* swizzle[] = { ".x", ".y", ".z", ".w" };
|
||||
|
||||
GetResInfoDataMETAL(psContext, psInst, psInst->asOperands[2].aui32Swizzle[destElem], destElem);
|
||||
}
|
||||
|
||||
@@ -1606,7 +1606,6 @@ static void METALMETALTranslateVariableNameWithMask(HLSLCrossCompilerContext* ps
|
||||
{
|
||||
// Array of matrices is treated as array of vec4s in HLSL,
|
||||
// but that would mess up uniform types in metal. Do gymnastics.
|
||||
SHADER_VARIABLE_TYPE eType2 = GetOperandDataTypeMETAL(psContext, psOperand->psSubOperand[0]);
|
||||
uint32_t opFlags = TO_FLAG_INTEGER;
|
||||
|
||||
if (psVarType && (psVarType->Class == SVC_MATRIX_COLUMNS || psVarType->Class == SVC_MATRIX_ROWS) && (psVarType->Elements > 1))
|
||||
@@ -1689,7 +1688,6 @@ static void METALMETALTranslateVariableNameWithMask(HLSLCrossCompilerContext* ps
|
||||
}
|
||||
else if (psOperand->psSubOperand[1] != NULL)
|
||||
{
|
||||
SHADER_VARIABLE_TYPE eType2 = GetOperandDataTypeMETAL(psContext, psOperand->psSubOperand[1]);
|
||||
bcatcstr(metal, "[");
|
||||
TranslateOperandMETAL(psContext, psOperand->psSubOperand[1], TO_FLAG_INTEGER);
|
||||
bcatcstr(metal, "]");
|
||||
@@ -2151,7 +2149,6 @@ void TranslateOperandWithMaskMETAL(HLSLCrossCompilerContext* psContext, const Op
|
||||
{
|
||||
bstring metal = *psContext->currentShaderString;
|
||||
uint32_t ui32IgnoreSwizzle = 0;
|
||||
SHADER_VARIABLE_TYPE eType = GetOperandDataTypeExMETAL(psContext, psOperand, TypeFlagsToSVTTypeMETAL(ui32TOFlag));
|
||||
|
||||
if (ui32TOFlag & TO_FLAG_NAME_ONLY)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user