intel: Add has_bit6_swizzle to devinfo

There's no good reason to have this rather complex check in three
drivers.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13636>
This commit is contained in:
Jason Ekstrand
2021-11-02 15:49:27 -05:00
committed by Marge Bot
parent a0dc303b45
commit 953a4ca6fe
20 changed files with 103 additions and 170 deletions
+1 -15
View File
@@ -961,21 +961,7 @@ anv_physical_device_try_create(struct anv_instance *instance,
device->compiler->compact_params = false;
device->compiler->indirect_ubos_use_sampler = device->info.ver < 12;
/* Broadwell PRM says:
*
* "Before Gfx8, there was a historical configuration control field to
* swizzle address bit[6] for in X/Y tiling modes. This was set in three
* different places: TILECTL[1:0], ARB_MODE[5:4], and
* DISP_ARB_CTL[14:13].
*
* For Gfx8 and subsequent generations, the swizzle fields are all
* reserved, and the CPU's memory controller performs all address
* swizzling modifications."
*/
bool swizzled =
device->info.ver < 8 && anv_gem_get_bit6_swizzle(fd, I915_TILING_X);
isl_device_init(&device->isl_dev, &device->info, swizzled);
isl_device_init(&device->isl_dev, &device->info);
result = anv_physical_device_init_uuids(device);
if (result != VK_SUCCESS)
-55
View File
@@ -330,61 +330,6 @@ anv_gem_get_drm_cap(int fd, uint32_t capability)
return cap.value;
}
bool
anv_gem_get_bit6_swizzle(int fd, uint32_t tiling)
{
struct drm_gem_close close;
int ret;
struct drm_i915_gem_create gem_create = {
.size = 4096,
};
if (intel_ioctl(fd, DRM_IOCTL_I915_GEM_CREATE, &gem_create)) {
assert(!"Failed to create GEM BO");
return false;
}
bool swizzled = false;
/* set_tiling overwrites the input on the error path, so we have to open
* code intel_ioctl.
*/
do {
struct drm_i915_gem_set_tiling set_tiling = {
.handle = gem_create.handle,
.tiling_mode = tiling,
.stride = tiling == I915_TILING_X ? 512 : 128,
};
ret = ioctl(fd, DRM_IOCTL_I915_GEM_SET_TILING, &set_tiling);
} while (ret == -1 && (errno == EINTR || errno == EAGAIN));
if (ret != 0) {
assert(!"Failed to set BO tiling");
goto close_and_return;
}
struct drm_i915_gem_get_tiling get_tiling = {
.handle = gem_create.handle,
};
if (intel_ioctl(fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling)) {
assert(!"Failed to get BO tiling");
goto close_and_return;
}
swizzled = get_tiling.swizzle_mode != I915_BIT_6_SWIZZLE_NONE;
close_and_return:
memset(&close, 0, sizeof(close));
close.handle = gem_create.handle;
intel_ioctl(fd, DRM_IOCTL_GEM_CLOSE, &close);
return swizzled;
}
bool
anv_gem_has_context_priority(int fd, int priority)
{
-6
View File
@@ -143,12 +143,6 @@ anv_gem_get_drm_cap(int fd, uint32_t capability)
return 0;
}
bool
anv_gem_get_bit6_swizzle(int fd, uint32_t tiling)
{
unreachable("Unused");
}
int
anv_gem_create_context(struct anv_device *device)
{
-1
View File
@@ -1445,7 +1445,6 @@ int anv_gem_get_context_param(int fd, int context, uint32_t param,
int anv_gem_get_param(int fd, uint32_t param);
uint64_t anv_gem_get_drm_cap(int fd, uint32_t capability);
int anv_gem_get_tiling(struct anv_device *device, uint32_t gem_handle);
bool anv_gem_get_bit6_swizzle(int fd, uint32_t tiling);
int anv_gem_context_get_reset_stats(int fd, int context,
uint32_t *active, uint32_t *pending);
int anv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle);