mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-24 13:45:57 +00:00
Merge commit 'f278e91a' into task/pr1412
# Conflicts: # runtime/cfg.c
This commit is contained in:
commit
83e4037f9c
5 files changed
+89
-2
No files matched your search
@@ -172,6 +172,7 @@ Many rows below are developer tools that only act together with another setting
|
||||
| `ub_overlay` (default `1`) | `0` copies each uniform update inside a pass into its buffer at once, ending the pass with a full barrier; `ab` alternates with the `ab` blocks. | With `0` scenes with many updated blocks (the terrain, the sky islands) take longer on the GPU; `TOTK_TRACE=perf` prints how many updates stayed in their pass. | Caution |
|
||||
| `ub_overlay_out` (default `1`) | `0` copies each uniform update between passes into its buffer at once, behind a full barrier of its own; `ab` alternates with the `ab` blocks. Needs `ub_overlay`. | With `0` a run of updates before a pass costs a full GPU barrier each; `TOTK_TRACE=perf` prints how many updates between passes were overlaid. | Caution |
|
||||
| `ubo_snapshot` (default `1`) | `0` binds live memory for uniform blocks; `ab` alternates with the `ab` blocks. | Without snapshots late draws read another object's matrix, so objects can be drawn in the wrong place. | Risky |
|
||||
| `null_attach` (default `0`) | `1` gives the colour slots of a render pass that hold no target a dummy attachment (an `R8_UNORM` image of the pass's size, writes masked off) instead of a null image view. A workaround to try on Intel's legacy Windows driver for 6th-10th generation graphics (HD 520, UHD 620, driver 101.21xx), which crashed inside `vkCmdBeginRendering` at the first pass with an empty slot (#1343). | A little memory per pass size (1.4 MiB at 1600x896); pipelines with empty slots are built again once. | Caution |
|
||||
| `vk_no_float64` (default `0`) | `1` clears the 64-bit float feature, so the translator lowers FP64 to FP32. | Shaders change, so the shader cache entries for it are made again; precision of FP64 shaders drops. | Caution |
|
||||
| `vk_no_host_import` (default `0`) | `1` leaves `VK_EXT_external_memory_host` off even when the GPU has it, so the game takes the path of a GPU without it: every CPU-visible pool gets shadow storage, as under Wine. For testing that path. | Shadow storage costs CPU copies before each submission and more memory than imports. | Caution |
|
||||
| `vk_ssbo_align` (default unset) | Power of two that storage buffer offsets are treated as needing, to test the unaligned path. | The translator and the draw code round storage offsets down to it; shaders are translated again. | Caution |
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ static const char *const known[] = {
|
||||
"LIB_PREBUILD_KEEP", "LIB_PREBUILD_THREADS", "LIGHTNING_FIX", "LOCALE", "LOD_GUARD", "LOD_STEADY", "LSTICK_DEADZONE", "MAP_CLICK", "MEMORY", "MEMX", "MENU_LANG", "MENU_TEST", "MENU_FONT_FONTCONFIG",
|
||||
"MEM_RESERVE_MIB", "MENU_CURSOR", "MENU_CURSOR_LOG", "MENU_TEST_DIR", "MENU_TEST_SET", "MINIMAL_LAYOUT", "MIRROR_GAP", "MODS_DIR", "MODS_DISABLED", "MODS_NO_CODE", "MODS_ORDER", "MODS_REBUILD", "MODS_WITHOUT_CODE", "MOTION", "MOUSE_AIM_SCALE", "MOUSE_MODE", "MOUSE_DIRECT_PATCH", "MOUSE_SENS", "MOVIE_ASPECT", "MOVIE_HOST", "MOVIE_PACE",
|
||||
"MVOBJ_ALL", "MVOBJ_BANKS", "MVOBJ_EQUAL", "MVOBJ_EXACT", "MVOBJ_EXEC", "MVOBJ_NOC4", "MVOBJ_ONLY", "MVOBJ_TIMES", "MVPREV_CHECK", "MVPREV_GROW", "MVPREV_SKIP", "MVPREV_TRUST", "MV_CHECK",
|
||||
"MV_SURVEY",
|
||||
"MV_SURVEY", "NULL_ATTACH",
|
||||
"ONE_PER_CORE", "OPERATION_MODE", "OPTREF_GUARD", "OUTPUT_RES", "PAD_LAYOUT", "PASS_CRUMBS", "PATCH_OUTPUT", "PATCH_SCENE", "PCORE", "PCSS", "PCSS_K", "PERF_CENSUS", "PERF_OVERLAY", "PERF_SLOW_MS", "PIPELINE_CACHE", "PIPE_MEMO", "PIPE_PREBUILD", "PIPE_SKIP", "PIPE_SYNC", "PIPE_WAIT", "PLUGIN_TICK_OFFSET", "PLUGIN_TRACE", "POINTER_IMAGE",
|
||||
"PREWARM_XLATE", "PROBE_MOVIE", "PROBE_MOVIE_BENCH", "PROBE_MOVIE_SHOT", "PROFILE", "PROFILE_CHAINS", "PROFILE_DIR", "PROFILE_FRAMES",
|
||||
"PROFILE_MAIN", "PROFILE_RENDER", "PROMPTS", "PUSH_SKIP", "PUSH_STAGE", "QUICKLOAD_KEY", "QUICKSAVE", "QUICKSAVE_KEY", "RDOC", "RDOC_DIR", "RDOC_DLL", "REALTIME", "REC_ASYNC", "REC_END", "REC_SPIN_US", "REEXEC", "REFLEX",
|
||||
|
||||
@@ -507,6 +507,10 @@ typedef struct {
|
||||
// into it, when the last draw into it was that copy and the swapchain is HDR10.
|
||||
void vk_hdr_present_source(const VkTexImage *win, VkImage *image, VkFormat *format);
|
||||
void vk_hdr_image_gone(VkImage image);
|
||||
// TOTK_NULL_ATTACH=1: empty colour slots of a pass get a dummy VK_EXEC_NULL_ATTACH_FMT attachment, and the pipelines name
|
||||
// that format for them with writes masked off (vk_exec.c vk_exec_null_attach, vk_pipeline.c gkey_fill).
|
||||
#define VK_EXEC_NULL_ATTACH_FMT VK_FORMAT_R8_UNORM
|
||||
int vk_exec_null_attach(void);
|
||||
const VkTexImage *vk_texture_get(const tex_t *t); // created and made current; NULL for BUFFER or unmapped formats
|
||||
const VkTexImage *vk_texture_revive(const tex_t *t, uint32_t pos); // the entry vk_texture_get would return if it exists, made live at op pos
|
||||
// A texture slot; a slot whose texture was finalized follows the live texture at the same storage (hle_nvn.c).
|
||||
|
||||
+79
-1
@@ -674,6 +674,76 @@ static void barrier_to(VkExec *ex, const VkImage *want, const VkImageAspectFlags
|
||||
|
||||
void vk_exec_barrier(VkExec *ex) { barrier_to(ex, NULL, NULL, 0); }
|
||||
|
||||
// TOTK_NULL_ATTACH=1 (null_attach, default 0): colour slots of a pass that hold no target get a view of a dummy image
|
||||
// instead of VK_NULL_HANDLE. Leaving a slot's imageView null is valid Vulkan, but Intel's legacy Windows driver for
|
||||
// 6th-10th generation graphics (HD 520, UHD 620; driver 101.21xx, Vulkan 1.3.215) faulted inside vkCmdBeginRendering at
|
||||
// the game's first pass with an empty slot, the 1600x896 scene G-buffer pass with slots 2 and 4 empty (issue #1343).
|
||||
// The pipelines then name NULL_ATTACH_FMT for those slots, with their writes masked off (vk_pipeline.c gkey_fill,
|
||||
// target_wmask), so the views match the pipelines' formats. One image per pass size, layer count and sample count,
|
||||
// in GENERAL from the start (moved there in the upload batch) and kept to the end; loads and stores are DONT_CARE.
|
||||
#define NULL_ATTACH_MAX 24
|
||||
typedef struct { uint32_t w, h, layers, samples; VkImage img; VmaAllocation alloc; VkImageView view; } NullAttach;
|
||||
static NullAttach null_att[NULL_ATTACH_MAX];
|
||||
static int nnull_att;
|
||||
static PlatMutex null_att_lock = PLAT_MUTEX_INIT;
|
||||
|
||||
int vk_exec_null_attach(void) {
|
||||
static int on = -1;
|
||||
if (on < 0) {
|
||||
on = rt_knob("NULL_ATTACH", "0") == 1;
|
||||
if (on) rt_log("vk_exec: empty colour slots get a dummy attachment (TOTK_NULL_ATTACH=1)");
|
||||
}
|
||||
return on;
|
||||
}
|
||||
|
||||
static VkImageView null_attach_view(uint32_t w, uint32_t h, uint32_t layers, uint32_t samples) {
|
||||
plat_mutex_lock(&null_att_lock);
|
||||
for (int i = 0; i < nnull_att; i++) {
|
||||
const NullAttach *a = &null_att[i];
|
||||
if (a->w == w && a->h == h && a->layers == layers && a->samples == samples) {
|
||||
VkImageView v = a->view;
|
||||
plat_mutex_unlock(&null_att_lock);
|
||||
return v;
|
||||
}
|
||||
}
|
||||
static int warned;
|
||||
if (nnull_att == NULL_ATTACH_MAX) {
|
||||
if (!warned++) rt_log("vk_exec: more than %d dummy attachment shapes: further empty slots stay empty", NULL_ATTACH_MAX);
|
||||
plat_mutex_unlock(&null_att_lock);
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
VkCtx *c = vk_ctx();
|
||||
NullAttach a = {w, h, layers, samples, VK_NULL_HANDLE, NULL, VK_NULL_HANDLE};
|
||||
VkImageCreateInfo ci = {.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, .imageType = VK_IMAGE_TYPE_2D,
|
||||
.format = VK_EXEC_NULL_ATTACH_FMT, .extent = {w, h, 1}, .mipLevels = 1, .arrayLayers = layers,
|
||||
.samples = (VkSampleCountFlagBits)samples, .tiling = VK_IMAGE_TILING_OPTIMAL,
|
||||
.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED};
|
||||
VmaAllocationCreateInfo ai = {.usage = VMA_MEMORY_USAGE_AUTO_PREFER_DEVICE};
|
||||
if (vmaCreateImage(c->vma, &ci, &ai, &a.img, &a.alloc, NULL) != VK_SUCCESS) {
|
||||
if (!warned++) rt_log("vk_exec: a %ux%u x %u dummy attachment could not be created: the slot stays empty", w, h, layers);
|
||||
plat_mutex_unlock(&null_att_lock);
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
VkImageViewCreateInfo vi = {.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = a.img,
|
||||
.viewType = layers > 1 ? VK_IMAGE_VIEW_TYPE_2D_ARRAY : VK_IMAGE_VIEW_TYPE_2D,
|
||||
.format = VK_EXEC_NULL_ATTACH_FMT,
|
||||
.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, layers}};
|
||||
if (vkCreateImageView(c->device, &vi, NULL, &a.view) != VK_SUCCESS) {
|
||||
vmaDestroyImage(c->vma, a.img, a.alloc);
|
||||
if (!warned++) rt_log("vk_exec: a dummy attachment view could not be created: the slot stays empty");
|
||||
plat_mutex_unlock(&null_att_lock);
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
// In the upload batch, which goes to the queue before the part that records this pass (as the BC stand-ins)
|
||||
VkCommandBuffer cb = vk_upload_begin();
|
||||
image_barrier(cb, a.img, VK_IMAGE_LAYOUT_UNDEFINED, layers);
|
||||
vk_upload_end();
|
||||
null_att[nnull_att++] = a;
|
||||
plat_mutex_unlock(&null_att_lock);
|
||||
rt_log("vk_exec: dummy attachment %ux%u x %u, %u samples, for empty colour slots", w, h, layers, samples);
|
||||
return a.view;
|
||||
}
|
||||
|
||||
void vk_exec_pass_begin(VkExec *ex) {
|
||||
if (ex->in_pass) return;
|
||||
resolve_rt(ex);
|
||||
@@ -699,7 +769,15 @@ void vk_exec_pass_begin(VkExec *ex) {
|
||||
for (uint32_t i = 0; i < ex->pass_ncolor; i++) {
|
||||
const VkExecTarget *t = &ex->color[i];
|
||||
ca[i] = (VkRenderingAttachmentInfo){.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO};
|
||||
if (!t->image) continue;
|
||||
if (!t->image) {
|
||||
if (vk_exec_null_attach()) { // a dummy for the empty slot, which the pipelines name too (see above)
|
||||
ca[i].imageView = null_attach_view(ex->pass_w, ex->pass_h, ex->pass_layers, ex->pass_samples);
|
||||
ca[i].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||
ca[i].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
ca[i].storeOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ca[i].imageView = view_of(ex, t);
|
||||
ca[i].imageLayout = fbl >> i & 1 ? VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT : VK_IMAGE_LAYOUT_GENERAL;
|
||||
ca[i].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
|
||||
|
||||
@@ -1345,6 +1345,7 @@ static uint32_t target_wmask(const VkPipeState *s, int i) {
|
||||
uint32_t m = s->chmask.mask >> (4 * i) & 0xf;
|
||||
if (s->fs && !(gfx_shader_outputs(s->fs, NULL) >> i & 1)) m = 0;
|
||||
if (i == 1 && s->fs && P.f_dual_src && uses_src1(s)) m = 0; // output 1 is the second blend source (spirv_dual_source)
|
||||
if (!s->color_fmt[i] && vk_exec_null_attach()) m = 0; // an empty slot's dummy attachment (vk_exec.c) takes no writes
|
||||
return m;
|
||||
}
|
||||
|
||||
@@ -1380,6 +1381,9 @@ static void gkey_fill(const VkPipeState *s, GKey *k) {
|
||||
o[3] = (uint8_t)blend_factor(b->src_a), o[4] = (uint8_t)blend_factor(b->dst_a), o[5] = (uint8_t)blend_op(b->eq_a);
|
||||
}
|
||||
}
|
||||
if (vk_exec_null_attach()) // empty slots get the dummy attachment's format (vk_exec.c vk_exec_null_attach)
|
||||
for (int i = 0; i < k->n_color; i++)
|
||||
if (k->color[i] == VK_FORMAT_UNDEFINED) k->color[i] = VK_EXEC_NULL_ATTACH_FMT;
|
||||
if (!P.dyn_vi) {
|
||||
VtxInput v;
|
||||
vertex_input(s, &v);
|
||||
|
||||
Reference in new issue
Block a user