Replace virgl_renderer_resource_get_info

virgl_renderer_resource_get_info is used to get texture information for
scanout. However, it is also crucial to configure the texture correctly
for scanout. Replace it with virgl_renderer_borrow_texture_for_scanout,
which "borrows" the texture and modifies its configuration.

Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
macos/master
Akihiko Odaki 4 years ago
parent 49b729dd84
commit 6a9e3b94c6
  1. 8
      src/virglrenderer.c
  2. 8
      src/virglrenderer.h
  3. 46
      src/vrend_renderer.c
  4. 6
      src/vrend_renderer.h

@ -453,8 +453,8 @@ void virgl_renderer_ctx_detach_resource(int ctx_id, int res_handle)
ctx->detach_resource(ctx, res);
}
int virgl_renderer_resource_get_info(int res_handle,
struct virgl_renderer_resource_info *info)
int virgl_renderer_borrow_texture_for_scanout(int res_handle,
struct virgl_renderer_texture_info *info)
{
TRACE_FUNC();
struct virgl_resource *res = virgl_resource_lookup(res_handle);
@ -464,8 +464,8 @@ int virgl_renderer_resource_get_info(int res_handle,
if (!info)
return EINVAL;
vrend_renderer_resource_get_info(res->pipe_resource,
(struct vrend_renderer_resource_info *)info);
vrend_renderer_borrow_texture_for_scanout(res->pipe_resource,
(struct vrend_renderer_texture_info *)info);
info->handle = res_handle;
if (state.winsys_initialized) {

@ -275,9 +275,9 @@ VIRGL_EXPORT void virgl_renderer_ctx_detach_resource(int ctx_id, int res_handle)
VIRGL_EXPORT virgl_debug_callback_type virgl_set_debug_callback(virgl_debug_callback_type cb);
/* return information about a resource */
/* borrow a texture for scanout */
struct virgl_renderer_resource_info {
struct virgl_renderer_texture_info {
uint32_t handle;
uint32_t virgl_format;
uint32_t width;
@ -289,8 +289,8 @@ struct virgl_renderer_resource_info {
int drm_fourcc;
};
VIRGL_EXPORT int virgl_renderer_resource_get_info(int res_handle,
struct virgl_renderer_resource_info *info);
VIRGL_EXPORT int virgl_renderer_borrow_texture_for_scanout(int res_handle,
struct virgl_renderer_texture_info *info);
VIRGL_EXPORT void virgl_renderer_cleanup(void *cookie);

@ -11236,21 +11236,45 @@ void vrend_context_set_debug_flags(struct vrend_context *ctx, const char *flagst
}
}
void vrend_renderer_resource_get_info(struct pipe_resource *pres,
struct vrend_renderer_resource_info *info)
void vrend_renderer_borrow_texture_for_scanout(struct pipe_resource *pres,
struct vrend_renderer_texture_info *info)
{
struct vrend_resource *res = (struct vrend_resource *)pres;
struct vrend_texture *tex = (struct vrend_texture *)pres;
struct vrend_format_table *tex_conv = &tex_conv_table[tex->base.base.format];
int elsize;
elsize = util_format_get_blocksize(res->base.format);
assert(tex->base.target == GL_TEXTURE_2D);
assert(!util_format_is_depth_or_stencil(tex->base.base.format));
elsize = util_format_get_blocksize(tex->base.base.format);
glBindTexture(GL_TEXTURE_2D, tex->base.id);
if (tex_conv->flags & VIRGL_TEXTURE_NEED_SWIZZLE) {
for (unsigned i = 0; i < ARRAY_SIZE(tex->cur_swizzle); ++i) {
GLint next_swizzle = to_gl_swizzle(tex_conv->swizzle[i]);
if (tex->cur_swizzle[i] != next_swizzle) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R + i, next_swizzle);
tex->cur_swizzle[i] = next_swizzle;
}
}
}
if (tex->cur_srgb_decode != GL_DECODE_EXT && util_format_is_srgb(tex->base.base.format)) {
if (has_feature(feat_texture_srgb_decode)) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT,
GL_DECODE_EXT);
tex->cur_srgb_decode = GL_DECODE_EXT;
}
}
info->tex_id = res->id;
info->width = res->base.width0;
info->height = res->base.height0;
info->depth = res->base.depth0;
info->format = res->base.format;
info->flags = res->y_0_top ? VIRGL_RESOURCE_Y_0_TOP : 0;
info->stride = util_format_get_nblocksx(res->base.format, u_minify(res->base.width0, 0)) * elsize;
info->tex_id = tex->base.id;
info->width = tex->base.base.width0;
info->height = tex->base.base.height0;
info->depth = tex->base.base.depth0;
info->format = tex->base.base.format;
info->flags = tex->base.y_0_top ? VIRGL_RESOURCE_Y_0_TOP : 0;
info->stride = util_format_get_nblocksx(tex->base.base.format, u_minify(tex->base.base.width0, 0)) * elsize;
}
void vrend_renderer_get_cap_set(uint32_t cap_set, uint32_t *max_ver,

@ -447,7 +447,7 @@ void vrend_renderer_detach_res_ctx(struct vrend_context *ctx,
struct vrend_context_tweaks *vrend_get_context_tweaks(struct vrend_context *ctx);
struct vrend_renderer_resource_info {
struct vrend_renderer_texture_info {
uint32_t handle;
uint32_t format;
uint32_t width;
@ -471,8 +471,8 @@ struct vrend_blit_info {
bool has_srgb_write_control;
};
void vrend_renderer_resource_get_info(struct pipe_resource *pres,
struct vrend_renderer_resource_info *info);
void vrend_renderer_borrow_texture_for_scanout(struct pipe_resource *pres,
struct vrend_renderer_texture_info *info);
void vrend_renderer_get_cap_set(uint32_t cap_set, uint32_t *max_ver,
uint32_t *max_size);

Loading…
Cancel
Save