mirror of
https://github.com/Inori/GPCS4.git
synced 2024-06-02 11:28:07 -04:00
shows logo
This commit is contained in:
parent
46d45296f2
commit
80fb91670b
|
@ -82,7 +82,7 @@ bool Emulator::Init()
|
|||
|
||||
void Emulator::Unit()
|
||||
{
|
||||
auto modManager = CSceModuleSystem::GetInstance();
|
||||
auto modManager = CSceModuleSystem::instance();
|
||||
modManager->clearModules();
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ private:
|
|||
|
||||
inline Emulator& TheEmulator()
|
||||
{
|
||||
return *Emulator::GetInstance();
|
||||
return *Emulator::instance();
|
||||
}
|
||||
|
||||
inline VirtualCPU& CPU()
|
||||
|
|
|
@ -82,7 +82,7 @@ void* CGameThread::ThreadFunc(void* pArg)
|
|||
|
||||
void* pRet = RunGameThread(pThis);
|
||||
|
||||
TLSManager* tlsMgr = TLSManager::GetInstance();
|
||||
TLSManager* tlsMgr = TLSManager::instance();
|
||||
tlsMgr->notifyThreadExit();
|
||||
|
||||
pthread_exit(pRet);
|
||||
|
|
|
@ -7,7 +7,10 @@
|
|||
|
||||
LOG_CHANNEL(Linker);
|
||||
|
||||
CLinker::CLinker() : m_modSystem{*CSceModuleSystem::GetInstance()} {}
|
||||
CLinker::CLinker() :
|
||||
m_modSystem{ *CSceModuleSystem::instance() }
|
||||
{
|
||||
}
|
||||
|
||||
// resolveSymbol always returns true
|
||||
bool CLinker::resolveSymbol(NativeModule const &mod,
|
||||
|
|
|
@ -411,7 +411,7 @@ bool NativeModule::getExportSymbols(SymbolList *exportSymbols) const
|
|||
bool NativeModule::getUnresolvedSymbols(SymbolList *symbolList) const
|
||||
{
|
||||
LOG_ASSERT(symbolList != nullptr, "%s", "null pointer error");
|
||||
auto modSystem = CSceModuleSystem::GetInstance();
|
||||
auto modSystem = CSceModuleSystem::instance();
|
||||
|
||||
for (auto index : m_importSymbols)
|
||||
{
|
||||
|
|
|
@ -144,7 +144,7 @@ bool Emulator::registerModules()
|
|||
bool bRet = false;
|
||||
do
|
||||
{
|
||||
CSceModuleSystem* pModuleSystem = CSceModuleSystem::GetInstance();
|
||||
CSceModuleSystem* pModuleSystem = CSceModuleSystem::instance();
|
||||
if (!pModuleSystem)
|
||||
{
|
||||
break;
|
||||
|
|
|
@ -476,7 +476,7 @@ bool installTLSManager()
|
|||
bool ret = false;
|
||||
do
|
||||
{
|
||||
TLSManager* tlsMgr = TLSManager::GetInstance();
|
||||
TLSManager* tlsMgr = TLSManager::instance();
|
||||
if (!tlsMgr)
|
||||
{
|
||||
break;
|
||||
|
@ -492,6 +492,6 @@ bool installTLSManager()
|
|||
|
||||
void uninstallTLSManager()
|
||||
{
|
||||
TLSManager* tlsMgr = TLSManager::GetInstance();
|
||||
TLSManager* tlsMgr = TLSManager::instance();
|
||||
tlsMgr->uninstall();
|
||||
}
|
|
@ -63,8 +63,8 @@ int main(int argc, char* argv[])
|
|||
break;
|
||||
}
|
||||
|
||||
CLinker linker = { *CSceModuleSystem::GetInstance() };
|
||||
ModuleLoader loader = { *CSceModuleSystem::GetInstance(), linker };
|
||||
CLinker linker = { *CSceModuleSystem::instance() };
|
||||
ModuleLoader loader = { *CSceModuleSystem::instance(), linker };
|
||||
|
||||
auto eboot = optResult["E"].as<std::string>();
|
||||
NativeModule* ebootModule = nullptr;
|
||||
|
|
|
@ -1805,7 +1805,7 @@ namespace sce::gcn
|
|||
// e.g. vec3 -> v[4:6]
|
||||
|
||||
uint32_t gprIdx = 0;
|
||||
for (uint32_t i = 0; i != value.type.ccount; ++i)
|
||||
for (uint32_t i = 0; i != 4; ++i)
|
||||
{
|
||||
if (!mask[i])
|
||||
{
|
||||
|
@ -1814,7 +1814,7 @@ namespace sce::gcn
|
|||
|
||||
uint32_t typeId = this->getScalarTypeId(value.type.ctype);
|
||||
uint32_t valueId = 0;
|
||||
if (mask.popCount() == 1)
|
||||
if (value.type.ccount == 1)
|
||||
{
|
||||
valueId = value.id;
|
||||
}
|
||||
|
|
|
@ -489,9 +489,6 @@ namespace sce::gcn
|
|||
std::array<GcnRegisterPointer, 4>
|
||||
emitDsAccess(const GcnShaderInstruction& ins);
|
||||
|
||||
void emitRawBufferLoad(
|
||||
const GcnShaderInstruction& ins);
|
||||
|
||||
void emitScalarBufferLoad(
|
||||
const GcnRegIndex& index,
|
||||
const GcnInstOperand& dst,
|
||||
|
@ -625,36 +622,36 @@ namespace sce::gcn
|
|||
|
||||
///////////////////////////
|
||||
// Debug methods
|
||||
|
||||
// Copy vk_layer_settings.txt from Misc folder to your
|
||||
// Current Working Directory or use vkconfig.exe from SDK
|
||||
// to enable shader debug printf.
|
||||
// Note that normally we need to specify big enough
|
||||
// buffer size and limit the number of messages by conditionally using invocation ID
|
||||
//
|
||||
// Format for specifier is "%"precision <d, i, o, u, x, X, a, A, e, E, f, F, g, G, or ul>
|
||||
// Format for vector specifier is "%"precision"v" [2, 3, or 4] [specifiers list above]
|
||||
//
|
||||
// To conditionally print something,
|
||||
// copy and edit the following code:
|
||||
//
|
||||
// if (m_header->key().name() == "SHDR_AF20AC1F702451D8" && 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("id %X\n", invId.id);
|
||||
// m_module.opBranch(labelEnd);
|
||||
// m_module.opLabel(labelEnd);
|
||||
//}
|
||||
template <typename... Args>
|
||||
void emitDebugPrintf(
|
||||
const std::string& format, Args... args)
|
||||
{
|
||||
// Copy vk_layer_settings.txt from Misc folder to your
|
||||
// Current Working Directory or use vkconfig.exe from SDK
|
||||
// to enable shader debug printf.
|
||||
// Note that normally we need to specify big enough
|
||||
// buffer size and limit the number of messages by conditionally using invocation ID
|
||||
//
|
||||
// Format for specifier is "%"precision <d, i, o, u, x, X, a, A, e, E, f, F, g, G, or ul>
|
||||
// Format for vector specifier is "%"precision"v" [2, 3, or 4] [specifiers list above]
|
||||
//
|
||||
// To conditionally print something,
|
||||
// copy and edit the following code:
|
||||
//
|
||||
//if (m_header->key().name() == "SHDR_AF20AC1F702451D8" && 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("id %X\n", invId.id);
|
||||
// m_module.opBranch(labelEnd);
|
||||
// m_module.opLabel(labelEnd);
|
||||
//}
|
||||
|
||||
#ifdef GCN_SHADER_DEBUG_PRINTF
|
||||
const int count = sizeof...(args);
|
||||
|
||||
|
@ -749,6 +746,9 @@ namespace sce::gcn
|
|||
GcnImageAddrComponent component,
|
||||
const GcnShaderInstruction& ins);
|
||||
|
||||
void mapEudResource(
|
||||
const GcnShaderInstruction& ins);
|
||||
|
||||
void mapNonEudResource();
|
||||
|
||||
private:
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace sce::gcn
|
|||
break;
|
||||
case GcnOpcode::S_LOAD_DWORDX4:
|
||||
case GcnOpcode::S_LOAD_DWORDX8:
|
||||
emitRawBufferLoad(ins);
|
||||
mapEudResource(ins);
|
||||
break;
|
||||
default:
|
||||
LOG_GCN_UNHANDLED_INST();
|
||||
|
@ -59,7 +59,7 @@ namespace sce::gcn
|
|||
}
|
||||
}
|
||||
|
||||
void GcnCompiler::emitRawBufferLoad(const GcnShaderInstruction& ins)
|
||||
void GcnCompiler::mapEudResource(const GcnShaderInstruction& ins)
|
||||
{
|
||||
// Currently, the only usage case I found for S_LOAD_DWORDX4 S_LOAD_DWORDX8
|
||||
// is to load 4 or 8 sgpr sharp descriptors from EUD.
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "GcnCompiler.h"
|
||||
#include "GcnInstructionUtil.h"
|
||||
#include "GcnHeader.h"
|
||||
#include "UtilVector.h"
|
||||
#include "UtilBit.h"
|
||||
|
||||
using namespace sce::vlt;
|
||||
|
||||
|
@ -780,8 +782,13 @@ namespace sce::gcn
|
|||
break;
|
||||
}
|
||||
|
||||
auto colorMask = GcnRegMask(mimg.control.dmask);
|
||||
result = emitRegisterExtract(result, colorMask);
|
||||
// The ISA set says dmask mask RGBA from LSB to MSB,
|
||||
// but it should be the reverse, which is
|
||||
// DMASK[0] = alpha, DMASK[1] = blue, DMASK[2] = green, DMASK[3] = red
|
||||
uint8_t byte = util::bit::reverseByte(mimg.control.dmask);
|
||||
uint32_t mask = byte >> 4;
|
||||
auto colorMask = GcnRegMask(mask);
|
||||
result = emitRegisterExtract(result, colorMask);
|
||||
emitVgprArrayStore(mimg.vdata,
|
||||
result,
|
||||
colorMask);
|
||||
|
@ -827,9 +834,25 @@ namespace sce::gcn
|
|||
// Apply component swizzle and mask
|
||||
auto colorMask = GcnRegMask(mimg.control.dmask);
|
||||
result = emitRegisterExtract(result, colorMask);
|
||||
|
||||
emitVgprArrayStore(mimg.vdata,
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
GcnRegisterValue GcnCompiler::emitCalcTexCoord(
|
||||
|
|
|
@ -360,8 +360,11 @@ namespace sce::Gnm
|
|||
m_initializer->initBuffer(result.buffer, vsharp);
|
||||
|
||||
resource->setBuffer(result);
|
||||
// Pending upload
|
||||
resource->setTransform(SceTransformFlag::GpuUpload);
|
||||
if (vsharp->getResourceMemoryType() != kResourceMemoryTypeRO)
|
||||
{
|
||||
// Pending upload
|
||||
resource->setTransform(SceTransformFlag::GpuUpload);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -404,7 +407,12 @@ namespace sce::Gnm
|
|||
m_initializer->initTexture(result.image, tsharp);
|
||||
|
||||
resource->setTexture(result);
|
||||
resource->setTransform(SceTransformFlag::GpuUpload);
|
||||
|
||||
auto& buffer = resource->buffer();
|
||||
if (buffer.gnmBuffer.getResourceMemoryType() != kResourceMemoryTypeRO)
|
||||
{
|
||||
resource->setTransform(SceTransformFlag::GpuUpload);
|
||||
}
|
||||
}
|
||||
else if (type.test(SceResourceType::RenderTarget) &&
|
||||
!type.test(SceResourceType::Texture))
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "Violet/VltContext.h"
|
||||
#include "Violet/VltDevice.h"
|
||||
#include "Violet/VltImage.h"
|
||||
#include "UtilRenderDoc.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
@ -29,6 +30,7 @@ LOG_CHANNEL(Graphic.Gnm.GnmCommandBufferDraw);
|
|||
|
||||
using namespace sce::vlt;
|
||||
using namespace sce::gcn;
|
||||
using namespace util;
|
||||
|
||||
namespace sce::Gnm
|
||||
{
|
||||
|
@ -196,7 +198,7 @@ namespace sce::Gnm
|
|||
|
||||
void GnmCommandBufferDraw::updatePsShader(const gcn::PsStageRegisters* psRegs)
|
||||
{
|
||||
LOG_ASSERT(false, "TODO");
|
||||
setPsShader(psRegs);
|
||||
}
|
||||
|
||||
void GnmCommandBufferDraw::setVsShader(const gcn::VsStageRegisters* vsRegs, uint32_t shaderModifier)
|
||||
|
@ -285,6 +287,7 @@ namespace sce::Gnm
|
|||
|
||||
void GnmCommandBufferDraw::updateVsShader(const gcn::VsStageRegisters* vsRegs, uint32_t shaderModifier)
|
||||
{
|
||||
setVsShader(vsRegs, shaderModifier);
|
||||
}
|
||||
|
||||
void GnmCommandBufferDraw::setVsharpInUserData(ShaderStage stage, uint32_t startUserDataSlot, const Buffer* buffer)
|
||||
|
@ -359,7 +362,7 @@ namespace sce::Gnm
|
|||
auto writeMasks = cvt::convertRenderTargetMask(mask);
|
||||
for (uint32_t i = 0; i != writeMasks.size(); ++i)
|
||||
{
|
||||
dirty |= m_state.gp.om.blendModes[i].writeMask == writeMasks[i];
|
||||
dirty |= (m_state.gp.om.blendModes[i].writeMask != writeMasks[i]);
|
||||
|
||||
m_state.gp.om.blendModes[i].writeMask = writeMasks[i];
|
||||
}
|
||||
|
@ -957,6 +960,7 @@ namespace sce::Gnm
|
|||
} while (false);
|
||||
}
|
||||
|
||||
static uint32_t count = 0;
|
||||
void GnmCommandBufferDraw::updatePixelShaderStage()
|
||||
{
|
||||
auto& ctx = m_state.gp.sc[kShaderStagePs];
|
||||
|
@ -971,6 +975,18 @@ namespace sce::Gnm
|
|||
auto shader = getShader(ctx.code);
|
||||
auto& resTable = shader.getResources();
|
||||
|
||||
|
||||
if (shader.name().find("F3FAB76ECBEAABD2") != std::string::npos)
|
||||
{
|
||||
++count;
|
||||
if (count == 5)
|
||||
{
|
||||
RdcController::instance()->triggerCapture();
|
||||
}
|
||||
//__debugbreak();
|
||||
}
|
||||
|
||||
|
||||
// create and bind shader resources
|
||||
bindResource(VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
||||
resTable,
|
||||
|
|
|
@ -255,6 +255,7 @@ namespace sce::Gnm
|
|||
vlt::Rc<vlt::VltImageView> getDepthTarget(
|
||||
const DepthRenderTarget& depthTarget);
|
||||
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
|
|
@ -332,8 +332,8 @@ bool ModuleLoader::initializeModules()
|
|||
auto &mods = m_modSystem.getAllNativeModules();
|
||||
bool retVal = true;
|
||||
|
||||
auto tlsManager = TLSManager::GetInstance();
|
||||
uint32_t tlsIndex = TLS_MODULE_ID_MAIN;
|
||||
auto tlsManager = TLSManager::instance();
|
||||
uint32_t tlsIndex = TLS_MODULE_ID_MAIN;
|
||||
// intialize TLS
|
||||
for (auto const &mod : mods)
|
||||
{
|
||||
|
|
|
@ -7,6 +7,6 @@ LOG_CHANNEL(SceModules.SceLibkernel.tls);
|
|||
void* PS4API __tls_get_addr(tls_index *ti)
|
||||
{
|
||||
LOG_SCE_DUMMY_IMPL();
|
||||
auto tlsManager = TLSManager::GetInstance();
|
||||
auto tlsManager = TLSManager::instance();
|
||||
return tlsManager->tlsGetAddr(ti->ti_module, ti->ti_offset);
|
||||
}
|
|
@ -160,7 +160,7 @@ int PS4API sceKernelUuidCreate(void)
|
|||
void *PS4API sceKernelGetProcParam(uint64_t p1, uint64_t p2)
|
||||
{
|
||||
LOG_DEBUG("param1: %zu, param2: %zu", p1, p2);
|
||||
auto moduleSystem = CSceModuleSystem::GetInstance();
|
||||
auto moduleSystem = CSceModuleSystem::instance();
|
||||
auto procParam = moduleSystem->getEbootModuleInfo()->pProcParam;
|
||||
return procParam;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ void* newThreadWrapper(void* arg)
|
|||
ret = pSceEntry(param->arg);
|
||||
|
||||
// release tls data
|
||||
TLSManager* tlsMgr = TLSManager::GetInstance();
|
||||
TLSManager* tlsMgr = TLSManager::instance();
|
||||
tlsMgr->notifyThreadExit();
|
||||
|
||||
} while (false);
|
||||
|
|
|
@ -134,5 +134,15 @@ namespace util::bit {
|
|||
return !std::memcmp(a, b, sizeof(T));
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Reverse the bits in a byte
|
||||
*
|
||||
* http://graphics.stanford.edu/~seander/bithacks.html
|
||||
*/
|
||||
inline uint8_t reverseByte(uint8_t x)
|
||||
{
|
||||
return ((x * 0x80200802ULL) & 0x0884422110ULL) * 0x0101010101ULL >> 32;
|
||||
}
|
||||
|
||||
}
|
|
@ -11,7 +11,7 @@ namespace util
|
|||
class Singleton
|
||||
{
|
||||
public:
|
||||
static T* GetInstance()
|
||||
static T* instance()
|
||||
{
|
||||
if (mInstance == NULL) //TODO: Double-Check
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue