mirror of
https://github.com/InoriRus/Kyty.git
synced 2026-08-28 05:06:40 +00:00
release 0.1.0
This commit is contained in:
@@ -6,13 +6,13 @@
|
||||
|
||||
#include "Emulator/Common.h"
|
||||
|
||||
#include <vulkan/vulkan_core.h>
|
||||
#include <vulkan/vulkan_core.h> // IWYU pragma: export
|
||||
|
||||
#ifdef KYTY_EMU_ENABLED
|
||||
|
||||
namespace Kyty::Libs::Graphics {
|
||||
|
||||
class CommandBuffer;
|
||||
class CommandProcessor;
|
||||
|
||||
struct VulkanSwapchain
|
||||
{
|
||||
@@ -67,36 +67,58 @@ struct VulkanMemory
|
||||
uint64_t unique_id = 0;
|
||||
};
|
||||
|
||||
enum class VulkanImageType
|
||||
{
|
||||
Unknown,
|
||||
VideoOut,
|
||||
DepthStencil,
|
||||
Texture,
|
||||
StorageTexture,
|
||||
RenderTexture
|
||||
};
|
||||
|
||||
struct VulkanImage
|
||||
{
|
||||
VkFormat format = VK_FORMAT_UNDEFINED;
|
||||
VkExtent2D extent = {};
|
||||
VkImage image = nullptr;
|
||||
VkImageView image_view = nullptr;
|
||||
VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
static constexpr int VIEW_MAX = 4;
|
||||
static constexpr int VIEW_DEFAULT = 0;
|
||||
static constexpr int VIEW_BGRA = 1;
|
||||
static constexpr int VIEW_DEPTH_TEXTURE = 2;
|
||||
|
||||
explicit VulkanImage(VulkanImageType type): type(type) {}
|
||||
|
||||
VulkanImageType type = VulkanImageType::Unknown;
|
||||
VkFormat format = VK_FORMAT_UNDEFINED;
|
||||
VkExtent2D extent = {};
|
||||
VkImage image = nullptr;
|
||||
VkImageView image_view[VIEW_MAX] = {};
|
||||
VkImageLayout layout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
Graphics::VulkanMemory memory;
|
||||
};
|
||||
|
||||
struct VideoOutVulkanImage: public VulkanImage
|
||||
{
|
||||
VideoOutVulkanImage(): VulkanImage(VulkanImageType::VideoOut) {}
|
||||
};
|
||||
|
||||
struct DepthStencilVulkanImage: public VulkanImage
|
||||
{
|
||||
bool compressed = false;
|
||||
VkImageView texture_view = nullptr;
|
||||
DepthStencilVulkanImage(): VulkanImage(VulkanImageType::DepthStencil) {}
|
||||
bool compressed = false;
|
||||
};
|
||||
|
||||
struct TextureVulkanImage: public VulkanImage
|
||||
{
|
||||
TextureVulkanImage(): VulkanImage(VulkanImageType::Texture) {}
|
||||
};
|
||||
|
||||
struct StorageTextureVulkanImage: public VulkanImage
|
||||
{
|
||||
StorageTextureVulkanImage(): VulkanImage(VulkanImageType::StorageTexture) {}
|
||||
};
|
||||
|
||||
struct RenderTextureVulkanImage: public VulkanImage
|
||||
{
|
||||
RenderTextureVulkanImage(): VulkanImage(VulkanImageType::RenderTexture) {}
|
||||
};
|
||||
|
||||
struct VulkanBuffer
|
||||
@@ -108,7 +130,7 @@ struct VulkanBuffer
|
||||
|
||||
struct StorageVulkanBuffer: public VulkanBuffer
|
||||
{
|
||||
CommandBuffer* cmd_buffer = nullptr;
|
||||
CommandProcessor* cp = nullptr;
|
||||
};
|
||||
|
||||
} // namespace Kyty::Libs::Graphics
|
||||
|
||||
@@ -33,7 +33,8 @@ public:
|
||||
CommandBuffer() { Allocate(); }
|
||||
virtual ~CommandBuffer() { Free(); }
|
||||
|
||||
void SetParent(CommandProcessor* parent) { m_parent = parent; }
|
||||
void SetParent(CommandProcessor* parent) { m_parent = parent; }
|
||||
CommandProcessor* GetParent() { return m_parent; }
|
||||
|
||||
KYTY_CLASS_NO_COPY(CommandBuffer);
|
||||
|
||||
@@ -56,7 +57,7 @@ public:
|
||||
|
||||
void SetQueue(int queue) { m_queue = queue; }
|
||||
|
||||
void CommandProcessorWait();
|
||||
// void CommandProcessorWait();
|
||||
|
||||
private:
|
||||
VulkanCommandPool* m_pool = nullptr;
|
||||
@@ -89,13 +90,15 @@ void GraphicsRenderWriteAtEndOfPipeWithInterruptWriteBack64(uint64_t submit_id,
|
||||
uint64_t value);
|
||||
void GraphicsRenderWriteAtEndOfPipeWithInterrupt64(uint64_t submit_id, CommandBuffer* buffer, uint64_t* dst_gpu_addr, uint64_t value);
|
||||
void GraphicsRenderWriteAtEndOfPipeWithInterrupt32(uint64_t submit_id, CommandBuffer* buffer, uint32_t* dst_gpu_addr, uint32_t value);
|
||||
void GraphicsRenderWriteBack();
|
||||
void GraphicsRenderWriteBack(CommandProcessor* cp);
|
||||
void GraphicsRenderDispatchDirect(uint64_t submit_id, CommandBuffer* buffer, HW::HardwareContext* ctx, uint32_t thread_group_x,
|
||||
uint32_t thread_group_y, uint32_t thread_group_z, uint32_t mode);
|
||||
void GraphicsRenderMemoryBarrier(CommandBuffer* buffer);
|
||||
void GraphicsRenderRenderTextureBarrier(CommandBuffer* buffer, uint64_t vaddr, uint64_t size);
|
||||
void GraphicsRenderDepthStencilBarrier(CommandBuffer* buffer, uint64_t vaddr, uint64_t size);
|
||||
void GraphicsRenderMemoryFree(uint64_t vaddr, uint64_t size);
|
||||
void GraphicsRenderDeleteIndexBuffers();
|
||||
void GraphicsRenderMemoryFlush(uint64_t vaddr, uint64_t size);
|
||||
|
||||
void DeleteFramebuffer(VideoOutVulkanImage* image);
|
||||
void DeleteFramebuffer(DepthStencilVulkanImage* image);
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
namespace Kyty::Libs::Graphics {
|
||||
|
||||
class CommandProcessor;
|
||||
|
||||
void GraphicsRunInit();
|
||||
|
||||
void GraphicsRunSubmit(uint32_t* cmd_draw_buffer, uint32_t num_draw_dw, uint32_t* cmd_const_buffer, uint32_t num_const_dw);
|
||||
@@ -23,6 +25,11 @@ void GraphicsRunDingDong(uint32_t ring_id, uint32_t offset_dw);
|
||||
int GraphicsRunGetFrameNum();
|
||||
bool GraphicsRunAreSubmitsAllowed();
|
||||
|
||||
void GraphicsRunCommandProcessorLock(CommandProcessor* cp);
|
||||
void GraphicsRunCommandProcessorUnlock(CommandProcessor* cp);
|
||||
void GraphicsRunCommandProcessorFlush(CommandProcessor* cp);
|
||||
void GraphicsRunCommandProcessorWait(CommandProcessor* cp);
|
||||
|
||||
} // namespace Kyty::Libs::Graphics
|
||||
|
||||
#endif // KYTY_EMU_ENABLED
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
namespace Kyty::Libs::Graphics {
|
||||
|
||||
class CommandBuffer;
|
||||
class CommandProcessor;
|
||||
struct GraphicContext;
|
||||
struct VulkanMemory;
|
||||
struct VulkanBuffer;
|
||||
@@ -60,10 +61,11 @@ public:
|
||||
VulkanMemory* mem);
|
||||
using create_from_objects_func_t = void* (*)(GraphicContext* ctx, CommandBuffer* buffer, const uint64_t* params,
|
||||
GpuMemoryScenario scenario, const Vector<GpuMemoryObject>& objects, VulkanMemory* mem);
|
||||
using write_back_func_t = void (*)(GraphicContext* ctx, void* obj, const uint64_t* vaddr, const uint64_t* size, int vaddr_num);
|
||||
using delete_func_t = void (*)(GraphicContext* ctx, void* obj, VulkanMemory* mem);
|
||||
using update_func_t = void (*)(GraphicContext* ctx, const uint64_t* params, void* obj, const uint64_t* vaddr, const uint64_t* size,
|
||||
int vaddr_num);
|
||||
using write_back_func_t = void (*)(GraphicContext* ctx, const uint64_t* params, void* obj, const uint64_t* vaddr, const uint64_t* size,
|
||||
int vaddr_num);
|
||||
using delete_func_t = void (*)(GraphicContext* ctx, void* obj, VulkanMemory* mem);
|
||||
using update_func_t = void (*)(GraphicContext* ctx, const uint64_t* params, void* obj, const uint64_t* vaddr, const uint64_t* size,
|
||||
int vaddr_num);
|
||||
|
||||
static constexpr int PARAMS_MAX = 8;
|
||||
|
||||
@@ -95,11 +97,12 @@ void* GpuMemoryCreateObject(uint64_t submit_id, GraphicContext* ctx, CommandBuff
|
||||
const GpuObject& info);
|
||||
void* GpuMemoryCreateObject(uint64_t submit_id, GraphicContext* ctx, CommandBuffer* buffer, const uint64_t* vaddr, const uint64_t* size,
|
||||
int vaddr_num, const GpuObject& info);
|
||||
void GpuMemoryResetHash(GraphicContext* ctx, const uint64_t* vaddr, const uint64_t* size, int vaddr_num, GpuMemoryObjectType type);
|
||||
void GpuMemoryResetHash(const uint64_t* vaddr, const uint64_t* size, int vaddr_num, GpuMemoryObjectType type);
|
||||
void GpuMemoryDbgDump();
|
||||
void GpuMemoryFlush(GraphicContext* ctx);
|
||||
void GpuMemoryFlush(GraphicContext* ctx, uint64_t vaddr, uint64_t size);
|
||||
void GpuMemoryFlushAll(GraphicContext* ctx);
|
||||
void GpuMemoryFrameDone();
|
||||
void GpuMemoryWriteBack(GraphicContext* ctx);
|
||||
void GpuMemoryWriteBack(GraphicContext* ctx, CommandProcessor* cp);
|
||||
bool GpuMemoryCheckAccessViolation(uint64_t vaddr, uint64_t size);
|
||||
bool GpuMemoryWatcherEnabled();
|
||||
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
|
||||
namespace Kyty::Libs::Graphics {
|
||||
|
||||
struct GraphicContext;
|
||||
|
||||
void IndexBufferInit();
|
||||
void IndexBufferDeleteAll(GraphicContext* ctx);
|
||||
|
||||
class IndexBufferGpuObject: public GpuObject
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -16,6 +16,8 @@ struct GraphicContext;
|
||||
|
||||
void LabelInit();
|
||||
|
||||
constexpr int LABEL_ARGS_MAX = 5;
|
||||
|
||||
class LabelGpuObject: public GpuObject
|
||||
{
|
||||
public:
|
||||
@@ -28,6 +30,7 @@ public:
|
||||
static constexpr int PARAM_ARG_2 = 4;
|
||||
static constexpr int PARAM_ARG_3 = 5;
|
||||
static constexpr int PARAM_ARG_4 = 6;
|
||||
static constexpr int PARAM_ARG_5 = 7;
|
||||
|
||||
explicit LabelGpuObject(uint64_t value, callback_t callback_1, callback_t callback_2, const uint64_t* args = nullptr)
|
||||
{
|
||||
@@ -40,6 +43,7 @@ public:
|
||||
params[PARAM_ARG_2] = args[1];
|
||||
params[PARAM_ARG_3] = args[2];
|
||||
params[PARAM_ARG_4] = args[3];
|
||||
params[PARAM_ARG_5] = args[4];
|
||||
}
|
||||
check_hash = false;
|
||||
type = Graphics::GpuMemoryObjectType::Label;
|
||||
|
||||
@@ -14,36 +14,41 @@ enum class RenderTextureFormat : uint64_t
|
||||
{
|
||||
Unknown,
|
||||
R8G8B8A8Unorm,
|
||||
B8G8R8A8Unorm
|
||||
R8G8B8A8Srgb,
|
||||
B8G8R8A8Unorm,
|
||||
B8G8R8A8Srgb,
|
||||
};
|
||||
|
||||
class RenderTextureObject: public GpuObject
|
||||
{
|
||||
public:
|
||||
static constexpr int PARAM_FORMAT = 0;
|
||||
static constexpr int PARAM_WIDTH = 1;
|
||||
static constexpr int PARAM_HEIGHT = 2;
|
||||
static constexpr int PARAM_TILED = 3;
|
||||
static constexpr int PARAM_NEO = 4;
|
||||
static constexpr int PARAM_PITCH = 5;
|
||||
static constexpr int PARAM_FORMAT = 0;
|
||||
static constexpr int PARAM_WIDTH = 1;
|
||||
static constexpr int PARAM_HEIGHT = 2;
|
||||
static constexpr int PARAM_TILED = 3;
|
||||
static constexpr int PARAM_NEO = 4;
|
||||
static constexpr int PARAM_PITCH = 5;
|
||||
static constexpr int PARAM_WRITE_BACK = 6;
|
||||
|
||||
explicit RenderTextureObject(RenderTextureFormat pixel_format, uint32_t width, uint32_t height, bool tiled, bool neo, uint32_t pitch)
|
||||
explicit RenderTextureObject(RenderTextureFormat pixel_format, uint32_t width, uint32_t height, bool tiled, bool neo, uint32_t pitch,
|
||||
bool write_back)
|
||||
{
|
||||
params[PARAM_FORMAT] = static_cast<uint64_t>(pixel_format);
|
||||
params[PARAM_WIDTH] = width;
|
||||
params[PARAM_HEIGHT] = height;
|
||||
params[PARAM_TILED] = tiled ? 1 : 0;
|
||||
params[PARAM_NEO] = neo ? 1 : 0;
|
||||
params[PARAM_PITCH] = pitch;
|
||||
check_hash = true;
|
||||
type = Graphics::GpuMemoryObjectType::RenderTexture;
|
||||
params[PARAM_FORMAT] = static_cast<uint64_t>(pixel_format);
|
||||
params[PARAM_WIDTH] = width;
|
||||
params[PARAM_HEIGHT] = height;
|
||||
params[PARAM_TILED] = tiled ? 1 : 0;
|
||||
params[PARAM_NEO] = neo ? 1 : 0;
|
||||
params[PARAM_PITCH] = pitch;
|
||||
params[PARAM_WRITE_BACK] = write_back ? 1 : 0;
|
||||
check_hash = true;
|
||||
type = Graphics::GpuMemoryObjectType::RenderTexture;
|
||||
}
|
||||
|
||||
bool Equal(const uint64_t* other) const override;
|
||||
|
||||
[[nodiscard]] create_func_t GetCreateFunc() const override;
|
||||
[[nodiscard]] create_from_objects_func_t GetCreateFromObjectsFunc() const override;
|
||||
[[nodiscard]] write_back_func_t GetWriteBackFunc() const override { return nullptr; };
|
||||
[[nodiscard]] write_back_func_t GetWriteBackFunc() const override;
|
||||
[[nodiscard]] delete_func_t GetDeleteFunc() const override;
|
||||
[[nodiscard]] update_func_t GetUpdateFunc() const override;
|
||||
};
|
||||
|
||||
@@ -31,6 +31,7 @@ enum class ShaderType
|
||||
enum class ShaderInstructionType
|
||||
{
|
||||
Unknown,
|
||||
|
||||
BufferLoadDword,
|
||||
BufferLoadFormatX,
|
||||
BufferLoadFormatXy,
|
||||
@@ -44,6 +45,8 @@ enum class ShaderInstructionType
|
||||
Exp,
|
||||
ImageLoad,
|
||||
ImageSample,
|
||||
ImageSampleLz,
|
||||
ImageSampleLzO,
|
||||
ImageStore,
|
||||
ImageStoreMip,
|
||||
SAddcU32,
|
||||
@@ -61,6 +64,7 @@ enum class ShaderInstructionType
|
||||
SBufferLoadDwordx8,
|
||||
SCbranchExecz,
|
||||
SCbranchScc0,
|
||||
SCbranchVccz,
|
||||
SCmpEqI32,
|
||||
SCmpEqU32,
|
||||
SCmpGeI32,
|
||||
@@ -94,7 +98,9 @@ enum class ShaderInstructionType
|
||||
SWqmB64,
|
||||
SXnorB64,
|
||||
SXorB64,
|
||||
TBufferLoadFormatX,
|
||||
TBufferLoadFormatXyzw,
|
||||
VAddF32,
|
||||
VAddI32,
|
||||
VAndB32,
|
||||
VAshrI32,
|
||||
@@ -138,9 +144,11 @@ enum class ShaderInstructionType
|
||||
VCmpUF32,
|
||||
VCmpxEqU32,
|
||||
VCmpxGeU32,
|
||||
VCmpxGtF32,
|
||||
VCmpxGtU32,
|
||||
VCmpxNeU32,
|
||||
VCmpxLtF32,
|
||||
VCmpxNeqF32,
|
||||
VCmpxNeU32,
|
||||
VCndmaskB32,
|
||||
VCosF32,
|
||||
VCvtF32F16,
|
||||
@@ -154,9 +162,11 @@ enum class ShaderInstructionType
|
||||
VCvtU32F32,
|
||||
VExpF32,
|
||||
VFloorF32,
|
||||
VFmaF32,
|
||||
VFractF32,
|
||||
VInterpP1F32,
|
||||
VInterpP2F32,
|
||||
VLogF32,
|
||||
VLshlB32,
|
||||
VLshlrevB32,
|
||||
VLshrB32,
|
||||
@@ -166,9 +176,12 @@ enum class ShaderInstructionType
|
||||
VMadF32,
|
||||
VMadmkF32,
|
||||
VMadU32U24,
|
||||
VMax3F32,
|
||||
VMaxF32,
|
||||
VMbcntHiU32B32,
|
||||
VMbcntLoU32B32,
|
||||
VMed3F32,
|
||||
VMin3F32,
|
||||
VMinF32,
|
||||
VMovB32,
|
||||
VMulF32,
|
||||
@@ -182,6 +195,7 @@ enum class ShaderInstructionType
|
||||
VRndneF32,
|
||||
VRsqF32,
|
||||
VSadU32,
|
||||
VSinF32,
|
||||
VSqrtF32,
|
||||
VSubF32,
|
||||
VSubI32,
|
||||
@@ -225,6 +239,7 @@ enum FormatByte : uint64_t
|
||||
Attr, // attr%u.%u <- inst.src[1].constant.u, inst.src[2].constant.u
|
||||
Idxen, // idxen
|
||||
Offen, // offen
|
||||
Float1, // format:float1
|
||||
Float4, // format:float4
|
||||
Pos0, // pos0
|
||||
Done, // done
|
||||
@@ -232,6 +247,7 @@ enum FormatByte : uint64_t
|
||||
Param1, // param1
|
||||
Param2, // param2
|
||||
Param3, // param3
|
||||
Param4, // param4
|
||||
Mrt0, // mrt_color0
|
||||
Off, // off
|
||||
Compr, // compr
|
||||
@@ -240,6 +256,9 @@ enum FormatByte : uint64_t
|
||||
DmaskF, // dmask:0xf
|
||||
Dmask7, // dmask:0x7
|
||||
Dmask1, // dmask:0x1
|
||||
Dmask8, // dmask:0x8
|
||||
Dmask3, // dmask:0x3
|
||||
Dmask5, // dmask:0x5
|
||||
Gds, // gds
|
||||
};
|
||||
|
||||
@@ -266,37 +285,43 @@ enum Format : uint64_t
|
||||
Param1Vsrc0Vsrc1Vsrc2Vsrc3 = FormatDefine({Param1, S0, S1, S2, S3}),
|
||||
Param2Vsrc0Vsrc1Vsrc2Vsrc3 = FormatDefine({Param2, S0, S1, S2, S3}),
|
||||
Param3Vsrc0Vsrc1Vsrc2Vsrc3 = FormatDefine({Param3, S0, S1, S2, S3}),
|
||||
Param4Vsrc0Vsrc1Vsrc2Vsrc3 = FormatDefine({Param4, S0, S1, S2, S3}),
|
||||
Pos0Vsrc0Vsrc1Vsrc2Vsrc3Done = FormatDefine({Pos0, S0, S1, S2, S3, Done}),
|
||||
Saddr = FormatDefine({S0A2}),
|
||||
Sdst4SbaseSoffset = FormatDefine({DA4, S0A2, S1}),
|
||||
Sdst8SbaseSoffset = FormatDefine({DA8, S0A2, S1}),
|
||||
SdstSvSoffset = FormatDefine({D, S0A4, S1}),
|
||||
Sdst2SvSoffset = FormatDefine({DA2, S0A4, S1}),
|
||||
Sdst4SvSoffset = FormatDefine({DA4, S0A4, S1}),
|
||||
Sdst8SvSoffset = FormatDefine({DA8, S0A4, S1}),
|
||||
Sdst16SvSoffset = FormatDefine({DA16, S0A4, S1}),
|
||||
SVdstSVsrc0 = FormatDefine({D, S0}),
|
||||
SVdstSVsrc0SVsrc1 = FormatDefine({D, S0, S1}),
|
||||
Sdst2Ssrc02 = FormatDefine({DA2, S0A2}),
|
||||
Sdst2Ssrc02Ssrc12 = FormatDefine({DA2, S0A2, S1A2}),
|
||||
Sdst2SvSoffset = FormatDefine({DA2, S0A4, S1}),
|
||||
Sdst4SbaseSoffset = FormatDefine({DA4, S0A2, S1}),
|
||||
Sdst4SvSoffset = FormatDefine({DA4, S0A4, S1}),
|
||||
Sdst8SbaseSoffset = FormatDefine({DA8, S0A2, S1}),
|
||||
Sdst8SvSoffset = FormatDefine({DA8, S0A4, S1}),
|
||||
SdstSvSoffset = FormatDefine({D, S0A4, S1}),
|
||||
SmaskVsrc0Vsrc1 = FormatDefine({DA2, S0, S1}),
|
||||
Ssrc0Ssrc1 = FormatDefine({S0, S1}),
|
||||
SVdstSVsrc0 = FormatDefine({D, S0}),
|
||||
SVdstSVsrc0SVsrc1 = FormatDefine({D, S0, S1}),
|
||||
Vdata1Vaddr3StSsDmask1 = FormatDefine({D, S0A3, S1A8, S2A4, Dmask1}),
|
||||
Vdata1Vaddr3StSsDmask8 = FormatDefine({D, S0A3, S1A8, S2A4, Dmask8}),
|
||||
Vdata1VaddrSvSoffsIdxen = FormatDefine({D, S0, S1A4, S2, Idxen}),
|
||||
Vdata1VaddrSvSoffsIdxenFloat1 = FormatDefine({D, S0, S1A4, S2, Idxen, Float1}),
|
||||
Vdata2Vaddr3StSsDmask3 = FormatDefine({DA2, S0A3, S1A8, S2A4, Dmask3}),
|
||||
Vdata2Vaddr3StSsDmask5 = FormatDefine({DA2, S0A3, S1A8, S2A4, Dmask5}),
|
||||
Vdata2VaddrSvSoffsIdxen = FormatDefine({DA2, S0, S1A4, S2, Idxen}),
|
||||
Vdata3Vaddr3StSsDmask7 = FormatDefine({DA3, S0A3, S1A8, S2A4, Dmask7}),
|
||||
Vdata3Vaddr4StSsDmask7 = FormatDefine({DA3, S0A4, S1A8, S2A4, Dmask7}),
|
||||
Vdata3VaddrSvSoffsIdxen = FormatDefine({DA3, S0, S1A4, S2, Idxen}),
|
||||
Vdata4Vaddr2SvSoffsOffenIdxenFloat4 = FormatDefine({DA4, S0A2, S1A4, S2, Offen, Idxen, Float4}),
|
||||
Vdata4Vaddr3StDmaskF = FormatDefine({DA4, S0A3, S1A8, DmaskF}),
|
||||
Vdata4Vaddr3StSsDmaskF = FormatDefine({DA4, S0A3, S1A8, S2A4, DmaskF}),
|
||||
Vdata4Vaddr4StDmaskF = FormatDefine({DA4, S0A4, S1A8, DmaskF}),
|
||||
Vdata4VaddrSvSoffsIdxen = FormatDefine({DA4, S0, S1A4, S2, Idxen}),
|
||||
Vdata4VaddrSvSoffsIdxenFloat4 = FormatDefine({DA4, S0, S1A4, S2, Idxen, Float4}),
|
||||
Vdata4Vaddr2SvSoffsOffenIdxenFloat4 = FormatDefine({DA4, S0A2, S1A4, S2, Offen, Idxen, Float4}),
|
||||
Vdata1Vaddr3StSsDmask1 = FormatDefine({D, S0A3, S1A8, S2A4, Dmask1}),
|
||||
Vdata3Vaddr3StSsDmask7 = FormatDefine({DA3, S0A3, S1A8, S2A4, Dmask7}),
|
||||
Vdata4Vaddr3StSsDmaskF = FormatDefine({DA4, S0A3, S1A8, S2A4, DmaskF}),
|
||||
Vdata4Vaddr3StDmaskF = FormatDefine({DA4, S0A3, S1A8, DmaskF}),
|
||||
Vdata4Vaddr4StDmaskF = FormatDefine({DA4, S0A4, S1A8, DmaskF}),
|
||||
VdstGds = FormatDefine({D, Gds}),
|
||||
VdstSdst2Vsrc0Vsrc1 = FormatDefine({D, D2A2, S0, S1}),
|
||||
VdstVsrc0Vsrc1Smask2 = FormatDefine({D, S0, S1, S2A2}),
|
||||
VdstVsrc0Vsrc1Vsrc2 = FormatDefine({D, S0, S1, S2}),
|
||||
VdstVsrcAttrChan = FormatDefine({D, S0, Attr}),
|
||||
VdstSdst2Vsrc0Vsrc1 = FormatDefine({D, D2A2, S0, S1}),
|
||||
VdstGds = FormatDefine({D, Gds}),
|
||||
};
|
||||
|
||||
} // namespace ShaderInstructionFormat
|
||||
@@ -332,6 +357,7 @@ struct ShaderOperand
|
||||
int register_id = 0;
|
||||
int size = 0;
|
||||
float multiplier = 1.0f;
|
||||
bool absolute = false;
|
||||
bool negate = false;
|
||||
bool clamp = false;
|
||||
|
||||
@@ -364,6 +390,14 @@ public:
|
||||
|
||||
[[nodiscard]] String ToString() const { return String::FromPrintf("label_%04" PRIx32 "_%04" PRIx32, m_dst, m_src); }
|
||||
|
||||
void Disable()
|
||||
{
|
||||
m_dst = 0;
|
||||
m_src = 0;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool IsDisabled() const { return m_dst == 0 && m_src == 0; }
|
||||
|
||||
private:
|
||||
uint32_t m_dst;
|
||||
uint32_t m_src;
|
||||
@@ -420,10 +454,18 @@ public:
|
||||
[[nodiscard]] uint32_t GetPsEmbeddedId() const { return m_ps_embedded_id; }
|
||||
void SetPsEmbeddedId(uint32_t embedded_id) { m_ps_embedded_id = embedded_id; }
|
||||
|
||||
[[nodiscard]] bool IsDiscardBlock(uint32_t pc) const;
|
||||
[[nodiscard]] bool IsDiscardInstruction(uint32_t index) const;
|
||||
[[nodiscard]] bool IsDiscardBlock(uint32_t pc) const;
|
||||
[[nodiscard]] bool IsDiscardInstruction(uint32_t index) const;
|
||||
[[nodiscard]] Vector<ShaderInstruction> GetDiscardBlock(uint32_t pc) const;
|
||||
|
||||
[[nodiscard]] uint32_t GetCrc32() const { return m_crc32; }
|
||||
void SetCrc32(uint32_t c) { this->m_crc32 = c; }
|
||||
[[nodiscard]] uint32_t GetHash0() const { return m_hash0; }
|
||||
void SetHash0(uint32_t h) { this->m_hash0 = h; }
|
||||
|
||||
private:
|
||||
uint32_t m_hash0 = 0;
|
||||
uint32_t m_crc32 = 0;
|
||||
Vector<ShaderInstruction> m_instructions;
|
||||
Vector<ShaderLabel> m_labels;
|
||||
ShaderType m_type = ShaderType::Unknown;
|
||||
@@ -436,12 +478,24 @@ private:
|
||||
|
||||
struct ShaderId
|
||||
{
|
||||
uint32_t hash0 = 0;
|
||||
uint32_t crc32 = 0;
|
||||
Vector<uint32_t> ids;
|
||||
|
||||
bool operator==(const ShaderId& other) const { return ids == other.ids; }
|
||||
bool operator==(const ShaderId& other) const { return hash0 == other.hash0 && crc32 == other.crc32 && ids == other.ids; }
|
||||
bool operator!=(const ShaderId& other) const { return !(*this == other); }
|
||||
};
|
||||
|
||||
constexpr uint32_t DstSel(uint32_t x, uint32_t y = 0, uint32_t z = 0, uint32_t w = 0)
|
||||
{
|
||||
return x | (y << 3u) | (z << 6u) | (w << 9u);
|
||||
}
|
||||
|
||||
inline uint8_t GetDstSel(uint32_t swizzle, uint32_t channel)
|
||||
{
|
||||
return (swizzle >> (channel * 3u)) & 0x7u;
|
||||
}
|
||||
|
||||
struct ShaderBufferResource
|
||||
{
|
||||
uint32_t fields[4] = {0};
|
||||
@@ -462,6 +516,9 @@ struct ShaderBufferResource
|
||||
[[nodiscard]] uint8_t DstSelY() const { return (fields[3] >> 3u) & 0x7u; }
|
||||
[[nodiscard]] uint8_t DstSelZ() const { return (fields[3] >> 6u) & 0x7u; }
|
||||
[[nodiscard]] uint8_t DstSelW() const { return (fields[3] >> 9u) & 0x7u; }
|
||||
[[nodiscard]] uint32_t DstSelXY() const { return (fields[3] >> 0u) & 0x3Fu; }
|
||||
[[nodiscard]] uint32_t DstSelXYZ() const { return (fields[3] >> 0u) & 0x1FFu; }
|
||||
[[nodiscard]] uint32_t DstSelXYZW() const { return (fields[3] >> 0u) & 0xFFFu; }
|
||||
[[nodiscard]] uint8_t Nfmt() const { return (fields[3] >> 12u) & 0x7u; }
|
||||
[[nodiscard]] uint8_t Dfmt() const { return (fields[3] >> 15u) & 0xFu; }
|
||||
[[nodiscard]] bool AddTid() const { return ((fields[3] >> 23u) & 0x1u) == 1; }
|
||||
@@ -496,6 +553,9 @@ struct ShaderTextureResource
|
||||
[[nodiscard]] uint8_t DstSelY() const { return (fields[3] >> 3u) & 0x7u; }
|
||||
[[nodiscard]] uint8_t DstSelZ() const { return (fields[3] >> 6u) & 0x7u; }
|
||||
[[nodiscard]] uint8_t DstSelW() const { return (fields[3] >> 9u) & 0x7u; }
|
||||
[[nodiscard]] uint32_t DstSelXY() const { return (fields[3] >> 0u) & 0x3Fu; }
|
||||
[[nodiscard]] uint32_t DstSelXYZ() const { return (fields[3] >> 0u) & 0x1FFu; }
|
||||
[[nodiscard]] uint32_t DstSelXYZW() const { return (fields[3] >> 0u) & 0xFFFu; }
|
||||
[[nodiscard]] uint8_t BaseLevel() const { return (fields[3] >> 12u) & 0xFu; }
|
||||
[[nodiscard]] uint8_t LastLevel() const { return (fields[3] >> 16u) & 0xFu; }
|
||||
[[nodiscard]] uint8_t TilingIdx() const { return (fields[3] >> 20u) & 0x1Fu; }
|
||||
|
||||
@@ -28,7 +28,7 @@ struct TileSizeAlign
|
||||
void TileInit();
|
||||
void TileConvertTiledToLinear(void* dst, const void* src, TileMode mode, uint32_t width, uint32_t height, bool neo);
|
||||
void TileConvertTiledToLinear(void* dst, const void* src, TileMode mode, uint32_t dfmt, uint32_t nfmt, uint32_t width, uint32_t height,
|
||||
uint32_t levels, bool neo);
|
||||
uint32_t pitch, uint32_t levels, bool neo);
|
||||
|
||||
bool TileGetDepthSize(uint32_t width, uint32_t height, uint32_t pitch, uint32_t z_format, uint32_t stencil_format, bool htile, bool neo,
|
||||
TileSizeAlign* stencil_size, TileSizeAlign* htile_size, TileSizeAlign* depth_size);
|
||||
|
||||
@@ -47,15 +47,18 @@ struct ImageImageCopy
|
||||
int dst_y;
|
||||
};
|
||||
|
||||
void UtilBufferToImage(CommandBuffer* buffer, VulkanBuffer* src_buffer, uint32_t src_pitch, VulkanImage* dst_image);
|
||||
void UtilBufferToImage(CommandBuffer* buffer, VulkanBuffer* src_buffer, uint32_t src_pitch, VulkanImage* dst_image, uint64_t dst_layout);
|
||||
void UtilBufferToImage(CommandBuffer* buffer, VulkanBuffer* src_buffer, VulkanImage* dst_image, const Vector<BufferImageCopy>& regions,
|
||||
uint64_t dst_layout);
|
||||
void UtilImageToBuffer(CommandBuffer* buffer, VulkanImage* src_image, VulkanBuffer* dst_buffer, uint32_t dst_pitch, uint64_t src_layout);
|
||||
void UtilImageToImage(CommandBuffer* buffer, const Vector<ImageImageCopy>& regions, VulkanImage* dst_image, uint64_t dst_layout);
|
||||
void UtilBlitImage(CommandBuffer* buffer, VulkanImage* src_image, VulkanSwapchain* dst_swapchain);
|
||||
void UtilFillImage(GraphicContext* ctx, VulkanImage* dst_image, const void* src_data, uint64_t size, uint32_t src_pitch);
|
||||
void UtilFillImage(GraphicContext* ctx, VulkanImage* dst_image, const void* src_data, uint64_t size, uint32_t src_pitch,
|
||||
uint64_t dst_layout);
|
||||
void UtilFillImage(GraphicContext* ctx, VulkanImage* dst_image, const void* src_data, uint64_t size, const Vector<BufferImageCopy>& regions,
|
||||
uint64_t dst_layout);
|
||||
void UtilFillImage(GraphicContext* ctx, const Vector<ImageImageCopy>& regions, VulkanImage* dst_image, uint64_t dst_layout);
|
||||
void UtilFillBuffer(GraphicContext* ctx, void* dst_data, uint64_t size, uint32_t dst_pitch, VulkanImage* src_image, uint64_t src_layout);
|
||||
void UtilCopyBuffer(VulkanBuffer* src_buffer, VulkanBuffer* dst_buffer, uint64_t size);
|
||||
void UtilSetDepthLayoutOptimal(DepthStencilVulkanImage* image);
|
||||
void UtilSetImageLayoutOptimal(VulkanImage* image);
|
||||
|
||||
Reference in New Issue
Block a user