fix gpr array store out of index

This commit is contained in:
Asuka 2022-07-21 00:26:28 +08:00
parent b0b9c2831f
commit a01d404d48
3 changed files with 40 additions and 35 deletions

View file

@ -1804,36 +1804,36 @@ namespace sce::gcn
// store values in a vector into vgpr array,
// e.g. vec3 -> v[4:6]
uint32_t gprIdx = 0;
for (uint32_t i = 0; i != 4; ++i)
{
if (!mask[i])
{
continue;
}
LOG_ASSERT(value.type.ccount >= mask.popCount(), "component count is less than mask.");
uint32_t typeId = this->getScalarTypeId(value.type.ctype);
GcnInstOperand reg = start;
// get continuous value
auto vec = emitRegisterExtract(value, mask);
// stores to gpr one by one
for (uint32_t i = 0; i != vec.type.ccount; ++i)
{
uint32_t typeId = this->getScalarTypeId(vec.type.ctype);
uint32_t valueId = 0;
if (value.type.ccount == 1)
if (vec.type.ccount == 1)
{
valueId = value.id;
valueId = vec.id;
}
else
{
valueId = m_module.opCompositeExtract(
typeId, value.id, 1, &i);
typeId, vec.id, 1, &i);
}
GcnInstOperand reg = start;
reg.code += (gprIdx++);
GcnRegisterValue val;
val.type.ctype = value.type.ctype;
val.type.ctype = vec.type.ctype;
val.type.ccount = 1;
val.id = valueId;
this->emitGprStore<IsVgpr>(reg, val);
// advance to next gpr
++reg.code;
}
}

View file

@ -3,6 +3,7 @@
#include "GcnHeader.h"
#include "UtilVector.h"
#include "UtilBit.h"
#include "UtilRenderDoc.h"
using namespace sce::vlt;
@ -782,8 +783,7 @@ namespace sce::gcn
break;
}
auto colorMask = GcnRegMask(mimg.control.dmask);
result = emitRegisterExtract(result, colorMask);
auto colorMask = GcnRegMask(mimg.control.dmask);
emitVgprArrayStore(mimg.vdata,
result,
colorMask);
@ -834,20 +834,21 @@ namespace sce::gcn
result,
colorMask);
if (m_header->key().name() == "SHDR_844598A0F388C19D" /*&& m_programCounter == 0x70*/)
{
// auto invId = emitCommonSystemValueLoad(GcnSystemValue::SubgroupInvocationID, 0);
// auto condition = m_module.opIEqual(m_module.defBoolType(), invId.id, m_module.constu32(1));
// uint32_t labelBegin = m_module.allocateId();
// uint32_t labelEnd = m_module.allocateId();
// m_module.opSelectionMerge(labelEnd, spv::SelectionControlMaskNone);
// m_module.opBranchConditional(condition, labelBegin, labelEnd);
// m_module.opLabel(labelBegin);
// emitDebugPrintf("mip %f\n", result.id);
// m_module.opBranch(labelEnd);
// m_module.opLabel(labelEnd);
m_module.opReturn();
}
//if (m_header->key().name() == "SHDR_844598A0F388C19D" /*&& m_programCounter == 0x70*/)
//{
// // auto invId = emitCommonSystemValueLoad(GcnSystemValue::SubgroupInvocationID, 0);
// // auto condition = m_module.opIEqual(m_module.defBoolType(), invId.id, m_module.constu32(1));
// // uint32_t labelBegin = m_module.allocateId();
// // uint32_t labelEnd = m_module.allocateId();
// // m_module.opSelectionMerge(labelEnd, spv::SelectionControlMaskNone);
// // m_module.opBranchConditional(condition, labelBegin, labelEnd);
// // m_module.opLabel(labelBegin);
// // emitDebugPrintf("mip %f\n", result.id);
// // m_module.opBranch(labelEnd);
// // m_module.opLabel(labelEnd);
// m_module.opReturn();
// util::RdcController::instance()->triggerCapture();
//}
}
GcnRegisterValue GcnCompiler::emitCalcTexCoord(

View file

@ -553,6 +553,11 @@ namespace sce::Gnm
void GnmCommandBufferDraw::dispatch(uint32_t threadGroupX, uint32_t threadGroupY, uint32_t threadGroupZ)
{
if (threadGroupX == 0x1e && threadGroupY == 0x438)
{
return;
}
commitComputeState();
m_context->dispatch(threadGroupX, threadGroupY, threadGroupZ);
@ -976,11 +981,10 @@ namespace sce::Gnm
auto& resTable = shader.getResources();
//if (shader.name().find("1C3E9BEC02B89E0E") != std::string::npos)
if (shader.name().find("F3FAB76ECBEAABD2") != std::string::npos)
if (shader.name().find("1C3E9BEC02B89E0E") != std::string::npos)
{
++count;
if (count == 1)
if (count == 2)
{
RdcController::instance()->triggerCapture();
}