drm/vc4: Add threading support
Subsystems (3)
PATCH 1/1 drm/vc4: Add threading support
From: Jonas Pfeil <[email protected]>
Add support for threaded fragment shaders. The validation code checks for thread switch signals and ensures that the registers of the other thread are not touched, and that our clamps are not live across thread switches. It also checks that the threading and branching instructions do not interfere.
(Original patch by Jonas, changes by anholt for style cleanup, removing validation the kernel doesn't need to do, and adding the flag for userspace).
Signed-off-by Jonas Pfeil <[email protected]>
Signed-off-by Eric Anholt <[email protected]>
--- drivers/gpu/drm/vc4/vc4_drv.c | 1 + drivers/gpu/drm/vc4/vc4_drv.h | 2 + drivers/gpu/drm/vc4/vc4_validate.c | 17 +++++--- drivers/gpu/drm/vc4/vc4_validate_shaders.c | 62 ++++++++++++++++++++++++++++++ include/uapi/drm/vc4_drm.h | 1 + 5 files changed, 78 insertions(+), 5 deletions(-) mode change 100644 => 100755 drivers/gpu/drm/vc4/vc4_validate.c mode change 100644 => 100755 drivers/gpu/drm/vc4/vc4_validate_shaders.c
drivers/gpu/drm/vc4/vc4_drv.c +1 -0
@@ -82,6 +82,7 @@ static int vc4_get_param_ioctl(struct drm_device *dev, void *data,break ;case DRM_VC4_PARAM_SUPPORTS_BRANCHES :case DRM_VC4_PARAM_SUPPORTS_ETC1 : +case DRM_VC4_PARAM_SUPPORTS_THREADED_FS : args->value = true;break ;default :
drivers/gpu/drm/vc4/vc4_drv.h +2 -0
@@ -381,6 +381,8 @@ struct vc4_validated_shader_info {uint32_t num_uniform_addr_offsets;uint32_t *uniform_addr_offsets; + +bool is_threaded; };/**
drivers/gpu/drm/vc4/vc4_validate.c +12 -5
@@ -789,11 +789,6 @@ validate_gl_shader_rec(struct drm_device *dev, exec->shader_rec_v +=roundup (packet_size,16 ); exec->shader_rec_size -= packet_size; -if (!(*(uint16_t *)pkt_u &VC4_SHADER_FLAG_FS_SINGLE_THREAD )) { -DRM_ERROR ("Multi-threaded fragment shaders not supported.\n" ); -return -EINVAL ; - } -for (i =0 ; i < shader_reloc_count; i++) {if (src_handles[i] > exec->bo_count) {DRM_ERROR ("Shader handle %d too big\n" , src_handles[i]);
@@ -810,6 +805,18 @@ validate_gl_shader_rec(struct drm_device *dev,return -EINVAL ; } +if (((*(uint16_t *)pkt_u &VC4_SHADER_FLAG_FS_SINGLE_THREAD ) ==0 ) != +to_vc4_bo (&bo[0 ]->base)->validated_shader->is_threaded) { +DRM_ERROR ("Thread mode of CL and FS do not match\n" ); +return -EINVAL ; + } + +if (to_vc4_bo (&bo[1 ]->base)->validated_shader->is_threaded || +to_vc4_bo (&bo[2 ]->base)->validated_shader->is_threaded) { +DRM_ERROR ("cs and vs cannot be threaded\n" ); +return -EINVAL ; + } +for (i =0 ; i < shader_reloc_count; i++) {struct vc4_validated_shader_info *validated_shader;uint32_t o = shader_reloc_offsets[i];
drivers/gpu/drm/vc4/vc4_validate_shaders.c +62 -0
122 lines not on this page · raw message
include/uapi/drm/vc4_drm.h +1 -0
@@ -287,6 +287,7 @@ struct drm_vc4_get_hang_state {#define DRM_VC4_PARAM_V3D_IDENT2 2#define DRM_VC4_PARAM_SUPPORTS_BRANCHES 3#define DRM_VC4_PARAM_SUPPORTS_ETC1 4 +#define DRM_VC4_PARAM_SUPPORTS_THREADED_FS 5struct drm_vc4_get_param {__u32 param;
Signature · 1 line
2.10.2