Added 2D Virtual Screen for HUD and Ortho Elements

This commit is contained in:
iChris4 committed 2026-09-04 18:31:03 +02:00
1 parent 60316f0115
commit 7898a76a22
24 files changed
+1392 -809

No files matched your search

+19 -18
View File
@@ -6,6 +6,9 @@
namespace aurora::gx {
struct DrawData {
gfx::PipelineRef pipeline;
// Same GX state with exact fragment-depth export enabled. Bound only when
// this draw is actually reprojected onto the VR virtual screen.
gfx::PipelineRef exactScreenDepthPipeline;
gfx::Range vertRange;
gfx::Range idxRange;
gfx::Range uniformRange;
@@ -19,14 +22,12 @@ struct DrawData {
uint32_t dstAlpha;
};
constexpr uint32_t GXPipelineConfigVersion = 19;
constexpr uint32_t GXPipelineConfigVersion = 20;
constexpr GXFogType effective_pipeline_fog_type(GXFogType fogType, GXZTexOp zTextureOp,
bool zCompLocBeforeTex, GXBlendMode blendMode,
GXLogicOp logicOp) noexcept {
constexpr GXFogType effective_pipeline_fog_type(GXFogType fogType, GXZTexOp zTextureOp, bool zCompLocBeforeTex,
GXBlendMode blendMode, GXLogicOp logicOp) noexcept {
const bool usesLateZTexture = zTextureOp != GX_ZT_DISABLE && !zCompLocBeforeTex;
const bool usesUnsupportedLogicFog =
blendMode == GX_BM_LOGIC && logicOp != GX_LO_OR;
const bool usesUnsupportedLogicFog = blendMode == GX_BM_LOGIC && logicOp != GX_LO_OR;
return usesLateZTexture && usesUnsupportedLogicFog ? GX_FOG_NONE : fogType;
}
@@ -49,33 +50,33 @@ inline bool valid_pipeline_config(const PipelineConfig& config) noexcept {
const auto in_range = [](auto value, auto maximum) {
using Value = decltype(value);
return static_cast<std::underlying_type_t<Value>>(value) >= 0 &&
static_cast<std::underlying_type_t<Value>>(value) <=
static_cast<std::underlying_type_t<Value>>(maximum);
static_cast<std::underlying_type_t<Value>>(value) <= static_cast<std::underlying_type_t<Value>>(maximum);
};
const bool validSamples = config.msaaSamples == 1 || config.msaaSamples == 2 ||
config.msaaSamples == 4 || config.msaaSamples == 8;
return config.version == GXPipelineConfigVersion && validSamples &&
in_range(config.depthFunc, GX_ALWAYS) && in_range(config.cullMode, GX_CULL_ALL) &&
in_range(config.blendMode, GX_BM_SUBTRACT) &&
in_range(config.blendFacSrc, GX_BL_INVDSTALPHA) &&
in_range(config.blendFacDst, GX_BL_INVDSTALPHA) &&
const bool validSamples =
config.msaaSamples == 1 || config.msaaSamples == 2 || config.msaaSamples == 4 || config.msaaSamples == 8;
return config.version == GXPipelineConfigVersion && validSamples && in_range(config.depthFunc, GX_ALWAYS) &&
in_range(config.cullMode, GX_CULL_ALL) && in_range(config.blendMode, GX_BM_SUBTRACT) &&
in_range(config.blendFacSrc, GX_BL_INVDSTALPHA) && in_range(config.blendFacDst, GX_BL_INVDSTALPHA) &&
in_range(config.blendOp, GX_LO_SET) && in_range(config.pixelFmt, GX_PF_YUV420);
}
wgpu::RenderPipeline create_pipeline([[maybe_unused]] const PipelineConfig& config);
void clear_shader_module_cache();
// Per-pass encoder state carried across the draws of one render pass, so the replay loop can elide Dawn calls that would re-bind what is already bound.
// Per-pass encoder state carried across the draws of one render pass, so the replay loop can elide Dawn calls that
// would re-bind what is already bound.
struct DrawEncodeState {
gfx::PipelineRef currentPipeline = UINTPTR_MAX;
// The bind group currently occupying slot 2.
WGPUBindGroup boundTextureBindGroup = nullptr;
// The pass-wide index buffer binding is established lazily by the first indexed draw; every draw then addresses it with firstIndex instead of a per-draw SetIndexBuffer.
// The pass-wide index buffer binding is established lazily by the first indexed draw; every draw then addresses it
// with firstIndex instead of a per-draw SetIndexBuffer.
bool indexBufferBound = false;
};
void render(const DrawData& data, const wgpu::RenderPassEncoder& pass, DrawEncodeState& state,
bool requireReadyPipeline, const gfx::Range* uniformRangeOverride = nullptr);
bool requireReadyPipeline, const gfx::Range* uniformRangeOverride = nullptr,
gfx::PipelineRef pipelineOverride = 0);
void queue_surface(const u8* dlStart, uint32_t dlSize, bool bigEndian) noexcept;
} // namespace aurora::gx