add texture barrier implementation

This adds the texture barrier support for the texture barriers,
a separate patch would be needed to implement the framebuffer fetch
barriers.

Reviewed-by: Jakob Bornecrantz <jakob@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
macos/master
Dave Airlie 6 years ago committed by Jakob Bornecrantz
parent a2639989a0
commit aaed5a6c10
  1. 6
      src/gallium/include/pipe/p_defines.h
  2. 1
      src/virgl_hw.h
  3. 5
      src/virgl_protocol.h
  4. 13
      src/vrend_decode.c
  5. 15
      src/vrend_renderer.c
  6. 2
      src/vrend_renderer.h

@ -342,6 +342,12 @@ enum pipe_flush_flags {
#define PIPE_BARRIER_GLOBAL_BUFFER (1 << 11) #define PIPE_BARRIER_GLOBAL_BUFFER (1 << 11)
#define PIPE_BARRIER_ALL ((1 << 12) - 1) #define PIPE_BARRIER_ALL ((1 << 12) - 1)
/**
* Flags for pipe_context::texture_barrier.
*/
#define PIPE_TEXTURE_BARRIER_SAMPLER (1 << 0)
#define PIPE_TEXTURE_BARRIER_FRAMEBUFFER (1 << 1)
/* /*
* Resource binding flags -- state tracker must specify in advance all * Resource binding flags -- state tracker must specify in advance all
* the ways a resource might be used. * the ways a resource might be used.

@ -229,6 +229,7 @@ enum virgl_formats {
#define VIRGL_CAP_ROBUST_BUFFER_ACCESS (1 << 9) #define VIRGL_CAP_ROBUST_BUFFER_ACCESS (1 << 9)
#define VIRGL_CAP_TGSI_FBFETCH (1 << 10) #define VIRGL_CAP_TGSI_FBFETCH (1 << 10)
#define VIRGL_CAP_SHADER_CLOCK (1 << 11) #define VIRGL_CAP_SHADER_CLOCK (1 << 11)
#define VIRGL_CAP_TEXTURE_BARRIER (1 << 12)
/* virgl bind flags - these are compatible with mesa 10.5 gallium. /* virgl bind flags - these are compatible with mesa 10.5 gallium.
* but are fixed, no other should be passed to virgl either. * but are fixed, no other should be passed to virgl either.

@ -90,6 +90,7 @@ enum virgl_context_cmd {
VIRGL_CCMD_MEMORY_BARRIER, VIRGL_CCMD_MEMORY_BARRIER,
VIRGL_CCMD_LAUNCH_GRID, VIRGL_CCMD_LAUNCH_GRID,
VIRGL_CCMD_SET_FRAMEBUFFER_STATE_NO_ATTACH, VIRGL_CCMD_SET_FRAMEBUFFER_STATE_NO_ATTACH,
VIRGL_CCMD_TEXTURE_BARRIER,
}; };
/* /*
@ -539,4 +540,8 @@ enum virgl_context_cmd {
#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_LAYERS(x) (x & 0xffff) #define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_LAYERS(x) (x & 0xffff)
#define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_SAMPLES(x) ((x >> 16) & 0xff) #define VIRGL_SET_FRAMEBUFFER_STATE_NO_ATTACH_SAMPLES(x) ((x >> 16) & 0xff)
/* texture barrier */
#define VIRGL_TEXTURE_BARRIER_SIZE 1
#define VIRGL_TEXTURE_BARRIER_FLAGS 1
#endif #endif

@ -1213,6 +1213,16 @@ static int vrend_decode_set_streamout_targets(struct vrend_decode_ctx *ctx,
return 0; return 0;
} }
static int vrend_decode_texture_barrier(struct vrend_decode_ctx *ctx, uint16_t length)
{
if (length != VIRGL_TEXTURE_BARRIER_SIZE)
return EINVAL;
unsigned flags = get_buf_entry(ctx, VIRGL_TEXTURE_BARRIER_FLAGS);
vrend_texture_barrier(ctx->grctx, flags);
return 0;
}
void vrend_renderer_context_create_internal(uint32_t handle, uint32_t nlen, void vrend_renderer_context_create_internal(uint32_t handle, uint32_t nlen,
const char *debug_name) const char *debug_name)
{ {
@ -1436,6 +1446,9 @@ int vrend_decode_block(uint32_t ctx_id, uint32_t *block, int ndw)
case VIRGL_CCMD_SET_FRAMEBUFFER_STATE_NO_ATTACH: case VIRGL_CCMD_SET_FRAMEBUFFER_STATE_NO_ATTACH:
ret = vrend_decode_set_framebuffer_state_no_attach(gdctx, len); ret = vrend_decode_set_framebuffer_state_no_attach(gdctx, len);
break; break;
case VIRGL_CCMD_TEXTURE_BARRIER:
ret = vrend_decode_texture_barrier(gdctx, len);
break;
default: default:
ret = EINVAL; ret = EINVAL;
} }

@ -129,6 +129,7 @@ enum features_id
feat_storage_multisample, feat_storage_multisample,
feat_tessellation, feat_tessellation,
feat_texture_array, feat_texture_array,
feat_texture_barrier,
feat_texture_buffer_range, feat_texture_buffer_range,
feat_texture_gather, feat_texture_gather,
feat_texture_multisample, feat_texture_multisample,
@ -193,6 +194,7 @@ static const struct {
[feat_storage_multisample] = { 43, 31, { "GL_ARB_texture_storage_multisample" } }, [feat_storage_multisample] = { 43, 31, { "GL_ARB_texture_storage_multisample" } },
[feat_tessellation] = { 40, UNAVAIL, { "GL_ARB_tessellation_shader" } }, [feat_tessellation] = { 40, UNAVAIL, { "GL_ARB_tessellation_shader" } },
[feat_texture_array] = { 30, 30, { "GL_EXT_texture_array" } }, [feat_texture_array] = { 30, 30, { "GL_EXT_texture_array" } },
[feat_texture_barrier] = { 45, UNAVAIL, { "GL_ARB_texture_barrier" } },
[feat_texture_buffer_range] = { 43, UNAVAIL, { "GL_ARB_texture_buffer_range" } }, [feat_texture_buffer_range] = { 43, UNAVAIL, { "GL_ARB_texture_buffer_range" } },
[feat_texture_gather] = { 40, 31, { "GL_ARB_texture_gather" } }, [feat_texture_gather] = { 40, 31, { "GL_ARB_texture_gather" } },
[feat_texture_multisample] = { 32, 30, { "GL_ARB_texture_multisample" } }, [feat_texture_multisample] = { 32, 30, { "GL_ARB_texture_multisample" } },
@ -2666,6 +2668,16 @@ void vrend_memory_barrier(struct vrend_context *ctx,
glMemoryBarrier(gl_barrier); glMemoryBarrier(gl_barrier);
} }
void vrend_texture_barrier(struct vrend_context *ctx,
unsigned flags)
{
if (!has_feature(feat_texture_barrier))
return;
if (flags == PIPE_TEXTURE_BARRIER_SAMPLER)
glTextureBarrier();
}
static void vrend_destroy_shader_object(void *obj_ptr) static void vrend_destroy_shader_object(void *obj_ptr)
{ {
struct vrend_shader_selector *state = obj_ptr; struct vrend_shader_selector *state = obj_ptr;
@ -8165,6 +8177,9 @@ static void vrend_renderer_fill_caps_v2(int gl_ver, int gles_ver, union virgl_c
if (has_feature(feat_shader_clock)) if (has_feature(feat_shader_clock))
caps->v2.capability_bits |= VIRGL_CAP_SHADER_CLOCK; caps->v2.capability_bits |= VIRGL_CAP_SHADER_CLOCK;
if (has_feature(feat_texture_barrier))
caps->v2.capability_bits |= VIRGL_CAP_TEXTURE_BARRIER;
} }
void vrend_renderer_fill_caps(uint32_t set, UNUSED uint32_t version, void vrend_renderer_fill_caps(uint32_t set, UNUSED uint32_t version,

@ -253,6 +253,8 @@ void vrend_launch_grid(struct vrend_context *ctx,
void vrend_set_framebuffer_state_no_attach(struct vrend_context *ctx, void vrend_set_framebuffer_state_no_attach(struct vrend_context *ctx,
uint32_t width, uint32_t height, uint32_t width, uint32_t height,
uint32_t layers, uint32_t samples); uint32_t layers, uint32_t samples);
void vrend_texture_barrier(struct vrend_context *ctx,
unsigned flags);
#define VREND_TRANSFER_WRITE 1 #define VREND_TRANSFER_WRITE 1
#define VREND_TRANSFER_READ 2 #define VREND_TRANSFER_READ 2
int vrend_renderer_transfer_iov(const struct vrend_transfer_info *info, int transfer_mode); int vrend_renderer_transfer_iov(const struct vrend_transfer_info *info, int transfer_mode);

Loading…
Cancel
Save