Commit 8c152a5e authored by Jonathan Marek's avatar Jonathan Marek Committed by Marge Bot

turnip: remove some dead/redundant code

A bit of cleanup to reduce noise in the codebase.
Signed-off-by: Jonathan Marek's avatarJonathan Marek <jonathan@marek.ca>
Part-of: <!5447>
parent 32143cba
Pipeline #160264 canceled with stages
in 27 minutes
......@@ -1211,13 +1211,13 @@ tu_CmdBlitImage(VkCommandBuffer commandBuffer,
static VkFormat
copy_format(VkFormat format)
{
switch (vk_format_get_blocksizebits(format)) {
case 8: return VK_FORMAT_R8_UINT;
case 16: return VK_FORMAT_R16_UINT;
case 32: return VK_FORMAT_R32_UINT;
case 64: return VK_FORMAT_R32G32_UINT;
case 96: return VK_FORMAT_R32G32B32_UINT;
case 128:return VK_FORMAT_R32G32B32A32_UINT;
switch (vk_format_get_blocksize(format)) {
case 1: return VK_FORMAT_R8_UINT;
case 2: return VK_FORMAT_R16_UINT;
case 4: return VK_FORMAT_R32_UINT;
case 8: return VK_FORMAT_R32G32_UINT;
case 12:return VK_FORMAT_R32G32B32_UINT;
case 16:return VK_FORMAT_R32G32B32A32_UINT;
default:
unreachable("unhandled format size");
}
......
......@@ -313,10 +313,10 @@ tu_GetDescriptorSetLayoutSupport(
uint64_t descriptor_sz = descriptor_size(binding->descriptorType);
uint64_t descriptor_alignment = 8;
if (size && !align_u64(size, descriptor_alignment)) {
if (size && !ALIGN_POT(size, descriptor_alignment)) {
supported = false;
}
size = align_u64(size, descriptor_alignment);
size = ALIGN_POT(size, descriptor_alignment);
uint64_t max_count = UINT64_MAX;
if (descriptor_sz)
......
......@@ -48,12 +48,12 @@ tu_image_create(VkDevice _device,
struct tu_image *image = NULL;
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO);
tu_assert(pCreateInfo->mipLevels > 0);
tu_assert(pCreateInfo->arrayLayers > 0);
tu_assert(pCreateInfo->samples > 0);
tu_assert(pCreateInfo->extent.width > 0);
tu_assert(pCreateInfo->extent.height > 0);
tu_assert(pCreateInfo->extent.depth > 0);
assert(pCreateInfo->mipLevels > 0);
assert(pCreateInfo->arrayLayers > 0);
assert(pCreateInfo->samples > 0);
assert(pCreateInfo->extent.width > 0);
assert(pCreateInfo->extent.height > 0);
assert(pCreateInfo->extent.depth > 0);
image = vk_zalloc2(&device->alloc, alloc, sizeof(*image), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
......@@ -517,20 +517,6 @@ tu_image_view_init(struct tu_image_view *iview,
.flags = ubwc_enabled).value;
}
unsigned
tu_image_queue_family_mask(const struct tu_image *image,
uint32_t family,
uint32_t queue_family)
{
if (!image->exclusive)
return image->queue_family_mask;
if (family == VK_QUEUE_FAMILY_EXTERNAL)
return (1u << TU_MAX_QUEUE_FAMILIES) - 1u;
if (family == VK_QUEUE_FAMILY_IGNORED)
return 1u << queue_family;
return 1u << family;
}
VkResult
tu_CreateImage(VkDevice device,
const VkImageCreateInfo *pCreateInfo,
......
......@@ -354,28 +354,6 @@ tu_dynamic_state_bit(VkDynamicState state)
}
}
static gl_shader_stage
tu_shader_stage(VkShaderStageFlagBits stage)
{
switch (stage) {
case VK_SHADER_STAGE_VERTEX_BIT:
return MESA_SHADER_VERTEX;
case VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT:
return MESA_SHADER_TESS_CTRL;
case VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT:
return MESA_SHADER_TESS_EVAL;
case VK_SHADER_STAGE_GEOMETRY_BIT:
return MESA_SHADER_GEOMETRY;
case VK_SHADER_STAGE_FRAGMENT_BIT:
return MESA_SHADER_FRAGMENT;
case VK_SHADER_STAGE_COMPUTE_BIT:
return MESA_SHADER_COMPUTE;
default:
unreachable("invalid VkShaderStageFlagBits");
return MESA_SHADER_NONE;
}
}
static bool
tu_logic_op_reads_dst(VkLogicOp op)
{
......@@ -2052,7 +2030,7 @@ tu_pipeline_builder_compile_shaders(struct tu_pipeline_builder *builder)
};
for (uint32_t i = 0; i < builder->create_info->stageCount; i++) {
gl_shader_stage stage =
tu_shader_stage(builder->create_info->pStages[i].stage);
vk_to_mesa_shader_stage(builder->create_info->pStages[i].stage);
stage_infos[stage] = &builder->create_info->pStages[i];
}
......
......@@ -43,7 +43,7 @@ struct cache_entry
char code[0];
};
void
static void
tu_pipeline_cache_init(struct tu_pipeline_cache *cache,
struct tu_device *device)
{
......@@ -66,7 +66,7 @@ tu_pipeline_cache_init(struct tu_pipeline_cache *cache,
memset(cache->hash_table, 0, byte_size);
}
void
static void
tu_pipeline_cache_finish(struct tu_pipeline_cache *cache)
{
for (unsigned i = 0; i < cache->table_size; ++i)
......@@ -88,41 +88,6 @@ entry_size(struct cache_entry *entry)
return ret;
}
void
tu_hash_shaders(unsigned char *hash,
const VkPipelineShaderStageCreateInfo **stages,
const struct tu_pipeline_layout *layout,
const struct tu_pipeline_key *key,
uint32_t flags)
{
struct mesa_sha1 ctx;
_mesa_sha1_init(&ctx);
if (key)
_mesa_sha1_update(&ctx, key, sizeof(*key));
if (layout)
_mesa_sha1_update(&ctx, layout->sha1, sizeof(layout->sha1));
for (int i = 0; i < MESA_SHADER_STAGES; ++i) {
if (stages[i]) {
TU_FROM_HANDLE(tu_shader_module, module, stages[i]->module);
const VkSpecializationInfo *spec_info =
stages[i]->pSpecializationInfo;
_mesa_sha1_update(&ctx, module->sha1, sizeof(module->sha1));
_mesa_sha1_update(&ctx, stages[i]->pName, strlen(stages[i]->pName));
if (spec_info) {
_mesa_sha1_update(
&ctx, spec_info->pMapEntries,
spec_info->mapEntryCount * sizeof spec_info->pMapEntries[0]);
_mesa_sha1_update(&ctx, spec_info->pData, spec_info->dataSize);
}
}
}
_mesa_sha1_update(&ctx, &flags, 4);
_mesa_sha1_final(&ctx, hash);
}
static struct cache_entry *
tu_pipeline_cache_search_unlocked(struct tu_pipeline_cache *cache,
const unsigned char *sha1)
......@@ -240,7 +205,7 @@ struct cache_header
uint8_t uuid[VK_UUID_SIZE];
};
void
static void
tu_pipeline_cache_load(struct tu_pipeline_cache *cache,
const void *data,
size_t size)
......
......@@ -92,8 +92,6 @@ typedef uint32_t xcb_window_t;
#define MAX_DYNAMIC_STORAGE_BUFFERS 8
#define MAX_DYNAMIC_BUFFERS \
(MAX_DYNAMIC_UNIFORM_BUFFERS + MAX_DYNAMIC_STORAGE_BUFFERS)
#define MAX_SAMPLES_LOG2 4
#define NUM_META_FS_KEYS 13
#define TU_MAX_DRM_DEVICES 8
#define MAX_VIEWS 8
#define MAX_BIND_POINTS 2 /* compute + graphics */
......@@ -106,83 +104,11 @@ typedef uint32_t xcb_window_t;
*/
#define MAX_UNIFORM_BUFFER_RANGE 0x10000
#define NUM_DEPTH_CLEAR_PIPELINES 3
/*
* This is the point we switch from using CP to compute shader
* for certain buffer operations.
*/
#define TU_BUFFER_OPS_CS_THRESHOLD 4096
#define A6XX_TEX_CONST_DWORDS 16
#define A6XX_TEX_SAMP_DWORDS 4
enum tu_mem_heap
{
TU_MEM_HEAP_VRAM,
TU_MEM_HEAP_VRAM_CPU_ACCESS,
TU_MEM_HEAP_GTT,
TU_MEM_HEAP_COUNT
};
enum tu_mem_type
{
TU_MEM_TYPE_VRAM,
TU_MEM_TYPE_GTT_WRITE_COMBINE,
TU_MEM_TYPE_VRAM_CPU_ACCESS,
TU_MEM_TYPE_GTT_CACHED,
TU_MEM_TYPE_COUNT
};
#define tu_printflike(a, b) __attribute__((__format__(__printf__, a, b)))
static inline uint32_t
align_u32(uint32_t v, uint32_t a)
{
assert(a != 0 && a == (a & -a));
return (v + a - 1) & ~(a - 1);
}
static inline uint32_t
align_u32_npot(uint32_t v, uint32_t a)
{
return (v + a - 1) / a * a;
}
static inline uint64_t
align_u64(uint64_t v, uint64_t a)
{
assert(a != 0 && a == (a & -a));
return (v + a - 1) & ~(a - 1);
}
static inline int32_t
align_i32(int32_t v, int32_t a)
{
assert(a != 0 && a == (a & -a));
return (v + a - 1) & ~(a - 1);
}
/** Alignment must be a power of 2. */
static inline bool
tu_is_aligned(uintmax_t n, uintmax_t a)
{
assert(a == (a & -a));
return (n & (a - 1)) == 0;
}
static inline uint32_t
round_up_u32(uint32_t v, uint32_t a)
{
return (v + a - 1) / a;
}
static inline uint64_t
round_up_u64(uint64_t v, uint64_t a)
{
return (v + a - 1) / a;
}
static inline uint32_t
tu_minify(uint32_t n, uint32_t levels)
{
......@@ -191,29 +117,6 @@ tu_minify(uint32_t n, uint32_t levels)
else
return MAX2(n >> levels, 1);
}
static inline float
tu_clamp_f(float f, float min, float max)
{
assert(min < max);
if (f > max)
return max;
else if (f < min)
return min;
else
return f;
}
static inline bool
tu_clear_mask(uint32_t *inout_mask, uint32_t clear_mask)
{
if (*inout_mask & clear_mask) {
*inout_mask &= ~clear_mask;
return true;
} else {
return false;
}
}
#define for_each_bit(b, dword) \
for (uint32_t __dword = (dword); \
......@@ -253,11 +156,7 @@ __tu_finishme(const char *file, int line, const char *format, ...)
void
tu_loge(const char *format, ...) tu_printflike(1, 2);
void
tu_loge_v(const char *format, va_list va);
void
tu_logi(const char *format, ...) tu_printflike(1, 2);
void
tu_logi_v(const char *format, va_list va);
/**
* Print a FINISHME message, including its source location.
......@@ -271,17 +170,6 @@ tu_logi_v(const char *format, va_list va);
} \
} while (0)
/* A non-fatal assert. Useful for debugging. */
#ifdef DEBUG
#define tu_assert(x) \
({ \
if (unlikely(!(x))) \
fprintf(stderr, "%s:%d ASSERT: %s\n", __FILE__, __LINE__, #x); \
})
#else
#define tu_assert(x)
#endif
/* Suppress -Wunused in stub functions */
#define tu_use_args(...) __tu_use_args(0, ##__VA_ARGS__)
static inline void
......@@ -406,39 +294,6 @@ struct tu_pipeline_key
{
};
void
tu_pipeline_cache_init(struct tu_pipeline_cache *cache,
struct tu_device *device);
void
tu_pipeline_cache_finish(struct tu_pipeline_cache *cache);
void
tu_pipeline_cache_load(struct tu_pipeline_cache *cache,
const void *data,
size_t size);
struct tu_shader_variant;
bool
tu_create_shader_variants_from_pipeline_cache(
struct tu_device *device,
struct tu_pipeline_cache *cache,
const unsigned char *sha1,
struct tu_shader_variant **variants);
void
tu_pipeline_cache_insert_shaders(struct tu_device *device,
struct tu_pipeline_cache *cache,
const unsigned char *sha1,
struct tu_shader_variant **variants,
const void *const *codes,
const unsigned *code_sizes);
struct tu_meta_state
{
VkAllocationCallbacks alloc;
struct tu_pipeline_cache cache;
};
/* queue types */
#define TU_QUEUE_GENERAL 0
......@@ -493,8 +348,6 @@ struct tu_device
struct tu_instance *instance;
struct tu_meta_state meta_state;
struct tu_queue *queues[TU_MAX_QUEUE_FAMILIES];
int queue_count[TU_MAX_QUEUE_FAMILIES];
......@@ -523,9 +376,6 @@ struct tu_device
struct tu_bo border_color;
struct list_head shader_slabs;
mtx_t shader_slab_mutex;
struct tu_device_extension_table enabled_extensions;
};
......@@ -1203,11 +1053,6 @@ tu6_emit_event_write(struct tu_cmd_buffer *cmd,
struct tu_cs *cs,
enum vgt_event_type event);
bool
tu_get_memory_fd(struct tu_device *device,
struct tu_device_memory *memory,
int *pFD);
static inline struct tu_descriptor_state *
tu_get_descriptors_state(struct tu_cmd_buffer *cmd_buffer,
VkPipelineBindPoint bind_point)
......@@ -1215,36 +1060,11 @@ tu_get_descriptors_state(struct tu_cmd_buffer *cmd_buffer,
return &cmd_buffer->descriptors[bind_point];
}
/*
* Takes x,y,z as exact numbers of invocations, instead of blocks.
*
* Limitations: Can't call normal dispatch functions without binding or
* rebinding
* the compute pipeline.
*/
void
tu_unaligned_dispatch(struct tu_cmd_buffer *cmd_buffer,
uint32_t x,
uint32_t y,
uint32_t z);
struct tu_event
{
struct tu_bo bo;
};
struct tu_shader_module;
#define TU_HASH_SHADER_IS_GEOM_COPY_SHADER (1 << 0)
#define TU_HASH_SHADER_SISCHED (1 << 1)
#define TU_HASH_SHADER_UNSAFE_MATH (1 << 2)
void
tu_hash_shaders(unsigned char *hash,
const VkPipelineShaderStageCreateInfo **stages,
const struct tu_pipeline_layout *layout,
const struct tu_pipeline_key *key,
uint32_t flags);
static inline gl_shader_stage
vk_to_mesa_shader_stage(VkShaderStageFlagBits vk_stage)
{
......@@ -1504,27 +1324,6 @@ tu_store_gmem_attachment(struct tu_cmd_buffer *cmd,
uint32_t a,
uint32_t gmem_a);
struct tu_userdata_info *
tu_lookup_user_sgpr(struct tu_pipeline *pipeline,
gl_shader_stage stage,
int idx);
struct tu_shader_variant *
tu_get_shader(struct tu_pipeline *pipeline, gl_shader_stage stage);
struct tu_graphics_pipeline_create_info
{
bool use_rectlist;
bool db_depth_clear;
bool db_stencil_clear;
bool db_depth_disable_expclear;
bool db_stencil_disable_expclear;
bool db_flush_depth_inplace;
bool db_flush_stencil_inplace;
bool db_resummarize;
uint32_t custom_blend_mode;
};
enum tu_supported_formats {
FMT_VERTEX = 1,
FMT_TEXTURE = 2,
......@@ -1582,11 +1381,6 @@ struct tu_image
VkDeviceSize bo_offset;
};
unsigned
tu_image_queue_family_mask(const struct tu_image *image,
uint32_t family,
uint32_t queue_family);
static inline uint32_t
tu_get_layerCount(const struct tu_image *image,
const VkImageSubresourceRange *range)
......@@ -1700,38 +1494,6 @@ tu_buffer_view_init(struct tu_buffer_view *view,
struct tu_device *device,
const VkBufferViewCreateInfo *pCreateInfo);
static inline struct VkExtent3D
tu_sanitize_image_extent(const VkImageType imageType,
const struct VkExtent3D imageExtent)
{
switch (imageType) {
case VK_IMAGE_TYPE_1D:
return (VkExtent3D) { imageExtent.width, 1, 1 };
case VK_IMAGE_TYPE_2D:
return (VkExtent3D) { imageExtent.width, imageExtent.height, 1 };
case VK_IMAGE_TYPE_3D:
return imageExtent;
default:
unreachable("invalid image type");
}
}
static inline struct VkOffset3D
tu_sanitize_image_offset(const VkImageType imageType,
const struct VkOffset3D imageOffset)
{
switch (imageType) {
case VK_IMAGE_TYPE_1D:
return (VkOffset3D) { imageOffset.x, 0, 0 };
case VK_IMAGE_TYPE_2D:
return (VkOffset3D) { imageOffset.x, imageOffset.y, 0 };
case VK_IMAGE_TYPE_3D:
return imageOffset;
default:
unreachable("invalid image type");
}
}
struct tu_attachment_info
{
struct tu_image_view *attachment;
......@@ -1801,11 +1563,6 @@ struct tu_render_pass
struct tu_subpass subpasses[0];
};
VkResult
tu_device_init_meta(struct tu_device *device);
void
tu_device_finish_meta(struct tu_device *device);
struct tu_query_pool
{
VkQueryType type;
......@@ -1844,14 +1601,6 @@ tu_update_descriptor_set_with_template(
VkDescriptorUpdateTemplate descriptorUpdateTemplate,
const void *pData);
void
tu_meta_push_descriptor_set(struct tu_cmd_buffer *cmd_buffer,
VkPipelineBindPoint pipelineBindPoint,
VkPipelineLayout _layout,
uint32_t set,
uint32_t descriptorWriteCount,
const VkWriteDescriptorSet *pDescriptorWrites);
int
tu_drm_get_gpu_id(const struct tu_physical_device *dev, uint32_t *id);
......
......@@ -35,6 +35,16 @@
/* TODO: Add Android support to tu_log funcs */
/** \see tu_loge() */
static void
tu_loge_v(const char *format, va_list va)
{
fprintf(stderr, "vk: error: ");
vfprintf(stderr, format, va);
fprintf(stderr, "\n");
}
/** Log an error message. */
void tu_printflike(1, 2) tu_loge(const char *format, ...)
{
......@@ -45,11 +55,11 @@ void tu_printflike(1, 2) tu_loge(const char *format, ...)
va_end(va);
}
/** \see tu_loge() */
void
tu_loge_v(const char *format, va_list va)
/** \see tu_logi() */
static void
tu_logi_v(const char *format, va_list va)
{
fprintf(stderr, "vk: error: ");
fprintf(stderr, "tu: info: ");
vfprintf(stderr, format, va);
fprintf(stderr, "\n");
}
......@@ -64,15 +74,6 @@ void tu_printflike(1, 2) tu_logi(const char *format, ...)
va_end(va);
}
/** \see tu_logi() */
void
tu_logi_v(const char *format, va_list va)
{
fprintf(stderr, "tu: info: ");
vfprintf(stderr, format, va);
fprintf(stderr, "\n");
}
void tu_printflike(3, 4)
__tu_finishme(const char *file, int line, const char *format, ...)
{
......
......@@ -40,15 +40,6 @@ vk_format_description(VkFormat format)
return util_format_description(vk_format_to_pipe_format(format));
}
/**
* Return total bits needed for the pixel format per block.
*/
static inline unsigned
vk_format_get_blocksizebits(VkFormat format)
{
return util_format_get_blocksizebits(vk_format_to_pipe_format(format));
}
/**
* Return bytes per block (not pixel) for the given format.
*/
......@@ -70,100 +61,6 @@ vk_format_get_blockheight(VkFormat format)
return util_format_get_blockheight(vk_format_to_pipe_format(format));
}
static inline unsigned
vk_format_get_block_count_width(VkFormat format, unsigned width)
{
return util_format_get_nblocksx(vk_format_to_pipe_format(format), width);
}
static inline unsigned
vk_format_get_block_count_height(VkFormat format, unsigned height)
{
return util_format_get_nblocksy(vk_format_to_pipe_format(format), height);
}
static inline unsigned
vk_format_get_block_count(VkFormat format, unsigned width, unsigned height)
{
return util_format_get_nblocks(vk_format_to_pipe_format(format),
width, height);
}
static inline VkImageAspectFlags
vk_format_aspects(VkFormat format)
{
switch (format) {
case VK_FORMAT_UNDEFINED:
return 0;
case VK_FORMAT_S8_UINT:
return VK_IMAGE_ASPECT_STENCIL_BIT;
case VK_FORMAT_D16_UNORM_S8_UINT: