panvk: Move shader related definitions to panvk_[vX_]shader.{c,h}
Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com> Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com> Reviewed-by: Rebecca Mckeever <rebecca.mckeever@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28170>
This commit is contained in:
committed by
Marge Bot
parent
80947ae1d2
commit
18174d8665
@@ -73,6 +73,7 @@
|
||||
#include "panvk_mempool.h"
|
||||
#include "panvk_pipeline.h"
|
||||
#include "panvk_pipeline_layout.h"
|
||||
#include "panvk_shader.h"
|
||||
#include "panvk_varyings.h"
|
||||
#include "vk_extensions.h"
|
||||
|
||||
@@ -104,10 +105,6 @@ typedef uint32_t xcb_window_t;
|
||||
|
||||
#define NUM_DEPTH_CLEAR_PIPELINES 3
|
||||
|
||||
#define PANVK_SYSVAL_UBO_INDEX 0
|
||||
#define PANVK_PUSH_CONST_UBO_INDEX 1
|
||||
#define PANVK_NUM_BUILTIN_UBOS 2
|
||||
|
||||
struct panvk_device;
|
||||
struct panvk_pipeline_layout;
|
||||
|
||||
@@ -352,36 +349,6 @@ enum panvk_dynamic_state_bits {
|
||||
PANVK_DYNAMIC_ALL = (1 << 12) - 1,
|
||||
};
|
||||
|
||||
union panvk_sysval_vec4 {
|
||||
float f32[4];
|
||||
uint32_t u32[4];
|
||||
};
|
||||
|
||||
struct panvk_sysvals {
|
||||
union {
|
||||
struct {
|
||||
/* Only for graphics */
|
||||
union panvk_sysval_vec4 viewport_scale;
|
||||
union panvk_sysval_vec4 viewport_offset;
|
||||
union panvk_sysval_vec4 blend_constants;
|
||||
|
||||
uint32_t first_vertex;
|
||||
uint32_t base_vertex;
|
||||
uint32_t base_instance;
|
||||
};
|
||||
|
||||
struct {
|
||||
/* Only for compute */
|
||||
union panvk_sysval_vec4 num_work_groups;
|
||||
union panvk_sysval_vec4 local_group_size;
|
||||
};
|
||||
};
|
||||
|
||||
/* The back-end compiler doesn't know about any sysvals after this point */
|
||||
|
||||
struct panvk_ssbo_addr dyn_ssbos[MAX_DYNAMIC_STORAGE_BUFFERS];
|
||||
};
|
||||
|
||||
struct panvk_descriptor_state {
|
||||
uint32_t dirty;
|
||||
const struct panvk_descriptor_set *sets[MAX_SETS];
|
||||
@@ -553,25 +520,6 @@ struct panvk_batch *panvk_cmd_open_batch(struct panvk_cmd_buffer *cmdbuf);
|
||||
|
||||
void panvk_cmd_preload_fb_after_batch_split(struct panvk_cmd_buffer *cmdbuf);
|
||||
|
||||
struct panvk_shader {
|
||||
struct pan_shader_info info;
|
||||
struct util_dynarray binary;
|
||||
unsigned sysval_ubo;
|
||||
struct pan_compute_dim local_size;
|
||||
bool has_img_access;
|
||||
};
|
||||
|
||||
struct panvk_shader *
|
||||
panvk_shader_create(struct panvk_device *dev, gl_shader_stage stage,
|
||||
const VkPipelineShaderStageCreateInfo *stage_info,
|
||||
const struct panvk_pipeline_layout *layout,
|
||||
unsigned sysval_ubo, struct pan_blend_state *blend_state,
|
||||
bool static_blend_constants,
|
||||
const VkAllocationCallbacks *alloc);
|
||||
|
||||
void panvk_shader_destroy(struct panvk_device *dev, struct panvk_shader *shader,
|
||||
const VkAllocationCallbacks *alloc);
|
||||
|
||||
VK_DEFINE_HANDLE_CASTS(panvk_cmd_buffer, vk.base, VkCommandBuffer,
|
||||
VK_OBJECT_TYPE_COMMAND_BUFFER)
|
||||
VK_DEFINE_HANDLE_CASTS(panvk_device, vk.base, VkDevice, VK_OBJECT_TYPE_DEVICE)
|
||||
@@ -608,22 +556,4 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(panvk_cmd_pool, vk.base, VkCommandPool,
|
||||
#undef panvk_per_arch
|
||||
#endif
|
||||
|
||||
#ifdef PAN_ARCH
|
||||
bool panvk_per_arch(blend_needs_lowering)(const struct panvk_device *dev,
|
||||
const struct pan_blend_state *state,
|
||||
unsigned rt);
|
||||
|
||||
struct panvk_shader *panvk_per_arch(shader_create)(
|
||||
struct panvk_device *dev, gl_shader_stage stage,
|
||||
const VkPipelineShaderStageCreateInfo *stage_info,
|
||||
const struct panvk_pipeline_layout *layout, unsigned sysval_ubo,
|
||||
struct pan_blend_state *blend_state, bool static_blend_constants,
|
||||
const VkAllocationCallbacks *alloc);
|
||||
struct nir_shader;
|
||||
|
||||
bool panvk_per_arch(nir_lower_descriptors)(
|
||||
struct nir_shader *nir, struct panvk_device *dev,
|
||||
const struct panvk_pipeline_layout *layout, bool *has_img_access_out);
|
||||
#endif
|
||||
|
||||
#endif /* PANVK_PRIVATE_H */
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "panvk_shader.h"
|
||||
#include "panvk_private.h"
|
||||
|
||||
#include "pan_shader.h"
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright © 2021 Collabora Ltd.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef PANVK_SHADER_H
|
||||
#define PANVK_SHADER_H
|
||||
|
||||
#include "util/u_dynarray.h"
|
||||
|
||||
#include "util/pan_ir.h"
|
||||
|
||||
#include "pan_desc.h"
|
||||
|
||||
#include "panvk_descriptor_set.h"
|
||||
#include "panvk_macros.h"
|
||||
#include "panvk_pipeline_layout.h"
|
||||
|
||||
#define PANVK_SYSVAL_UBO_INDEX 0
|
||||
#define PANVK_PUSH_CONST_UBO_INDEX 1
|
||||
#define PANVK_NUM_BUILTIN_UBOS 2
|
||||
|
||||
struct nir_shader;
|
||||
struct pan_blend_state;
|
||||
struct panvk_device;
|
||||
|
||||
union panvk_sysval_vec4 {
|
||||
float f32[4];
|
||||
uint32_t u32[4];
|
||||
};
|
||||
|
||||
struct panvk_sysvals {
|
||||
union {
|
||||
struct {
|
||||
/* Only for graphics */
|
||||
union panvk_sysval_vec4 viewport_scale;
|
||||
union panvk_sysval_vec4 viewport_offset;
|
||||
union panvk_sysval_vec4 blend_constants;
|
||||
|
||||
uint32_t first_vertex;
|
||||
uint32_t base_vertex;
|
||||
uint32_t base_instance;
|
||||
};
|
||||
|
||||
struct {
|
||||
/* Only for compute */
|
||||
union panvk_sysval_vec4 num_work_groups;
|
||||
union panvk_sysval_vec4 local_group_size;
|
||||
};
|
||||
};
|
||||
|
||||
/* The back-end compiler doesn't know about any sysvals after this point */
|
||||
|
||||
struct panvk_ssbo_addr dyn_ssbos[MAX_DYNAMIC_STORAGE_BUFFERS];
|
||||
};
|
||||
|
||||
struct panvk_shader {
|
||||
struct pan_shader_info info;
|
||||
struct util_dynarray binary;
|
||||
unsigned sysval_ubo;
|
||||
struct pan_compute_dim local_size;
|
||||
bool has_img_access;
|
||||
};
|
||||
|
||||
struct panvk_shader *
|
||||
panvk_shader_create(struct panvk_device *dev, gl_shader_stage stage,
|
||||
const VkPipelineShaderStageCreateInfo *stage_info,
|
||||
const struct panvk_pipeline_layout *layout,
|
||||
unsigned sysval_ubo, struct pan_blend_state *blend_state,
|
||||
bool static_blend_constants,
|
||||
const VkAllocationCallbacks *alloc);
|
||||
|
||||
void panvk_shader_destroy(struct panvk_device *dev, struct panvk_shader *shader,
|
||||
const VkAllocationCallbacks *alloc);
|
||||
|
||||
#ifdef PAN_ARCH
|
||||
bool panvk_per_arch(blend_needs_lowering)(const struct panvk_device *dev,
|
||||
const struct pan_blend_state *state,
|
||||
unsigned rt);
|
||||
|
||||
struct panvk_shader *panvk_per_arch(shader_create)(
|
||||
struct panvk_device *dev, gl_shader_stage stage,
|
||||
const VkPipelineShaderStageCreateInfo *stage_info,
|
||||
const struct panvk_pipeline_layout *layout, unsigned sysval_ubo,
|
||||
struct pan_blend_state *blend_state, bool static_blend_constants,
|
||||
const VkAllocationCallbacks *alloc);
|
||||
|
||||
bool panvk_per_arch(nir_lower_descriptors)(
|
||||
struct nir_shader *nir, struct panvk_device *dev,
|
||||
const struct panvk_pipeline_layout *layout, bool *has_img_access_out);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "panvk_pipeline_layout.h"
|
||||
#include "panvk_private.h"
|
||||
#include "panvk_shader.h"
|
||||
|
||||
#include "nir.h"
|
||||
#include "nir_builder.h"
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "panvk_pipeline.h"
|
||||
#include "panvk_pipeline_layout.h"
|
||||
#include "panvk_private.h"
|
||||
#include "panvk_shader.h"
|
||||
|
||||
#include "nir/nir.h"
|
||||
#include "nir/nir_builder.h"
|
||||
@@ -392,38 +393,6 @@ panvk_pipeline_builder_parse_input_assembly(
|
||||
builder->create_info.gfx->pInputAssemblyState->topology);
|
||||
}
|
||||
|
||||
bool
|
||||
panvk_per_arch(blend_needs_lowering)(const struct panvk_device *dev,
|
||||
const struct pan_blend_state *state,
|
||||
unsigned rt)
|
||||
{
|
||||
/* LogicOp requires a blend shader */
|
||||
if (state->logicop_enable)
|
||||
return true;
|
||||
|
||||
/* Not all formats can be blended by fixed-function hardware */
|
||||
if (!panfrost_blendable_formats_v7[state->rts[rt].format].internal)
|
||||
return true;
|
||||
|
||||
unsigned constant_mask = pan_blend_constant_mask(state->rts[rt].equation);
|
||||
|
||||
/* v6 doesn't support blend constants in FF blend equations.
|
||||
* v7 only uses the constant from RT 0 (TODO: what if it's the same
|
||||
* constant? or a constant is shared?)
|
||||
*/
|
||||
if (constant_mask && (PAN_ARCH == 6 || (PAN_ARCH == 7 && rt > 0)))
|
||||
return true;
|
||||
|
||||
if (!pan_blend_is_homogenous_constant(constant_mask, state->constants))
|
||||
return true;
|
||||
|
||||
struct panvk_physical_device *phys_dev =
|
||||
to_panvk_physical_device(dev->vk.physical);
|
||||
unsigned arch = pan_arch(phys_dev->kmod.props.gpu_prod_id);
|
||||
bool supports_2src = pan_blend_supports_2src(arch);
|
||||
return !pan_blend_can_fixed_function(state->rts[rt].equation, supports_2src);
|
||||
}
|
||||
|
||||
static void
|
||||
panvk_pipeline_builder_parse_color_blend(struct panvk_pipeline_builder *builder,
|
||||
struct panvk_pipeline *pipeline)
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "panvk_pipeline_layout.h"
|
||||
#include "panvk_private.h"
|
||||
#include "panvk_sampler.h"
|
||||
#include "panvk_shader.h"
|
||||
|
||||
#include "util/mesa-sha1.h"
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include "panvk_pipeline_layout.h"
|
||||
#include "panvk_private.h"
|
||||
#include "panvk_shader.h"
|
||||
|
||||
#include "spirv/nir_spirv.h"
|
||||
#include "util/mesa-sha1.h"
|
||||
@@ -394,3 +395,35 @@ panvk_per_arch(shader_create)(struct panvk_device *dev, gl_shader_stage stage,
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
||||
bool
|
||||
panvk_per_arch(blend_needs_lowering)(const struct panvk_device *dev,
|
||||
const struct pan_blend_state *state,
|
||||
unsigned rt)
|
||||
{
|
||||
/* LogicOp requires a blend shader */
|
||||
if (state->logicop_enable)
|
||||
return true;
|
||||
|
||||
/* Not all formats can be blended by fixed-function hardware */
|
||||
if (!panfrost_blendable_formats_v7[state->rts[rt].format].internal)
|
||||
return true;
|
||||
|
||||
unsigned constant_mask = pan_blend_constant_mask(state->rts[rt].equation);
|
||||
|
||||
/* v6 doesn't support blend constants in FF blend equations.
|
||||
* v7 only uses the constant from RT 0 (TODO: what if it's the same
|
||||
* constant? or a constant is shared?)
|
||||
*/
|
||||
if (constant_mask && (PAN_ARCH == 6 || (PAN_ARCH == 7 && rt > 0)))
|
||||
return true;
|
||||
|
||||
if (!pan_blend_is_homogenous_constant(constant_mask, state->constants))
|
||||
return true;
|
||||
|
||||
struct panvk_physical_device *phys_dev =
|
||||
to_panvk_physical_device(dev->vk.physical);
|
||||
unsigned arch = pan_arch(phys_dev->kmod.props.gpu_prod_id);
|
||||
bool supports_2src = pan_blend_supports_2src(arch);
|
||||
return !pan_blend_can_fixed_function(state->rts[rt].equation, supports_2src);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user