Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dm/gfx/vk_android/vka.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ typedef struct {
// memu: NVN2 task and mesh draws drawn through compute (vka_memu.c): by default where the device lacks meshShader or taskShader, DM_VK_MESH_EMU=1 on any device, =0
// never (restart). cs_groups: maxComputeWorkGroupCount[0]
int memu; uint32_t cs_groups;
int comp_ctl; // PEANUTS: VK_EXT_image_compression_control is on: an image with a raw-bits view is made uncompressed (vka_tex.c img_create)
int fb_loop; // PEANUTS: VK_EXT_attachment_feedback_loop_layout + _dynamic_state are on (DM_VK_FB_LOOP=0 leaves them off): a draw sampling its own attachment says so (vka_draw.c)
int xfb; // PEANUTS: VK_EXT_transform_feedback is on (DM_VK_XFB=0 leaves it off): NVN transform feedback is captured (vka_tf.c)
int cache_ctl; // pipelineCreationCacheControl (core 1.3): a pipeline may be asked for with FAIL_ON_PIPELINE_COMPILE_REQUIRED (vka_pso.c cs_obtain's cache-only try)
Expand Down
7 changes: 7 additions & 0 deletions dm/gfx/vk_android/vka_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ static int init_once(void) {
int x_fbl = has_ext(de, nde, VK_EXT_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_EXTENSION_NAME) && has_ext(de, nde, VK_EXT_ATTACHMENT_FEEDBACK_LOOP_DYNAMIC_STATE_EXTENSION_NAME) &&
!(fbl_env && !strcmp(fbl_env, "0"));
if (x_fbl) { dext[ndext++] = VK_EXT_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_EXTENSION_NAME; dext[ndext++] = VK_EXT_ATTACHMENT_FEEDBACK_LOOP_DYNAMIC_STATE_EXTENSION_NAME; }
// PEANUTS: VK_EXT_image_compression_control: an image read through a view of another texel layout is made without UBWC (vka_tex.c img_create, rawv): Turnip on a7xx
// keeps UBWC whatever the image's view formats (ubwc_all_formats_compatible), and a raw R32_UINT view of an A2B10G10R10 target read compressed blocks
int x_icc = has_ext(de, nde, VK_EXT_IMAGE_COMPRESSION_CONTROL_EXTENSION_NAME);
if (x_icc) dext[ndext++] = VK_EXT_IMAGE_COMPRESSION_CONTROL_EXTENSION_NAME;
V.mem_budget = has_ext(de, nde, VK_EXT_MEMORY_BUDGET_EXTENSION_NAME); // the image heap's budget, for the texture cache's limit (vka_tex.c img_limit_update)
if (V.mem_budget) dext[ndext++] = VK_EXT_MEMORY_BUDGET_EXTENSION_NAME;
free(de);
Expand All @@ -250,13 +254,15 @@ static int init_once(void) {
VkPhysicalDeviceTransformFeedbackFeaturesEXT fxfb = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT}; // PEANUTS: transform feedback (vka_tf.c)
VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT ffbl = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_FEATURES_EXT}; // PEANUTS: feedback loops
VkPhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT ffbd = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_DYNAMIC_STATE_FEATURES_EXT};
VkPhysicalDeviceImageCompressionControlFeaturesEXT ficc = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_FEATURES_EXT}; // PEANUTS: raw views without UBWC
void *chain = placed ? &fmp : NULL;
#define LINK(on, st) if (on) { (st).pNext = chain; chain = &(st); }
struct { VkStructureType sType; void *pNext; VkBool32 queuePerfHint; } fph = {(VkStructureType)1000302001}; // VkPhysicalDeviceQueuePerfHintFeaturesQCOM (not in the NDK's headers yet)
LINK(x_vin, fvin) LINK(x_rob, frob) LINK(x_i8, fi8) LINK(x_div, fdiv) LINK(x_ph, fph) LINK(x_gpl, fgpl) LINK(x_mesh, fmesh) LINK(x_fault, ffault)
LINK(core_m5 || x_m5, fm5) // PEANUTS: bounded draw ranges
LINK(x_xfb, fxfb) // PEANUTS: transform feedback (vka_tf.c)
LINK(x_fbl, ffbl) LINK(x_fbl, ffbd) // PEANUTS: feedback loops (vka_draw.c)
LINK(x_icc, ficc) // PEANUTS: raw views without UBWC (vka_tex.c)
#undef LINK
VkPhysicalDeviceVulkan13Features f13 = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES, .pNext = chain};
VkPhysicalDeviceVulkan12Features f12 = {VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES, .pNext = &f13};
Expand All @@ -277,6 +283,7 @@ static int init_once(void) {
if (!f12.timelineSemaphore || !f13.dynamicRendering) { VRED("the device lacks timeline semaphores (%d) or dynamic rendering (%d)", f12.timelineSemaphore, f13.dynamicRendering); return 0; }
fxfb.geometryStreams = VK_FALSE; V.xfb = x_xfb && fxfb.transformFeedback; // PEANUTS: transform feedback (vka_tf.c): captures of stream 0 only
V.fb_loop = x_fbl && ffbl.attachmentFeedbackLoopLayout && ffbd.attachmentFeedbackLoopDynamicState; // PEANUTS: feedback loops (vka_draw.c)
V.comp_ctl = x_icc && ficc.imageCompressionControl; // PEANUTS: raw views without UBWC (vka_tex.c)
V.imageless = f12.imagelessFramebuffer; // (enabled with the rest of f12)
V.draw_count = f12.drawIndirectCount;
V.minmax = f12.samplerFilterMinmax; // (enabled with the rest of f12)
Expand Down
15 changes: 14 additions & 1 deletion dm/gfx/vk_android/vka_tex.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,15 @@ static vka_img *img_create_(const tex_t *t, const vka_fmt *f, uint32_t base, int
// when it has no type answer, and KTGL takes the bits back with as_type<int> (nvn_mtl.m tbuf_view_format), so the view of the shader's class (class_twin) is there without waiting for the pair to be learned
if (tbuf && ubwc && f->kind <= 2) { VkFormat tw = class_twin(f->vk, f->kind ? 0 : 1); if (tw && !vkfl_has(&im->fl, (uint32_t)f->vk, (uint32_t)tw) && im->fl.nx < VKFL_MAX) im->fl.x[im->fl.nx++] = (uint32_t)tw; }
uint32_t fls[2 + VKFL_MAX]; int nfl = ubwc ? vkfl_entries(&im->fl, (uint32_t)f->vk, fls) : 0; // (own format first, no UNDEFINED entry)
VkImageFormatListCreateInfo fli = {VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO, .viewFormatCount = (uint32_t)nfl, .pViewFormats = (const VkFormat *)fls};
// PEANUTS: a list with a view of another texel layout than the image's own (not its sRGB / raw UNORM twin: A2B10G10R10 with R32_UINT, a shader reading the raw bits)
// is made uncompressed (VK_EXT_image_compression_control, below): Turnip on a7xx keeps UBWC whatever the view formats (ubwc_all_formats_compatible) and the R32_UINT
// view read compressed blocks (Xenoblade Chronicles: Definitive Edition's Colony 9 roads, AYN Thor, Turnip v27; TU_DEBUG=noubwc drew them right). The learned
// reinterpretations were meant to go without UBWC (DM_VK_VIEW_LEARN). DM_VK_UBWC_RAWVIEW=0: compressed as the driver decides
int rawv = 0;
if (nfl > 1 && f->kind <= 2 && VKA_ENV("DM_VK_UBWC_RAWVIEW", 1))
for (int k = 0; k < nfl; k++) { VkFormat x = (VkFormat)fls[k]; if (x != f->vk && x != srgb_twin(f->vk) && x != raw_unorm_twin(f->vk) && srgb_twin(x) != f->vk) rawv = 1; }
VkImageCompressionControlEXT icc = {VK_STRUCTURE_TYPE_IMAGE_COMPRESSION_CONTROL_EXT, .flags = VK_IMAGE_COMPRESSION_DISABLED_EXT};
VkImageFormatListCreateInfo fli = {VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO, .pNext = rawv && V.comp_ctl ? &icc : NULL, .viewFormatCount = (uint32_t)nfl, .pViewFormats = (const VkFormat *)fls};
VkImageCreateFlags fl = nfl || im->fl.any ? VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT : 0;
// A texture with image intent whose own format has no storage use (RGB9E5, R11G11B10 on some drivers) but a listed view format has (R32_UINT): storage use through
// that view (EXTENDED_USAGE); views in formats without it leave storage out (vka_view)
Expand Down Expand Up @@ -3644,6 +3652,11 @@ static VkFormat class_twin(VkFormat v, int cls) {
for (size_t i = 0; i < sizeof t / sizeof *t; i++) for (int c = 0; c < 3; c++) if (t[i].f[c] == v) return t[i].f[cls];
if (v == VK_FORMAT_R16_UNORM || v == VK_FORMAT_R16_SNORM) return cls == 1 ? VK_FORMAT_R16_UINT : cls == 2 ? VK_FORMAT_R16_SINT : VK_FORMAT_UNDEFINED;
if (v == VK_FORMAT_R16G16_UNORM || v == VK_FORMAT_R16G16_SNORM) return cls == 1 ? VK_FORMAT_R16G16_UINT : cls == 2 ? VK_FORMAT_R16G16_SINT : VK_FORMAT_UNDEFINED;
// PEANUTS: a packed 4-byte texel with no integer layout of its own, read through a uint / int shader image: the texel's 32-bit word, as Maxwell's raw image load gives it
// (one compatibility class with R32_UINT). Xenoblade Chronicles: Definitive Edition reads its R11G11B10 1280x720 targets as uint images in four shaders; with no twin they read as unbound
if (v == VK_FORMAT_B10G11R11_UFLOAT_PACK32 || v == VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 || v == VK_FORMAT_A2B10G10R10_UNORM_PACK32 || v == VK_FORMAT_A2R10G10B10_UNORM_PACK32 ||
v == VK_FORMAT_B8G8R8A8_UNORM || v == VK_FORMAT_B8G8R8A8_SRGB || v == VK_FORMAT_R8G8B8A8_SRGB)
return cls == 1 ? VK_FORMAT_R32_UINT : cls == 2 ? VK_FORMAT_R32_SINT : VK_FORMAT_UNDEFINED;
return VK_FORMAT_UNDEFINED;
}
// The Vulkan format texture ID id is viewed in (its texture view's, else its own), UNDEFINED for none. Not its image's: textures of one memory and shape share an image made in
Expand Down
1 change: 1 addition & 0 deletions docs/advanced_settings.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ DM_VK_TL_POLL developer Diagnostics text both
DM_VK_TS_LOG developer Diagnostics text both
DM_VK_TU_UBWC_HINT developer Graphics text both
DM_VK_UBWC developer Graphics text both
DM_VK_UBWC_RAWVIEW developer Graphics text both
DM_VK_UB_DEFER developer Graphics text both
DM_VK_UB_PEEK developer Diagnostics text both
DM_VK_UB_PEEK_AT developer Diagnostics text both
Expand Down
1 change: 1 addition & 0 deletions docs/env_switches.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,7 @@ DM_VK_TL_POLL diagnostic `1` (Android, live, off) the host's waits for the repla
DM_VK_TS_LOG diagnostic `=<n>` (Android, at start) logs the first n submissions that carry timestamp reports (`ts log` lines): the completion time, how many reports and the span between the first and the last, and for the first four and the last report its address, its time relative to the completion, its submission slot and (`completion`) whether it took the completion time because no segment query could be read; shows what a game that subtracts two reports reads
DM_VK_TU_UBWC_HINT switch `0` (Android, restart, default 1) Turnip on an Adreno 740 does not get `FD_DEV_FEATURES=enable_tp_ubwc_flag_hint=<1|0>` from the system driver's version (`vka_driver.c` `ubwc_hint`: the texture unit's UBWC flag hint is one register for every driver on the GPU and must match the system driver's, v7xx on, v6xx off, or the picture flickers while Android composites on the GPU); an `FD_DEV_FEATURES` of the environment always wins
DM_VK_UBWC switch `0` (Android, live: images made from then on, 1) every colour image is MUTABLE_FORMAT without a format list, as before (any view format; no UBWC compression on Adreno)
DM_VK_UBWC_RAWVIEW switch `0` (Android, live: images made from then on, 1) a colour image whose format list holds a view of another texel layout (a raw R32_UINT view of A2B10G10R10, not an sRGB twin) keeps the compression the driver picks; on, it is made with `VK_IMAGE_COMPRESSION_DISABLED_EXT` where the device has `VK_EXT_image_compression_control` (Turnip on a7xx keeps UBWC whatever the view formats, and the raw view read compressed blocks: Xenoblade Chronicles: Definitive Edition's Colony 9 roads) [PEANUTS]
DM_VK_UB_DEFER switch `0` (Android, live, 1) an inline uniform update (`OP_UPDATE_UB`) ends an open render pass at once, as before; by default it is deferred to the pass end and draws in the pass whose uniform buffers overlap it bind a scratch shadow reconstructed from guest memory and the submission's queued writes
DM_VK_UB_PEEK diagnostic `=<hex key>[,…]` (Android, restart) logs the uniform buffers (constant buffers) those shaders' draws and dispatches bind from guest memory, as the CPU sees them when recorded (`ub peek`: 16 words as hex and float), to check a pass's parameters; `DM_VK_SB_PEEK_FROM` and `DM_VK_SB_PEEK_LINES` apply
DM_VK_UB_PEEK_AT diagnostic `=<word>[,<word>…]` (Android, live) with `DM_VK_UB_PEEK`, the first of the 16 words each line shows (default 0); a list (at most 8) logs one line per window, each counted in `DM_VK_SB_PEEK_LINES`
Expand Down