intel/isl: Add an isl_swizzle structure and use it for isl_view swizzles
This should be more compact than the enum isl_channel_select[4] that we were using before. It's also very convenient because we already had such a structure in the Vulkan driver we just needed to pull it over. Signed-off-by: Jason Ekstrand <jason@jlekstrand.net> Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
This commit is contained in:
@@ -111,12 +111,7 @@ brw_blorp_surface_info_init(struct blorp_context *blorp,
|
|||||||
.format = format,
|
.format = format,
|
||||||
.base_level = level,
|
.base_level = level,
|
||||||
.levels = 1,
|
.levels = 1,
|
||||||
.channel_select = {
|
.swizzle = ISL_SWIZZLE_IDENTITY,
|
||||||
ISL_CHANNEL_SELECT_RED,
|
|
||||||
ISL_CHANNEL_SELECT_GREEN,
|
|
||||||
ISL_CHANNEL_SELECT_BLUE,
|
|
||||||
ISL_CHANNEL_SELECT_ALPHA,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
info->view.array_len = MAX2(info->surf.logical_level0_px.depth,
|
info->view.array_len = MAX2(info->surf.logical_level0_px.depth,
|
||||||
|
@@ -1637,10 +1637,12 @@ blorp_blit(struct blorp_batch *batch,
|
|||||||
|
|
||||||
brw_blorp_get_blit_kernel(batch->blorp, ¶ms, &wm_prog_key);
|
brw_blorp_get_blit_kernel(batch->blorp, ¶ms, &wm_prog_key);
|
||||||
|
|
||||||
for (unsigned i = 0; i < 4; i++) {
|
params.src.view.swizzle = (struct isl_swizzle) {
|
||||||
params.src.view.channel_select[i] =
|
.r = swizzle_to_scs(GET_SWZ(src_swizzle, 0)),
|
||||||
swizzle_to_scs(GET_SWZ(src_swizzle, i));
|
.g = swizzle_to_scs(GET_SWZ(src_swizzle, 1)),
|
||||||
}
|
.b = swizzle_to_scs(GET_SWZ(src_swizzle, 2)),
|
||||||
|
.a = swizzle_to_scs(GET_SWZ(src_swizzle, 3)),
|
||||||
|
};
|
||||||
|
|
||||||
batch->blorp->exec(batch, ¶ms);
|
batch->blorp->exec(batch, ¶ms);
|
||||||
}
|
}
|
||||||
|
@@ -854,6 +854,22 @@ struct isl_surf {
|
|||||||
isl_surf_usage_flags_t usage;
|
isl_surf_usage_flags_t usage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct isl_swizzle {
|
||||||
|
enum isl_channel_select r:4;
|
||||||
|
enum isl_channel_select g:4;
|
||||||
|
enum isl_channel_select b:4;
|
||||||
|
enum isl_channel_select a:4;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define ISL_SWIZZLE(R, G, B, A) ((struct isl_swizzle) { \
|
||||||
|
.r = ISL_CHANNEL_SELECT_##R, \
|
||||||
|
.g = ISL_CHANNEL_SELECT_##G, \
|
||||||
|
.b = ISL_CHANNEL_SELECT_##B, \
|
||||||
|
.a = ISL_CHANNEL_SELECT_##A, \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define ISL_SWIZZLE_IDENTITY ISL_SWIZZLE(RED, GREEN, BLUE, ALPHA)
|
||||||
|
|
||||||
struct isl_view {
|
struct isl_view {
|
||||||
/**
|
/**
|
||||||
* Indicates the usage of the particular view
|
* Indicates the usage of the particular view
|
||||||
@@ -889,7 +905,7 @@ struct isl_view {
|
|||||||
uint32_t base_array_layer;
|
uint32_t base_array_layer;
|
||||||
uint32_t array_len;
|
uint32_t array_len;
|
||||||
|
|
||||||
enum isl_channel_select channel_select[4];
|
struct isl_swizzle swizzle;
|
||||||
};
|
};
|
||||||
|
|
||||||
union isl_color_value {
|
union isl_color_value {
|
||||||
|
@@ -411,10 +411,10 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (GEN_GEN >= 8 || GEN_IS_HASWELL)
|
#if (GEN_GEN >= 8 || GEN_IS_HASWELL)
|
||||||
s.ShaderChannelSelectRed = info->view->channel_select[0];
|
s.ShaderChannelSelectRed = info->view->swizzle.r;
|
||||||
s.ShaderChannelSelectGreen = info->view->channel_select[1];
|
s.ShaderChannelSelectGreen = info->view->swizzle.g;
|
||||||
s.ShaderChannelSelectBlue = info->view->channel_select[2];
|
s.ShaderChannelSelectBlue = info->view->swizzle.b;
|
||||||
s.ShaderChannelSelectAlpha = info->view->channel_select[3];
|
s.ShaderChannelSelectAlpha = info->view->swizzle.a;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
s.SurfaceBaseAddress = info->address;
|
s.SurfaceBaseAddress = info->address;
|
||||||
|
@@ -24,13 +24,6 @@
|
|||||||
#include "anv_private.h"
|
#include "anv_private.h"
|
||||||
#include "vk_format_info.h"
|
#include "vk_format_info.h"
|
||||||
|
|
||||||
#define ISL_SWIZZLE(r, g, b, a) { \
|
|
||||||
ISL_CHANNEL_SELECT_##r, \
|
|
||||||
ISL_CHANNEL_SELECT_##g, \
|
|
||||||
ISL_CHANNEL_SELECT_##b, \
|
|
||||||
ISL_CHANNEL_SELECT_##a, \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define RGBA ISL_SWIZZLE(RED, GREEN, BLUE, ALPHA)
|
#define RGBA ISL_SWIZZLE(RED, GREEN, BLUE, ALPHA)
|
||||||
#define BGRA ISL_SWIZZLE(BLUE, GREEN, RED, ALPHA)
|
#define BGRA ISL_SWIZZLE(BLUE, GREEN, RED, ALPHA)
|
||||||
#define RGB1 ISL_SWIZZLE(RED, GREEN, BLUE, ONE)
|
#define RGB1 ISL_SWIZZLE(RED, GREEN, BLUE, ONE)
|
||||||
@@ -283,7 +276,7 @@ anv_get_format(const struct gen_device_info *devinfo, VkFormat vk_format,
|
|||||||
format.isl_format = rgbx;
|
format.isl_format = rgbx;
|
||||||
} else {
|
} else {
|
||||||
format.isl_format = isl_format_rgb_to_rgba(format.isl_format);
|
format.isl_format = isl_format_rgb_to_rgba(format.isl_format);
|
||||||
format.swizzle = (struct anv_format_swizzle) RGB1;
|
format.swizzle = RGB1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -345,7 +345,7 @@ alloc_surface_state(struct anv_device *device,
|
|||||||
|
|
||||||
static enum isl_channel_select
|
static enum isl_channel_select
|
||||||
remap_swizzle(VkComponentSwizzle swizzle, VkComponentSwizzle component,
|
remap_swizzle(VkComponentSwizzle swizzle, VkComponentSwizzle component,
|
||||||
struct anv_format_swizzle format_swizzle)
|
struct isl_swizzle format_swizzle)
|
||||||
{
|
{
|
||||||
if (swizzle == VK_COMPONENT_SWIZZLE_IDENTITY)
|
if (swizzle == VK_COMPONENT_SWIZZLE_IDENTITY)
|
||||||
swizzle = component;
|
swizzle = component;
|
||||||
@@ -414,15 +414,15 @@ anv_image_view_init(struct anv_image_view *iview,
|
|||||||
.levels = anv_get_levelCount(image, range),
|
.levels = anv_get_levelCount(image, range),
|
||||||
.base_array_layer = range->baseArrayLayer,
|
.base_array_layer = range->baseArrayLayer,
|
||||||
.array_len = anv_get_layerCount(image, range),
|
.array_len = anv_get_layerCount(image, range),
|
||||||
.channel_select = {
|
.swizzle = {
|
||||||
remap_swizzle(pCreateInfo->components.r,
|
.r = remap_swizzle(pCreateInfo->components.r,
|
||||||
VK_COMPONENT_SWIZZLE_R, format.swizzle),
|
VK_COMPONENT_SWIZZLE_R, format.swizzle),
|
||||||
remap_swizzle(pCreateInfo->components.g,
|
.g = remap_swizzle(pCreateInfo->components.g,
|
||||||
VK_COMPONENT_SWIZZLE_G, format.swizzle),
|
VK_COMPONENT_SWIZZLE_G, format.swizzle),
|
||||||
remap_swizzle(pCreateInfo->components.b,
|
.b = remap_swizzle(pCreateInfo->components.b,
|
||||||
VK_COMPONENT_SWIZZLE_B, format.swizzle),
|
VK_COMPONENT_SWIZZLE_B, format.swizzle),
|
||||||
remap_swizzle(pCreateInfo->components.a,
|
.a = remap_swizzle(pCreateInfo->components.a,
|
||||||
VK_COMPONENT_SWIZZLE_A, format.swizzle),
|
VK_COMPONENT_SWIZZLE_A, format.swizzle),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1621,16 +1621,9 @@ anv_graphics_pipeline_create(VkDevice device,
|
|||||||
const VkAllocationCallbacks *alloc,
|
const VkAllocationCallbacks *alloc,
|
||||||
VkPipeline *pPipeline);
|
VkPipeline *pPipeline);
|
||||||
|
|
||||||
struct anv_format_swizzle {
|
|
||||||
enum isl_channel_select r:4;
|
|
||||||
enum isl_channel_select g:4;
|
|
||||||
enum isl_channel_select b:4;
|
|
||||||
enum isl_channel_select a:4;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct anv_format {
|
struct anv_format {
|
||||||
enum isl_format isl_format:16;
|
enum isl_format isl_format:16;
|
||||||
struct anv_format_swizzle swizzle;
|
struct isl_swizzle swizzle;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct anv_format
|
struct anv_format
|
||||||
|
@@ -217,12 +217,7 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
|
|||||||
.levels = 1,
|
.levels = 1,
|
||||||
.base_array_layer = irb->mt_layer / layer_multiplier,
|
.base_array_layer = irb->mt_layer / layer_multiplier,
|
||||||
.array_len = MAX2(irb->layer_count, 1),
|
.array_len = MAX2(irb->layer_count, 1),
|
||||||
.channel_select = {
|
.swizzle = ISL_SWIZZLE_IDENTITY,
|
||||||
ISL_CHANNEL_SELECT_RED,
|
|
||||||
ISL_CHANNEL_SELECT_GREEN,
|
|
||||||
ISL_CHANNEL_SELECT_BLUE,
|
|
||||||
ISL_CHANNEL_SELECT_ALPHA,
|
|
||||||
},
|
|
||||||
.usage = ISL_SURF_USAGE_RENDER_TARGET_BIT,
|
.usage = ISL_SURF_USAGE_RENDER_TARGET_BIT,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -611,11 +606,11 @@ brw_update_texture_surface(struct gl_context *ctx,
|
|||||||
.levels = intel_obj->_MaxLevel - obj->BaseLevel + 1,
|
.levels = intel_obj->_MaxLevel - obj->BaseLevel + 1,
|
||||||
.base_array_layer = obj->MinLayer,
|
.base_array_layer = obj->MinLayer,
|
||||||
.array_len = view_num_layers,
|
.array_len = view_num_layers,
|
||||||
.channel_select = {
|
.swizzle = {
|
||||||
swizzle_to_scs(GET_SWZ(swizzle, 0), need_green_to_blue),
|
.r = swizzle_to_scs(GET_SWZ(swizzle, 0), need_green_to_blue),
|
||||||
swizzle_to_scs(GET_SWZ(swizzle, 1), need_green_to_blue),
|
.g = swizzle_to_scs(GET_SWZ(swizzle, 1), need_green_to_blue),
|
||||||
swizzle_to_scs(GET_SWZ(swizzle, 2), need_green_to_blue),
|
.b = swizzle_to_scs(GET_SWZ(swizzle, 2), need_green_to_blue),
|
||||||
swizzle_to_scs(GET_SWZ(swizzle, 3), need_green_to_blue),
|
.a = swizzle_to_scs(GET_SWZ(swizzle, 3), need_green_to_blue),
|
||||||
},
|
},
|
||||||
.usage = ISL_SURF_USAGE_TEXTURE_BIT,
|
.usage = ISL_SURF_USAGE_TEXTURE_BIT,
|
||||||
};
|
};
|
||||||
@@ -1189,12 +1184,7 @@ update_renderbuffer_read_surfaces(struct brw_context *brw)
|
|||||||
.levels = 1,
|
.levels = 1,
|
||||||
.base_array_layer = irb->mt_layer / mt_layer_unit,
|
.base_array_layer = irb->mt_layer / mt_layer_unit,
|
||||||
.array_len = irb->layer_count,
|
.array_len = irb->layer_count,
|
||||||
.channel_select = {
|
.swizzle = ISL_SWIZZLE_IDENTITY,
|
||||||
ISL_CHANNEL_SELECT_RED,
|
|
||||||
ISL_CHANNEL_SELECT_GREEN,
|
|
||||||
ISL_CHANNEL_SELECT_BLUE,
|
|
||||||
ISL_CHANNEL_SELECT_ALPHA,
|
|
||||||
},
|
|
||||||
.usage = ISL_SURF_USAGE_TEXTURE_BIT,
|
.usage = ISL_SURF_USAGE_TEXTURE_BIT,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1748,12 +1738,7 @@ update_image_surface(struct brw_context *brw,
|
|||||||
.levels = 1,
|
.levels = 1,
|
||||||
.base_array_layer = obj->MinLayer + u->_Layer,
|
.base_array_layer = obj->MinLayer + u->_Layer,
|
||||||
.array_len = num_layers,
|
.array_len = num_layers,
|
||||||
.channel_select = {
|
.swizzle = ISL_SWIZZLE_IDENTITY,
|
||||||
ISL_CHANNEL_SELECT_RED,
|
|
||||||
ISL_CHANNEL_SELECT_GREEN,
|
|
||||||
ISL_CHANNEL_SELECT_BLUE,
|
|
||||||
ISL_CHANNEL_SELECT_ALPHA,
|
|
||||||
},
|
|
||||||
.usage = ISL_SURF_USAGE_STORAGE_BIT,
|
.usage = ISL_SURF_USAGE_STORAGE_BIT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user