mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
feat(core): add and link to Agc not implemented shader recompilier
This commit is contained in:
@@ -23,5 +23,6 @@ set(SDL_SENSOR OFF CACHE BOOL "" FORCE)
|
||||
set(SDL_STATIC_PIC ON CACHE BOOL "" FORCE)
|
||||
add_subdirectory(3rdparty/SDL2)
|
||||
|
||||
add_subdirectory(core/shader/recompilier)
|
||||
add_subdirectory(core/libs)
|
||||
add_subdirectory(core/relinker)
|
||||
|
||||
@@ -13,4 +13,5 @@ add_library(libSceAgc SHARED EXCLUDE_FROM_ALL
|
||||
)
|
||||
|
||||
target_include_directories(libSceAgc PRIVATE ${LIBS_INCLUDE_DIR})
|
||||
target_link_libraries(libSceAgc PRIVATE libc)
|
||||
add_shader_recompiler(shader_recompiler_agc libc)
|
||||
target_link_libraries(libSceAgc PRIVATE shader_recompiler_agc libc)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <cstddef>
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/General.hpp"
|
||||
#include "shader/recompilier/Recompiler.hpp"
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -106,7 +107,17 @@ uint32_t* APS5_VABI sceAgcDcbResetQueue(CommandBuffer* buf, uint32_t op, uint32_
|
||||
(void)buf;
|
||||
(void)op;
|
||||
(void)state;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
const std::array<std::uint32_t, 1> code = {0xbf810000u};
|
||||
const std::array<std::uint32_t, 1> capabilities = {1u};
|
||||
const std::array<ShaderRecompiler::RegisterValue, 3> shaderRegisters = {{{0x207u, 1u}, {0x208u, 1u}, {0x209u, 1u}}};
|
||||
const std::array<ShaderRecompiler::MemoryRegion, 1> memory = {{{0x10000u, std::as_bytes(std::span(code))}}};
|
||||
const ShaderRecompiler::RecompileRequest request{
|
||||
{ShaderRecompiler::ShaderStage::Compute, 0x10000u, code, 0, {}},
|
||||
{64, 0, {}, shaderRegisters, {}, {}, memory},
|
||||
{0x00403000u, 0x00010600u, 64, capabilities, {}, {1024, 1024, 64}, 1024, 32768},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
(void)ShaderRecompiler::Recompile(request);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
function(add_shader_recompiler target runtimeTarget)
|
||||
if(NOT TARGET "${runtimeTarget}")
|
||||
message(FATAL_ERROR "Shader recompiler requires an existing runtime target: ${runtimeTarget}")
|
||||
endif()
|
||||
add_library(${target} STATIC EXCLUDE_FROM_ALL "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/src/Recompiler.cpp")
|
||||
target_include_directories(${target} PUBLIC "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/include")
|
||||
target_compile_features(${target} PUBLIC cxx_std_20)
|
||||
set_target_properties(${target} PROPERTIES POSITION_INDEPENDENT_CODE ON CXX_EXTENSIONS OFF)
|
||||
target_link_libraries(${target} PRIVATE ${runtimeTarget})
|
||||
endfunction()
|
||||
@@ -0,0 +1,103 @@
|
||||
#ifndef CORE_SHADER_RECOMPILIER_INCLUDE_SHADER_RECOMPILIER_RECOMPILER_HPP
|
||||
#define CORE_SHADER_RECOMPILIER_INCLUDE_SHADER_RECOMPILIER_RECOMPILER_HPP
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <span>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace ShaderRecompiler {
|
||||
|
||||
enum class ShaderStage {
|
||||
Compute,
|
||||
Vertex,
|
||||
TessellationControl,
|
||||
TessellationEvaluation,
|
||||
Geometry,
|
||||
Fragment
|
||||
};
|
||||
|
||||
struct RegisterValue {
|
||||
std::uint32_t offsetDwords;
|
||||
std::uint32_t value;
|
||||
};
|
||||
|
||||
struct MemoryRegion {
|
||||
std::uint64_t guestAddress;
|
||||
std::span<const std::byte> bytes;
|
||||
};
|
||||
|
||||
struct ShaderBinary {
|
||||
ShaderStage stage;
|
||||
std::uint64_t codeAddress;
|
||||
std::span<const std::uint32_t> code;
|
||||
std::uint64_t headerAddress;
|
||||
std::span<const std::byte> header;
|
||||
};
|
||||
|
||||
struct GuestContext {
|
||||
std::uint32_t waveSize;
|
||||
std::uint32_t userDataBaseRegister;
|
||||
std::span<const std::uint32_t> userData;
|
||||
std::span<const RegisterValue> shaderRegisters;
|
||||
std::span<const RegisterValue> contextRegisters;
|
||||
std::span<const RegisterValue> userConfigRegisters;
|
||||
std::span<const MemoryRegion> memory;
|
||||
};
|
||||
|
||||
struct SpirvTarget {
|
||||
std::uint32_t vulkanVersion;
|
||||
std::uint32_t spirvVersion;
|
||||
std::uint32_t subgroupSize;
|
||||
std::span<const std::uint32_t> supportedCapabilities;
|
||||
std::span<const std::string_view> supportedExtensions;
|
||||
std::array<std::uint32_t, 3> maxWorkgroupSize;
|
||||
std::uint32_t maxWorkgroupInvocations;
|
||||
std::uint32_t maxWorkgroupSharedMemoryBytes;
|
||||
};
|
||||
|
||||
struct BindingLayout {
|
||||
std::uint32_t descriptorSet;
|
||||
std::uint32_t firstBinding;
|
||||
std::uint32_t pushConstantOffsetBytes;
|
||||
std::uint32_t pushConstantSizeBytes;
|
||||
};
|
||||
|
||||
struct RecompileRequest {
|
||||
ShaderBinary shader;
|
||||
GuestContext context;
|
||||
SpirvTarget target;
|
||||
BindingLayout layout;
|
||||
};
|
||||
|
||||
enum class DescriptorKind {
|
||||
UniformBuffer,
|
||||
StorageBuffer,
|
||||
UniformTexelBuffer,
|
||||
StorageTexelBuffer,
|
||||
SampledImage,
|
||||
StorageImage,
|
||||
Sampler
|
||||
};
|
||||
|
||||
struct DescriptorBinding {
|
||||
DescriptorKind kind;
|
||||
std::uint32_t descriptorSet;
|
||||
std::uint32_t binding;
|
||||
std::uint32_t count;
|
||||
std::vector<std::uint32_t> guestDescriptor;
|
||||
};
|
||||
|
||||
struct RecompileResult {
|
||||
std::vector<std::uint32_t> spirv;
|
||||
std::vector<DescriptorBinding> bindings;
|
||||
std::vector<std::byte> pushConstants;
|
||||
};
|
||||
|
||||
[[nodiscard]] RecompileResult Recompile(const RecompileRequest& request);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
#include "shader/recompilier/Recompiler.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace ShaderRecompiler {
|
||||
|
||||
RecompileResult Recompile(const RecompileRequest& request) {
|
||||
(void)request;
|
||||
throw std::runtime_error("ShaderRecompiler::Recompile not implemented");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user