fix scalar buffer load for ssbo

This commit is contained in:
Asuka 2022-07-13 04:23:00 +08:00
parent 1f649c0d1c
commit 82dbae613a
5 changed files with 23 additions and 10 deletions

View file

@ -2269,26 +2269,33 @@ namespace sce::gcn
return result;
}
void GcnCompiler::emitConstantBufferLoad(
void GcnCompiler::emitScalarBufferLoad(
const GcnRegIndex& index,
const GcnInstOperand& dst,
uint32_t count)
{
uint32_t regId = index.regIdx;
GcnRegisterValue baseId = emitIndexLoad(index);
const auto& buffer = m_buffers.at(regId);
uint32_t fpTypeId = getScalarTypeId(GcnScalarType::Float32);
const uint32_t typeId = getScalarTypeId(buffer.asSsbo
? GcnScalarType::Uint32
: GcnScalarType::Float32);
auto ptrList = emitUniformBufferAccess(m_buffers.at(regId).varId,
baseId.id,
count);
auto ptrList = buffer.asSsbo
? emitStorageBufferAccess(buffer.varId,
baseId.id,
count)
: emitUniformBufferAccess(buffer.varId,
baseId.id,
count);
for (uint32_t i = 0; i != count ; ++i)
{
const auto& ptr = ptrList[i];
GcnRegisterValuePair value = {};
value.low.type = ptr.type;
value.low.id = m_module.opLoad(fpTypeId,
value.low.id = m_module.opLoad(typeId,
ptr.id);
GcnInstOperand reg = dst;

View file

@ -483,7 +483,7 @@ namespace sce::gcn
void emitRawBufferLoad(
const GcnShaderInstruction& ins);
void emitConstantBufferLoad(
void emitScalarBufferLoad(
const GcnRegIndex& index,
const GcnInstOperand& dst,
uint32_t count);

View file

@ -45,7 +45,8 @@ namespace sce::gcn
index.offset = 0;
index.relReg = &smrd.offset;
}
emitConstantBufferLoad(index, smrd.sdst, smrd.control.count);
emitScalarBufferLoad(index, smrd.sdst, smrd.control.count);
}
break;
case GcnOpcode::S_LOAD_DWORDX4:

View file

@ -720,7 +720,7 @@ namespace sce::gcn
if (flags.test(GcnMimgModifier::Offset))
{
m_module.enableCapability(spv::CapabilityImageGatherExtended);
// m_module.enableCapability(spv::CapabilityImageGatherExtended);
auto offset = emitLoadTexOffset(ins);

View file

@ -3,7 +3,7 @@
#include "Gcn/GcnShaderMeta.h"
#include <fstream>
#include <fmt/format.h>
LOG_CHANNEL(Graphic.Gnm.GnmShader);
@ -33,6 +33,11 @@ namespace sce::Gnm
{
m_shader = m_module.compile(meta, moduleInfo);
m_shader->setShaderKey(m_key);
std::ofstream fout(
fmt::format("shaders/{}", m_shader->debugName()),
std::ofstream::binary);
m_shader->dump(fout);
}
return m_shader;
}