mirror of
				https://git.suyu.dev/suyu/suyu
				synced 2025-11-04 08:59:03 -06:00 
			
		
		
		
	shader/other: Implement BAR.SYNC 0x0
Trivially implement this particular case of BAR. Unless games use OpenCL or CUDA barriers, we shouldn't hit any other case here.
This commit is contained in:
		@@ -2321,6 +2321,15 @@ private:
 | 
			
		||||
        return {fmt::format("readInvocationARB({}, {})", value, index), Type::Float};
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Expression Barrier(Operation) {
 | 
			
		||||
        if (!ir.IsDecompiled()) {
 | 
			
		||||
            LOG_ERROR(Render_OpenGL, "barrier() used but shader is not decompiled");
 | 
			
		||||
            return {};
 | 
			
		||||
        }
 | 
			
		||||
        code.AddLine("barrier();");
 | 
			
		||||
        return {};
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Expression MemoryBarrierGL(Operation) {
 | 
			
		||||
        code.AddLine("memoryBarrier();");
 | 
			
		||||
        return {};
 | 
			
		||||
@@ -2556,6 +2565,7 @@ private:
 | 
			
		||||
        &GLSLDecompiler::ThreadId,
 | 
			
		||||
        &GLSLDecompiler::ShuffleIndexed,
 | 
			
		||||
 | 
			
		||||
        &GLSLDecompiler::Barrier,
 | 
			
		||||
        &GLSLDecompiler::MemoryBarrierGL,
 | 
			
		||||
    };
 | 
			
		||||
    static_assert(operation_decompilers.size() == static_cast<std::size_t>(OperationCode::Amount));
 | 
			
		||||
 
 | 
			
		||||
@@ -2181,6 +2181,22 @@ private:
 | 
			
		||||
        return {OpSubgroupReadInvocationKHR(t_float, value, index), Type::Float};
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Expression Barrier(Operation) {
 | 
			
		||||
        if (!ir.IsDecompiled()) {
 | 
			
		||||
            LOG_ERROR(Render_Vulkan, "OpBarrier used by shader is not decompiled");
 | 
			
		||||
            return {};
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        const auto scope = spv::Scope::Workgroup;
 | 
			
		||||
        const auto memory = spv::Scope::Workgroup;
 | 
			
		||||
        const auto semantics =
 | 
			
		||||
            spv::MemorySemanticsMask::WorkgroupMemory | spv::MemorySemanticsMask::AcquireRelease;
 | 
			
		||||
        OpControlBarrier(Constant(t_uint, static_cast<u32>(scope)),
 | 
			
		||||
                         Constant(t_uint, static_cast<u32>(memory)),
 | 
			
		||||
                         Constant(t_uint, static_cast<u32>(semantics)));
 | 
			
		||||
        return {};
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Expression MemoryBarrierGL(Operation) {
 | 
			
		||||
        const auto scope = spv::Scope::Device;
 | 
			
		||||
        const auto semantics =
 | 
			
		||||
@@ -2641,6 +2657,7 @@ private:
 | 
			
		||||
        &SPIRVDecompiler::ThreadId,
 | 
			
		||||
        &SPIRVDecompiler::ShuffleIndexed,
 | 
			
		||||
 | 
			
		||||
        &SPIRVDecompiler::Barrier,
 | 
			
		||||
        &SPIRVDecompiler::MemoryBarrierGL,
 | 
			
		||||
    };
 | 
			
		||||
    static_assert(operation_decompilers.size() == static_cast<std::size_t>(OperationCode::Amount));
 | 
			
		||||
 
 | 
			
		||||
@@ -272,6 +272,11 @@ u32 ShaderIR::DecodeOther(NodeBlock& bb, u32 pc) {
 | 
			
		||||
        SetRegister(bb, instr.gpr0, GetRegister(instr.gpr8));
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
    case OpCode::Id::BAR: {
 | 
			
		||||
        UNIMPLEMENTED_IF_MSG(instr.value != 0xF0A81B8000070000ULL, "BAR is not BAR.SYNC 0x0");
 | 
			
		||||
        bb.push_back(Operation(OperationCode::Barrier));
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
    case OpCode::Id::MEMBAR: {
 | 
			
		||||
        UNIMPLEMENTED_IF(instr.membar.type != Tegra::Shader::MembarType::GL);
 | 
			
		||||
        UNIMPLEMENTED_IF(instr.membar.unknown != Tegra::Shader::MembarUnknown::Default);
 | 
			
		||||
 
 | 
			
		||||
@@ -228,6 +228,7 @@ enum class OperationCode {
 | 
			
		||||
    ThreadId,       /// () -> uint
 | 
			
		||||
    ShuffleIndexed, /// (uint value, uint index) -> uint
 | 
			
		||||
 | 
			
		||||
    Barrier,         /// () -> void
 | 
			
		||||
    MemoryBarrierGL, /// () -> void
 | 
			
		||||
 | 
			
		||||
    Amount,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user