anv: Set up the memory-backed FIFO buffer

v2: Fix incorrect goto (Caio)
    Comment 3DSTATE_BTD programming (Caio)

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16970>
This commit is contained in:
Jason Ekstrand 2020-11-09 15:33:17 -06:00 committed by Marge Bot
parent 93526c89c5
commit 5814436159
5 changed files with 74 additions and 4 deletions

View file

@ -1711,6 +1711,29 @@
<field name="Blend State Pointer" start="38" end="63" type="offset"/>
</instruction>
<instruction name="3DSTATE_BTD" bias="2" length="6" engine="render">
<field name="DWord Length" start="0" end="7" type="uint" default="4"/>
<field name="3D Command Sub Opcode" start="16" end="23" type="uint" default="6"/>
<field name="3D Command Opcode" start="24" end="26" type="uint" default="1"/>
<field name="Command SubType" start="27" end="28" type="uint" default="0"/>
<field name="Command Type" start="29" end="31" type="uint" default="3"/>
<field name="Dispatch Timeout Counter" start="32" end="33" type="uint">
<value name="64 clocks" value="0"/>
<value name="128 clocks" value="1"/>
<value name="192 clocks" value="2"/>
<value name="256 clocks" value="3"/>
</field>
<field name="AMFS Mode" start="35" end="36" type="uint" prefix="AMFS_MODE">
<value name="NORMAL" value="0"/>
<value name="TOUCH" value="1"/>
<value name="BACKFILL" value="2"/>
<value name="FALLBACK" value="3"/>
</field>
<field name="Per DSS Memory Backed Buffer Size" start="64" end="66" type="uint"/>
<field name="Memory Backed Buffer Base Pointer" start="74" end="127" type="address"/>
<field name="Scratch Space Buffer" start="138" end="159" type="uint"/>
</instruction>
<instruction name="3DSTATE_CC_STATE_POINTERS" bias="2" length="2" engine="render">
<field name="DWord Length" start="0" end="7" type="uint" default="0"/>
<field name="3D Command Sub Opcode" start="16" end="23" type="uint" default="14"/>

View file

@ -3454,16 +3454,30 @@ VkResult anv_CreateDevice(
/* TODO(RT): Do we want some sort of data structure for this? */
memset(device->rt_scratch_bos, 0, sizeof(device->rt_scratch_bos));
if (device->info->has_ray_tracing) {
/* The docs say to always allocate 128KB per DSS */
const uint32_t btd_fifo_bo_size =
128 * 1024 * intel_device_info_dual_subslice_id_bound(device->info);
result = anv_device_alloc_bo(device,
"rt-btd-fifo",
btd_fifo_bo_size,
0 /* alloc_flags */,
0 /* explicit_address */,
&device->btd_fifo_bo);
if (result != VK_SUCCESS)
goto fail_trivial_batch_bo_and_scratch_pool;
}
result = anv_genX(device->info, init_device_state)(device);
if (result != VK_SUCCESS)
goto fail_trivial_batch_bo_and_scratch_pool;
goto fail_btd_fifo_bo;
struct vk_pipeline_cache_create_info pcc_info = { };
device->default_pipeline_cache =
vk_pipeline_cache_create(&device->vk, &pcc_info, NULL);
if (!device->default_pipeline_cache) {
result = vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
goto fail_trivial_batch_bo_and_scratch_pool;
goto fail_btd_fifo_bo;
}
/* Internal shaders need their own pipeline cache because, unlike the rest
@ -3501,6 +3515,9 @@ VkResult anv_CreateDevice(
vk_pipeline_cache_destroy(device->internal_cache, NULL);
fail_default_pipeline_cache:
vk_pipeline_cache_destroy(device->default_pipeline_cache, NULL);
fail_btd_fifo_bo:
if (device->info->has_ray_tracing)
anv_device_release_bo(device, device->btd_fifo_bo);
fail_trivial_batch_bo_and_scratch_pool:
anv_scratch_pool_finish(device, &device->scratch_pool);
fail_trivial_batch:
@ -3571,6 +3588,9 @@ void anv_DestroyDevice(
vk_pipeline_cache_destroy(device->internal_cache, NULL);
vk_pipeline_cache_destroy(device->default_pipeline_cache, NULL);
if (device->info->has_ray_tracing)
anv_device_release_bo(device, device->btd_fifo_bo);
#ifdef HAVE_VALGRIND
/* We only need to free these to prevent valgrind errors. The backing
* BO will go away in a couple of lines so we don't actually leak.
@ -4754,9 +4774,9 @@ vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t* pSupportedVersion)
*
* - Loader interface v4 differs from v3 in:
* - The ICD must implement vk_icdGetPhysicalDeviceProcAddr().
*
*
* - Loader interface v5 differs from v4 in:
* - The ICD must support Vulkan API version 1.1 and must not return
* - The ICD must support Vulkan API version 1.1 and must not return
* VK_ERROR_INCOMPATIBLE_DRIVER from vkCreateInstance() unless a
* Vulkan Loader with interface v4 or smaller is being used and the
* application provides an API version that is greater than 1.0.

View file

@ -1140,6 +1140,7 @@ struct anv_device {
struct anv_scratch_pool scratch_pool;
struct anv_bo *rt_scratch_bos[16];
struct anv_bo *btd_fifo_bo;
/** Shadow ray query BO
*

View file

@ -5379,6 +5379,9 @@ cmd_buffer_trace_rays(struct anv_cmd_buffer *cmd_buffer,
anv_reloc_list_add_bo(cmd_buffer->batch.relocs,
cmd_buffer->batch.alloc,
rt->scratch.bo);
anv_reloc_list_add_bo(cmd_buffer->batch.relocs,
cmd_buffer->batch.alloc,
cmd_buffer->device->btd_fifo_bo);
/* Allocate and set up our RT_DISPATCH_GLOBALS */
struct anv_state rtdg_state =

View file

@ -228,6 +228,29 @@ init_common_queue_state(struct anv_queue *queue, struct anv_batch *batch)
sba.L1CacheControl = L1CC_WB;
}
#endif
#if GFX_VERx10 >= 125
if (device->info->has_ray_tracing) {
anv_batch_emit(batch, GENX(3DSTATE_BTD), btd) {
/* TODO: This is the timeout after which the bucketed thread
* dispatcher will kick off a wave of threads. We go with the
* lowest value for now. It could be tweaked on a per
* application basis (drirc).
*/
btd.DispatchTimeoutCounter = _64clocks;
/* BSpec 43851: "This field must be programmed to 6h i.e. memory
* backed buffer must be 128KB."
*/
btd.PerDSSMemoryBackedBufferSize = 6;
btd.MemoryBackedBufferBasePointer = (struct anv_address) {
/* This batch doesn't have a reloc list so we can't use the BO
* here. We just use the address directly.
*/
.offset = device->btd_fifo_bo->offset,
};
}
}
#endif
}
static VkResult