aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/freedreno/vulkan/tu_clear_blit.c14
-rw-r--r--src/freedreno/vulkan/tu_descriptor_set.c4
-rw-r--r--src/freedreno/vulkan/tu_image.c26
-rw-r--r--src/freedreno/vulkan/tu_pipeline.c24
-rw-r--r--src/freedreno/vulkan/tu_pipeline_cache.c41
-rw-r--r--src/freedreno/vulkan/tu_private.h251
-rw-r--r--src/freedreno/vulkan/tu_util.c27
-rw-r--r--src/freedreno/vulkan/vk_format.h188
8 files changed, 35 insertions, 540 deletions
diff --git a/src/freedreno/vulkan/tu_clear_blit.c b/src/freedreno/vulkan/tu_clear_blit.c
index 5635375cc23..e4c573142b1 100644
--- a/src/freedreno/vulkan/tu_clear_blit.c
+++ b/src/freedreno/vulkan/tu_clear_blit.c
@@ -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");
}
diff --git a/src/freedreno/vulkan/tu_descriptor_set.c b/src/freedreno/vulkan/tu_descriptor_set.c
index ab597633c3d..c0d349c12c7 100644
--- a/src/freedreno/vulkan/tu_descriptor_set.c
+++ b/src/freedreno/vulkan/tu_descriptor_set.c
@@ -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)
diff --git a/src/freedreno/vulkan/tu_image.c b/src/freedreno/vulkan/tu_image.c
index 76c12703e1c..420842f4544 100644
--- a/src/freedreno/vulkan/tu_image.c
+++ b/src/freedreno/vulkan/tu_image.c
@@ -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,
diff --git a/src/freedreno/vulkan/tu_pipeline.c b/src/freedreno/vulkan/tu_pipeline.c
index 4b062b8bfa6..682eac7ff88 100644
--- a/src/freedreno/vulkan/tu_pipeline.c
+++ b/src/freedreno/vulkan/tu_pipeline.c
@@ -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];
}
diff --git a/src/freedreno/vulkan/tu_pipeline_cache.c b/src/freedreno/vulkan/tu_pipeline_cache.c
index b8b2ceda263..47a8b97283f 100644
--- a/src/freedreno/vulkan/tu_pipeline_cache.c
+++ b/src/freedreno/vulkan/tu_pipeline_cache.c
@@ -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)
diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h
index 65aa6a5660e..e3226f7cf99 100644
--- a/src/freedreno/vulkan/tu_private.h
+++ b/src/freedreno/vulkan/tu_private.h
@@ -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,84 +104,12 @@ 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)
{
if (unlikely(n == 0))
@@ -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);
diff --git a/src/freedreno/vulkan/tu_util.c b/src/freedreno/vulkan/tu_util.c
index e630460fb33..9a0e5cce4c9 100644
--- a/src/freedreno/vulkan/tu_util.c
+++ b/src/freedreno/vulkan/tu_util.c
@@ -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, ...)
{
diff --git a/src/freedreno/vulkan/vk_format.h b/src/freedreno/vulkan/vk_format.h
index 516ba7a2ec4..5755ed0de52 100644
--- a/src/freedreno/vulkan/vk_format.h
+++ b/src/freedreno/vulkan/vk_format.h
@@ -41,15 +41,6 @@ vk_format_description(VkFormat 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.
*/
static inline unsigned
@@ -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:
- case VK_FORMAT_D24_UNORM_S8_UINT:
- case VK_FORMAT_D32_SFLOAT_S8_UINT:
- return VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
-
- case VK_FORMAT_D16_UNORM:
- case VK_FORMAT_X8_D24_UNORM_PACK32:
- case VK_FORMAT_D32_SFLOAT:
- return VK_IMAGE_ASPECT_DEPTH_BIT;
-
- default:
- return VK_IMAGE_ASPECT_COLOR_BIT;
- }
-}
-
-static inline enum pipe_swizzle
-tu_swizzle_conv(VkComponentSwizzle component,
- const unsigned char chan[4],
- VkComponentSwizzle vk_swiz)
-{
- int x;
-
- if (vk_swiz == VK_COMPONENT_SWIZZLE_IDENTITY)
- vk_swiz = component;
- switch (vk_swiz) {
- case VK_COMPONENT_SWIZZLE_ZERO:
- return PIPE_SWIZZLE_0;
- case VK_COMPONENT_SWIZZLE_ONE:
- return PIPE_SWIZZLE_1;
- case VK_COMPONENT_SWIZZLE_R:
- for (x = 0; x < 4; x++)
- if (chan[x] == 0)
- return x;
- return PIPE_SWIZZLE_0;
- case VK_COMPONENT_SWIZZLE_G:
- for (x = 0; x < 4; x++)
- if (chan[x] == 1)
- return x;
- return PIPE_SWIZZLE_0;
- case VK_COMPONENT_SWIZZLE_B:
- for (x = 0; x < 4; x++)
- if (chan[x] == 2)
- return x;
- return PIPE_SWIZZLE_0;
- case VK_COMPONENT_SWIZZLE_A:
- for (x = 0; x < 4; x++)
- if (chan[x] == 3)
- return x;
- return PIPE_SWIZZLE_1;
- default:
- unreachable("Illegal swizzle");
- }
-}
-
-static inline void
-vk_format_compose_swizzles(const VkComponentMapping *mapping,
- const unsigned char swz[4],
- enum pipe_swizzle dst[4])
-{
- dst[0] = tu_swizzle_conv(VK_COMPONENT_SWIZZLE_R, swz, mapping->r);
- dst[1] = tu_swizzle_conv(VK_COMPONENT_SWIZZLE_G, swz, mapping->g);
- dst[2] = tu_swizzle_conv(VK_COMPONENT_SWIZZLE_B, swz, mapping->b);
- dst[3] = tu_swizzle_conv(VK_COMPONENT_SWIZZLE_A, swz, mapping->a);
-}
-
static inline bool
vk_format_is_compressed(VkFormat format)
{
@@ -172,31 +69,11 @@ vk_format_is_compressed(VkFormat format)
}
static inline bool
-vk_format_has_depth(VkFormat format)
-{
- const struct util_format_description *desc = vk_format_description(format);
-
- return util_format_has_depth(desc);
-}
-
-static inline bool
-vk_format_has_stencil(VkFormat format)
-{
- const struct util_format_description *desc = vk_format_description(format);
-
- return util_format_has_stencil(desc);
-}
-
-static inline bool
vk_format_is_depth_or_stencil(VkFormat format)
{
- return vk_format_has_depth(format) || vk_format_has_stencil(format);
-}
+ const struct util_format_description *desc = vk_format_description(format);
-static inline bool
-vk_format_is_color(VkFormat format)
-{
- return !vk_format_is_depth_or_stencil(format);
+ return util_format_has_depth(desc) || util_format_has_stencil(desc);
}
static inline bool
@@ -205,21 +82,6 @@ vk_format_has_alpha(VkFormat format)
return util_format_has_alpha(vk_format_to_pipe_format(format));
}
-static inline VkFormat
-vk_format_depth_only(VkFormat format)
-{
- switch (format) {
- case VK_FORMAT_D16_UNORM_S8_UINT:
- return VK_FORMAT_D16_UNORM;
- case VK_FORMAT_D24_UNORM_S8_UINT:
- return VK_FORMAT_X8_D24_UNORM_PACK32;
- case VK_FORMAT_D32_SFLOAT_S8_UINT:
- return VK_FORMAT_D32_SFLOAT;
- default:
- return format;
- }
-}
-
static inline bool
vk_format_is_int(VkFormat format)
{
@@ -262,52 +124,6 @@ vk_format_is_float(VkFormat format)
return util_format_is_float(vk_format_to_pipe_format(format));
}
-static inline VkFormat
-vk_format_no_srgb(VkFormat format)
-{
- switch (format) {
- case VK_FORMAT_R8_SRGB:
- return VK_FORMAT_R8_UNORM;
- case VK_FORMAT_R8G8_SRGB:
- return VK_FORMAT_R8G8_UNORM;
- case VK_FORMAT_R8G8B8_SRGB:
- return VK_FORMAT_R8G8B8_UNORM;
- case VK_FORMAT_B8G8R8_SRGB:
- return VK_FORMAT_B8G8R8_UNORM;
- case VK_FORMAT_R8G8B8A8_SRGB:
- return VK_FORMAT_R8G8B8A8_UNORM;
- case VK_FORMAT_B8G8R8A8_SRGB:
- return VK_FORMAT_B8G8R8A8_UNORM;
- case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
- return VK_FORMAT_A8B8G8R8_UNORM_PACK32;
- case VK_FORMAT_BC1_RGB_SRGB_BLOCK:
- return VK_FORMAT_BC1_RGB_UNORM_BLOCK;
- case VK_FORMAT_BC1_RGBA_SRGB_BLOCK:
- return VK_FORMAT_BC1_RGBA_UNORM_BLOCK;
- case VK_FORMAT_BC2_SRGB_BLOCK:
- return VK_FORMAT_BC2_UNORM_BLOCK;
- case VK_FORMAT_BC3_SRGB_BLOCK:
- return VK_FORMAT_BC3_UNORM_BLOCK;
- case VK_FORMAT_BC7_SRGB_BLOCK:
- return VK_FORMAT_BC7_UNORM_BLOCK;
- case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK:
- return VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK;
- case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK:
- return VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK;
- case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK:
- return VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK;
- default:
- assert(!vk_format_is_srgb(format));
- return format;
- }
-}
-
-static inline VkFormat
-vk_format_stencil_only(VkFormat format)
-{
- return VK_FORMAT_S8_UINT;
-}
-
static inline unsigned
vk_format_get_component_bits(VkFormat format,
enum util_format_colorspace colorspace,