mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Port hakuX Phase 3 conservative draw reordering
This commit is contained in:
+659
-12
File diff suppressed because it is too large
Load Diff
@@ -192,6 +192,7 @@ static void pgraph_vk_flush(NV2AState *d)
|
||||
{
|
||||
PGRAPHState *pg = &d->pgraph;
|
||||
|
||||
pgraph_vk_flush_reorder_window(d);
|
||||
pgraph_vk_finish(pg, VK_FINISH_REASON_FLUSH);
|
||||
pgraph_vk_surface_flush(d);
|
||||
pgraph_vk_mark_textures_possibly_dirty(d, 0, memory_region_size(d->vram));
|
||||
|
||||
@@ -47,6 +47,8 @@
|
||||
#define MAX_FRAMEBUFFERS 256
|
||||
#define FB_CACHE_MAX 32
|
||||
#define OPT_BINDLESS_TEXTURES 1
|
||||
#define OPT_REORDER_SAFE_WINDOWS 1
|
||||
#define REORDER_WINDOW_MAX 64
|
||||
#define MAX_BINDLESS_TEXTURES 1024
|
||||
#define BINDLESS_STAGE_SLOT_BASE (MAX_BINDLESS_TEXTURES - NV2A_MAX_TEXTURES)
|
||||
|
||||
@@ -256,6 +258,64 @@ typedef struct TextureBinding {
|
||||
#endif
|
||||
} TextureBinding;
|
||||
|
||||
#if OPT_REORDER_SAFE_WINDOWS
|
||||
typedef enum ReorderDrawMode {
|
||||
RW_DRAW_INDEXED,
|
||||
RW_DRAW_INDIRECT,
|
||||
RW_DRAW_DIRECT,
|
||||
} ReorderDrawMode;
|
||||
|
||||
typedef struct ReorderWindowEntry {
|
||||
PipelineBinding *pipeline_binding;
|
||||
VkDescriptorSet descriptor_set;
|
||||
|
||||
VkBuffer vertex_buffers[NV2A_VERTEXSHADER_ATTRIBUTES];
|
||||
VkDeviceSize vertex_offsets[NV2A_VERTEXSHADER_ATTRIBUTES];
|
||||
int num_vertex_bindings;
|
||||
|
||||
ReorderDrawMode draw_mode;
|
||||
VkDeviceSize index_indirect_offset;
|
||||
uint32_t draw_count;
|
||||
uint32_t vertex_count;
|
||||
int32_t first_vertex;
|
||||
|
||||
bool has_dynamic_line_width;
|
||||
float line_width;
|
||||
|
||||
VkViewport viewport;
|
||||
VkRect2D scissor;
|
||||
|
||||
float push_values[NV2A_VERTEXSHADER_ATTRIBUTES * 4];
|
||||
int num_push_values;
|
||||
bool use_push_constants;
|
||||
bool use_bindless_textures;
|
||||
#if OPT_BINDLESS_TEXTURES
|
||||
uint32_t tex_bindless_indices[NV2A_MAX_TEXTURES];
|
||||
#endif
|
||||
VkPipelineLayout layout;
|
||||
|
||||
int sequence_number;
|
||||
int group_order;
|
||||
|
||||
bool color_write;
|
||||
bool depth_test;
|
||||
bool stencil_test;
|
||||
} ReorderWindowEntry;
|
||||
|
||||
#define REORDER_MAX_PIPELINES 32
|
||||
|
||||
typedef struct ReorderWindow {
|
||||
ReorderWindowEntry entries[REORDER_WINDOW_MAX];
|
||||
int count;
|
||||
bool active;
|
||||
|
||||
PipelineBinding *seen_pipelines[REORDER_MAX_PIPELINES];
|
||||
int seen_pipeline_group[REORDER_MAX_PIPELINES];
|
||||
int num_seen_pipelines;
|
||||
int next_group;
|
||||
} ReorderWindow;
|
||||
#endif
|
||||
|
||||
typedef struct QueryReport {
|
||||
QSIMPLEQ_ENTRY(QueryReport) entry;
|
||||
bool clear;
|
||||
@@ -491,6 +551,10 @@ typedef struct PGRAPHVkState {
|
||||
bool shader_bindings_changed;
|
||||
bool use_push_constants_for_uniform_attrs;
|
||||
|
||||
#if OPT_REORDER_SAFE_WINDOWS
|
||||
ReorderWindow reorder_window;
|
||||
#endif
|
||||
|
||||
Lru shader_module_cache;
|
||||
ShaderModuleCacheEntry *shader_module_cache_entries;
|
||||
size_t shader_module_cache_target;
|
||||
@@ -685,6 +749,7 @@ void pgraph_vk_draw_begin(NV2AState *d);
|
||||
void pgraph_vk_draw_end(NV2AState *d);
|
||||
void pgraph_vk_finish(PGRAPHState *pg, FinishReason why);
|
||||
void pgraph_vk_flush_draw(NV2AState *d);
|
||||
void pgraph_vk_flush_reorder_window(NV2AState *d);
|
||||
void pgraph_vk_begin_command_buffer(PGRAPHState *pg);
|
||||
void pgraph_vk_ensure_command_buffer(PGRAPHState *pg);
|
||||
void pgraph_vk_ensure_not_in_render_pass(PGRAPHState *pg);
|
||||
|
||||
@@ -2029,6 +2029,9 @@ void pgraph_vk_surface_update(NV2AState *d, bool upload, bool color_write,
|
||||
update_surface_part(d, true, false);
|
||||
}
|
||||
} else {
|
||||
#if OPT_REORDER_SAFE_WINDOWS
|
||||
pgraph_vk_flush_reorder_window(d);
|
||||
#endif
|
||||
if ((color_write || pg->surface_color.write_enabled_cache)
|
||||
&& pg->surface_color.draw_dirty) {
|
||||
update_surface_part(d, false, true);
|
||||
|
||||
@@ -689,6 +689,13 @@ static void copy_zeta_surface_to_texture(PGRAPHState *pg, SurfaceBinding *surfac
|
||||
TextureShape *state = &texture->key.state;
|
||||
VkColorFormatInfo vkf = kelvin_color_format_vk_map[state->color_format];
|
||||
|
||||
#if OPT_REORDER_SAFE_WINDOWS
|
||||
if (r->reorder_window.count > 0) {
|
||||
NV2AState *d = container_of(pg, NV2AState, pgraph);
|
||||
pgraph_vk_flush_reorder_window(d);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool use_compute_to_convert_depth_stencil =
|
||||
surface->host_fmt.vk_format == VK_FORMAT_D24_UNORM_S8_UINT ||
|
||||
surface->host_fmt.vk_format == VK_FORMAT_D32_SFLOAT_S8_UINT;
|
||||
@@ -1216,6 +1223,13 @@ static void copy_surface_to_texture(PGRAPHState *pg, SurfaceBinding *surface,
|
||||
TextureShape *state = &texture->key.state;
|
||||
VkColorFormatInfo vkf = kelvin_color_format_vk_map[state->color_format];
|
||||
|
||||
#if OPT_REORDER_SAFE_WINDOWS
|
||||
if (r->reorder_window.count > 0) {
|
||||
NV2AState *d = container_of(pg, NV2AState, pgraph);
|
||||
pgraph_vk_flush_reorder_window(d);
|
||||
}
|
||||
#endif
|
||||
|
||||
nv2a_profile_inc_counter(NV2A_PROF_SURF_TO_TEX);
|
||||
|
||||
trace_nv2a_pgraph_surface_render_to_texture(
|
||||
|
||||
Reference in New Issue
Block a user