mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 19:07:01 +02:00
Split renderState header
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
#ifndef EMULATOR_SRC_GRAPHICS_HOST_GPU_RENDERER_RENDERTARGET_H_
|
||||
#define EMULATOR_SRC_GRAPHICS_HOST_GPU_RENDERER_RENDERTARGET_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <type_traits>
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
namespace Libs::Graphics {
|
||||
|
||||
static constexpr uint32_t RENDER_COLOR_ATTACHMENTS_MAX = 8;
|
||||
|
||||
inline constexpr bool depth_msaa_single_sample_compatible(uint32_t encoded_fragments) {
|
||||
return encoded_fragments == 1 || encoded_fragments == 2;
|
||||
}
|
||||
|
||||
inline constexpr bool color_msaa_single_sample_compatible(uint32_t encoded_samples,
|
||||
uint32_t encoded_fragments) {
|
||||
return encoded_samples == encoded_fragments &&
|
||||
depth_msaa_single_sample_compatible(encoded_fragments);
|
||||
}
|
||||
|
||||
enum class TargetViewType : uint8_t { Image2D, Image2DArray, Unsupported };
|
||||
|
||||
struct TargetViewInfo {
|
||||
TargetViewType type = TargetViewType::Unsupported;
|
||||
uint32_t base_layer = 0;
|
||||
uint32_t layer_count = 0;
|
||||
uint32_t image_layers = 0;
|
||||
};
|
||||
|
||||
inline constexpr TargetViewInfo ResolveTargetViewInfo(uint32_t base_layer, uint32_t last_layer,
|
||||
uint32_t draw_layer_offset = 0) {
|
||||
if (base_layer > last_layer || draw_layer_offset != 0) {
|
||||
return {};
|
||||
}
|
||||
return {base_layer == last_layer ? TargetViewType::Image2D : TargetViewType::Image2DArray,
|
||||
base_layer, last_layer - base_layer + 1u, last_layer + 1u};
|
||||
}
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
struct PipelineStencilStaticState {
|
||||
VkStencilOp failOp = VK_STENCIL_OP_KEEP;
|
||||
VkStencilOp passOp = VK_STENCIL_OP_KEEP;
|
||||
VkStencilOp depthFailOp = VK_STENCIL_OP_KEEP;
|
||||
VkCompareOp compareOp = VK_COMPARE_OP_NEVER;
|
||||
};
|
||||
|
||||
struct PipelineStencilDynamicState {
|
||||
uint32_t compareMask = 0;
|
||||
uint32_t writeMask = 0;
|
||||
uint32_t reference = 0;
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
inline constexpr bool stencil_face_accesses_attachment(const PipelineStencilStaticState& state,
|
||||
const PipelineStencilDynamicState& dynamic) {
|
||||
return state.compareOp != VK_COMPARE_OP_ALWAYS ||
|
||||
(dynamic.writeMask != 0 &&
|
||||
(state.failOp != VK_STENCIL_OP_KEEP || state.passOp != VK_STENCIL_OP_KEEP ||
|
||||
state.depthFailOp != VK_STENCIL_OP_KEEP));
|
||||
}
|
||||
|
||||
static_assert(std::is_trivially_copyable_v<PipelineStencilStaticState>);
|
||||
static_assert(std::is_standard_layout_v<PipelineStencilStaticState>);
|
||||
static_assert(alignof(PipelineStencilStaticState) == 1);
|
||||
static_assert(sizeof(PipelineStencilStaticState) == sizeof(VkStencilOp) * 3 + sizeof(VkCompareOp));
|
||||
static_assert(std::is_trivially_copyable_v<PipelineStencilDynamicState>);
|
||||
static_assert(std::is_standard_layout_v<PipelineStencilDynamicState>);
|
||||
static_assert(alignof(PipelineStencilDynamicState) == 1);
|
||||
static_assert(sizeof(PipelineStencilDynamicState) == sizeof(uint32_t) * 3);
|
||||
|
||||
} // namespace Libs::Graphics
|
||||
|
||||
#endif // EMULATOR_SRC_GRAPHICS_HOST_GPU_RENDERER_RENDERTARGET_H_
|
||||
Reference in New Issue
Block a user