renderer: CLEANUP: whitespace and reindent

this uses the mesa coding style, pray I never have to do
this again.

strip all trailing whitespace as much as possible
macos/master
Dave Airlie 10 years ago
parent 59b9cb549a
commit 7e85c2f114
  1. 358
      src/virgl_egl_context.c
  2. 2
      src/virgl_hw.h
  3. 2
      src/virgl_protocol.h
  4. 134
      src/virglrenderer.c
  5. 14
      src/virglrenderer.h
  6. 700
      src/vrend_blitter.c
  7. 27
      src/vrend_blitter.h
  8. 102
      src/vrend_decode.c
  9. 462
      src/vrend_formats.c
  10. 8
      src/vrend_object.c
  11. 1214
      src/vrend_renderer.c
  12. 72
      src/vrend_renderer.h
  13. 238
      src/vrend_shader.c
  14. 2
      src/vrend_shader.h

@ -43,213 +43,213 @@
#include "virgl_hw.h" #include "virgl_hw.h"
struct virgl_egl { struct virgl_egl {
int fd; int fd;
struct gbm_device *gbm_dev; struct gbm_device *gbm_dev;
EGLDisplay egl_display; EGLDisplay egl_display;
EGLConfig egl_conf; EGLConfig egl_conf;
EGLContext egl_ctx; EGLContext egl_ctx;
bool have_mesa_drm_image; bool have_mesa_drm_image;
bool have_mesa_dma_buf_img_export; bool have_mesa_dma_buf_img_export;
}; };
static int egl_rendernode_open(void) static int egl_rendernode_open(void)
{ {
DIR *dir; DIR *dir;
struct dirent *e; struct dirent *e;
int r, fd; int r, fd;
char *p; char *p;
dir = opendir("/dev/dri"); dir = opendir("/dev/dri");
if (!dir) if (!dir)
return -1; return -1;
fd = -1; fd = -1;
while ((e = readdir(dir))) { while ((e = readdir(dir))) {
if (e->d_type != DT_CHR) if (e->d_type != DT_CHR)
continue; continue;
if (strncmp(e->d_name, "renderD", 7)) if (strncmp(e->d_name, "renderD", 7))
continue; continue;
r = asprintf(&p, "/dev/dri/%s", e->d_name); r = asprintf(&p, "/dev/dri/%s", e->d_name);
if (r < 0) if (r < 0)
return -1; return -1;
r = open(p, O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK); r = open(p, O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK);
if (r < 0){ if (r < 0){
free(p); free(p);
continue; continue;
} }
fd = r; fd = r;
free(p); free(p);
break; break;
} }
closedir(dir); closedir(dir);
if (fd < 0) if (fd < 0)
return -1; return -1;
return fd; return fd;
} }
static bool virgl_egl_has_extension_in_string(const char *haystack, const char *needle) static bool virgl_egl_has_extension_in_string(const char *haystack, const char *needle)
{ {
const unsigned needle_len = strlen(needle); const unsigned needle_len = strlen(needle);
if (needle_len == 0) if (needle_len == 0)
return false; return false;
while (true) { while (true) {
const char *const s = strstr(haystack, needle); const char *const s = strstr(haystack, needle);
if (s == NULL) if (s == NULL)
return false; return false;
if (s[needle_len] == ' ' || s[needle_len] == '\0') { if (s[needle_len] == ' ' || s[needle_len] == '\0') {
return true; return true;
} }
/* strstr found an extension whose name begins with /* strstr found an extension whose name begins with
* needle, but whose name is not equal to needle. * needle, but whose name is not equal to needle.
* Restart the search at s + needle_len so that we * Restart the search at s + needle_len so that we
* don't just find the same extension again and go * don't just find the same extension again and go
* into an infinite loop. * into an infinite loop.
*/ */
haystack = s + needle_len; haystack = s + needle_len;
} }
return false; return false;
} }
struct virgl_egl *virgl_egl_init(void) struct virgl_egl *virgl_egl_init(void)
{ {
static const EGLint conf_att[] = { static const EGLint conf_att[] = {
EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
EGL_RED_SIZE, 1, EGL_RED_SIZE, 1,
EGL_GREEN_SIZE, 1, EGL_GREEN_SIZE, 1,
EGL_BLUE_SIZE, 1, EGL_BLUE_SIZE, 1,
EGL_ALPHA_SIZE, 0, EGL_ALPHA_SIZE, 0,
EGL_NONE, EGL_NONE,
}; };
static const EGLint ctx_att[] = { static const EGLint ctx_att[] = {
EGL_CONTEXT_CLIENT_VERSION, 2, EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE EGL_NONE
}; };
EGLBoolean b; EGLBoolean b;
EGLenum api; EGLenum api;
EGLint major, minor, n; EGLint major, minor, n;
const char *extension_list; const char *extension_list;
struct virgl_egl *d; struct virgl_egl *d;
d = malloc(sizeof(struct virgl_egl)); d = malloc(sizeof(struct virgl_egl));
if (!d) if (!d)
return NULL; return NULL;
d->fd = egl_rendernode_open(); d->fd = egl_rendernode_open();
if (d->fd == -1) if (d->fd == -1)
goto fail; goto fail;
d->gbm_dev = gbm_create_device(d->fd); d->gbm_dev = gbm_create_device(d->fd);
if (!d->gbm_dev) if (!d->gbm_dev)
goto fail; goto fail;
d->egl_display = eglGetDisplay((EGLNativeDisplayType)d->gbm_dev); d->egl_display = eglGetDisplay((EGLNativeDisplayType)d->gbm_dev);
if (!d->egl_display) if (!d->egl_display)
goto fail; goto fail;
b = eglInitialize(d->egl_display, &major, &minor); b = eglInitialize(d->egl_display, &major, &minor);
if (!b) if (!b)
goto fail; goto fail;
extension_list = eglQueryString(d->egl_display, EGL_EXTENSIONS); extension_list = eglQueryString(d->egl_display, EGL_EXTENSIONS);
#ifdef VIRGL_EGL_DEBUG #ifdef VIRGL_EGL_DEBUG
fprintf(stderr, "EGL major/minor: %d.%d\n", major, minor); fprintf(stderr, "EGL major/minor: %d.%d\n", major, minor);
fprintf(stderr, "EGL version: %s\n", fprintf(stderr, "EGL version: %s\n",
eglQueryString(d->egl_display, EGL_VERSION)); eglQueryString(d->egl_display, EGL_VERSION));
fprintf(stderr, "EGL vendor: %s\n", fprintf(stderr, "EGL vendor: %s\n",
eglQueryString(d->egl_display, EGL_VENDOR)); eglQueryString(d->egl_display, EGL_VENDOR));
fprintf(stderr, "EGL extensions: %s\n", extension_list); fprintf(stderr, "EGL extensions: %s\n", extension_list);
#endif #endif
/* require surfaceless context */ /* require surfaceless context */
if (!virgl_egl_has_extension_in_string(extension_list, "EGL_KHR_surfaceless_context")) if (!virgl_egl_has_extension_in_string(extension_list, "EGL_KHR_surfaceless_context"))
goto fail; goto fail;
d->have_mesa_drm_image = false; d->have_mesa_drm_image = false;
d->have_mesa_dma_buf_img_export = false; d->have_mesa_dma_buf_img_export = false;
if (virgl_egl_has_extension_in_string(extension_list, "EGL_MESA_drm_image")) if (virgl_egl_has_extension_in_string(extension_list, "EGL_MESA_drm_image"))
d->have_mesa_drm_image = true; d->have_mesa_drm_image = true;
if (virgl_egl_has_extension_in_string(extension_list, "EGL_MESA_image_dma_buf_export")) if (virgl_egl_has_extension_in_string(extension_list, "EGL_MESA_image_dma_buf_export"))
d->have_mesa_dma_buf_img_export = true; d->have_mesa_dma_buf_img_export = true;
if (d->have_mesa_drm_image == false && d->have_mesa_dma_buf_img_export == false) { if (d->have_mesa_drm_image == false && d->have_mesa_dma_buf_img_export == false) {
fprintf(stderr, "failed to find drm image extensions\n"); fprintf(stderr, "failed to find drm image extensions\n");
goto fail; goto fail;
} }
api = EGL_OPENGL_API; api = EGL_OPENGL_API;
b = eglBindAPI(api); b = eglBindAPI(api);
if (!b) if (!b)
goto fail; goto fail;
b = eglChooseConfig(d->egl_display, conf_att, &d->egl_conf, b = eglChooseConfig(d->egl_display, conf_att, &d->egl_conf,
1, &n); 1, &n);
if (!b || n != 1) if (!b || n != 1)
goto fail; goto fail;
d->egl_ctx = eglCreateContext(d->egl_display, d->egl_ctx = eglCreateContext(d->egl_display,
d->egl_conf, d->egl_conf,
EGL_NO_CONTEXT, EGL_NO_CONTEXT,
ctx_att); ctx_att);
if (!d->egl_ctx) if (!d->egl_ctx)
goto fail; goto fail;
eglMakeCurrent(d->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, eglMakeCurrent(d->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
d->egl_ctx); d->egl_ctx);
return d; return d;
fail: fail:
free(d); free(d);
return NULL; return NULL;
} }
void virgl_egl_destroy(struct virgl_egl *d) void virgl_egl_destroy(struct virgl_egl *d)
{ {
eglMakeCurrent(d->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, eglMakeCurrent(d->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
EGL_NO_CONTEXT); EGL_NO_CONTEXT);
eglDestroyContext(d->egl_display, d->egl_ctx); eglDestroyContext(d->egl_display, d->egl_ctx);
eglTerminate(d->egl_display); eglTerminate(d->egl_display);
gbm_device_destroy(d->gbm_dev); gbm_device_destroy(d->gbm_dev);
close(d->fd); close(d->fd);
free(d); free(d);
} }
virgl_renderer_gl_context virgl_egl_create_context(struct virgl_egl *ve, struct virgl_gl_ctx_param *vparams) virgl_renderer_gl_context virgl_egl_create_context(struct virgl_egl *ve, struct virgl_gl_ctx_param *vparams)
{ {
EGLContext eglctx; EGLContext eglctx;
EGLint ctx_att[] = { EGLint ctx_att[] = {
EGL_CONTEXT_CLIENT_VERSION, vparams->major_ver, EGL_CONTEXT_CLIENT_VERSION, vparams->major_ver,
EGL_CONTEXT_MINOR_VERSION_KHR, vparams->minor_ver, EGL_CONTEXT_MINOR_VERSION_KHR, vparams->minor_ver,
EGL_NONE EGL_NONE
}; };
eglctx = eglCreateContext(ve->egl_display, eglctx = eglCreateContext(ve->egl_display,
ve->egl_conf, ve->egl_conf,
vparams->shared ? eglGetCurrentContext() : EGL_NO_CONTEXT, vparams->shared ? eglGetCurrentContext() : EGL_NO_CONTEXT,
ctx_att); ctx_att);
return (virgl_renderer_gl_context)eglctx; return (virgl_renderer_gl_context)eglctx;
} }
void virgl_egl_destroy_context(struct virgl_egl *ve, virgl_renderer_gl_context virglctx) void virgl_egl_destroy_context(struct virgl_egl *ve, virgl_renderer_gl_context virglctx)
{ {
EGLContext eglctx = (EGLContext)virglctx; EGLContext eglctx = (EGLContext)virglctx;
eglDestroyContext(ve->egl_display, eglctx); eglDestroyContext(ve->egl_display, eglctx);
} }
int virgl_egl_make_context_current(struct virgl_egl *ve, virgl_renderer_gl_context virglctx) int virgl_egl_make_context_current(struct virgl_egl *ve, virgl_renderer_gl_context virglctx)
{ {
EGLContext eglctx = (EGLContext)virglctx; EGLContext eglctx = (EGLContext)virglctx;
return eglMakeCurrent(ve->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, return eglMakeCurrent(ve->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE,
eglctx); eglctx);
} }
virgl_renderer_gl_context virgl_egl_get_current_context(struct virgl_egl *ve) virgl_renderer_gl_context virgl_egl_get_current_context(struct virgl_egl *ve)
@ -289,7 +289,7 @@ int virgl_egl_get_fourcc_for_texture(struct virgl_egl *ve, uint32_t tex_id, uint
#endif #endif
fallback: fallback:
*fourcc = virgl_egl_get_gbm_format(format); *fourcc = virgl_egl_get_gbm_format(format);
return ret; return ret;
} }
@ -308,36 +308,36 @@ int virgl_egl_get_fd_for_texture(struct virgl_egl *ve, uint32_t tex_id, int *fd)
ret = EINVAL; ret = EINVAL;
if (ve->have_mesa_dma_buf_img_export) { if (ve->have_mesa_dma_buf_img_export) {
#ifdef EGL_MESA_image_dma_buf_export #ifdef EGL_MESA_image_dma_buf_export
b = eglExportDMABUFImageMESA(ve->egl_display, b = eglExportDMABUFImageMESA(ve->egl_display,
image, image,
fd, fd,
&stride); &stride);
#else #else
goto out_destroy; goto out_destroy;
#endif #endif
} else { } else {
#ifdef EGL_MESA_drm_image #ifdef EGL_MESA_drm_image
EGLint handle; EGLint handle;
int r; int r;
b = eglExportDRMImageMESA(ve->egl_display, b = eglExportDRMImageMESA(ve->egl_display,
image, image,
NULL, &handle, NULL, &handle,
&stride); &stride);
if (!b) if (!b)
goto out_destroy; goto out_destroy;
fprintf(stderr,"image exported %d %d\n", handle, stride); fprintf(stderr,"image exported %d %d\n", handle, stride);
r = drmPrimeHandleToFD(ve->fd, handle, DRM_CLOEXEC, fd); r = drmPrimeHandleToFD(ve->fd, handle, DRM_CLOEXEC, fd);
if (r < 0) if (r < 0)
goto out_destroy; goto out_destroy;
#else #else
goto out_destroy; goto out_destroy;
#endif #endif
} }
ret = 0; ret = 0;
out_destroy: out_destroy:
eglDestroyImageKHR(ve->egl_display, image); eglDestroyImageKHR(ve->egl_display, image);
return ret; return ret;
} }

@ -163,7 +163,7 @@ enum virgl_formats {
VIRGL_FORMAT_L32_SINT = 223, VIRGL_FORMAT_L32_SINT = 223,
VIRGL_FORMAT_L32A32_SINT = 224, VIRGL_FORMAT_L32A32_SINT = 224,
VIRGL_FORMAT_B10G10R10A2_UINT = 225, VIRGL_FORMAT_B10G10R10A2_UINT = 225,
VIRGL_FORMAT_R8G8B8X8_SNORM = 229, VIRGL_FORMAT_R8G8B8X8_SNORM = 229,
VIRGL_FORMAT_R8G8B8X8_SRGB = 230, VIRGL_FORMAT_R8G8B8X8_SRGB = 230,

@ -65,7 +65,7 @@ enum virgl_context_cmd {
}; };
/* /*
8-bit cmd headers 8-bit cmd headers
8-bit object type 8-bit object type
16-bit length 16-bit length

@ -59,7 +59,7 @@ void virgl_renderer_resource_unref(uint32_t res_handle)
void virgl_renderer_fill_caps(uint32_t set, uint32_t version, void virgl_renderer_fill_caps(uint32_t set, uint32_t version,
void *caps) void *caps)
{ {
vrend_renderer_fill_caps(set, version, (union virgl_caps *)caps); vrend_renderer_fill_caps(set, version, (union virgl_caps *)caps);
} }
int virgl_renderer_context_create(uint32_t handle, uint32_t nlen, const char *name) int virgl_renderer_context_create(uint32_t handle, uint32_t nlen, const char *name)
@ -76,32 +76,32 @@ int virgl_renderer_submit_cmd(void *buffer,
int ctx_id, int ctx_id,
int ndw) int ndw)
{ {
return vrend_decode_block(ctx_id, buffer, ndw); return vrend_decode_block(ctx_id, buffer, ndw);
} }
int virgl_renderer_transfer_write_iov(uint32_t handle, int virgl_renderer_transfer_write_iov(uint32_t handle,
uint32_t ctx_id, uint32_t ctx_id,
int level, int level,
uint32_t stride, uint32_t stride,
uint32_t layer_stride, uint32_t layer_stride,
struct virgl_box *box, struct virgl_box *box,
uint64_t offset, uint64_t offset,
struct iovec *iovec, struct iovec *iovec,
unsigned int iovec_cnt) unsigned int iovec_cnt)
{ {
struct vrend_transfer_info transfer_info; struct vrend_transfer_info transfer_info;
transfer_info.handle = handle; transfer_info.handle = handle;
transfer_info.ctx_id = ctx_id; transfer_info.ctx_id = ctx_id;
transfer_info.level = level; transfer_info.level = level;
transfer_info.stride = stride; transfer_info.stride = stride;
transfer_info.layer_stride = layer_stride; transfer_info.layer_stride = layer_stride;
transfer_info.box = (struct pipe_box *)box; transfer_info.box = (struct pipe_box *)box;
transfer_info.offset = offset; transfer_info.offset = offset;
transfer_info.iovec = iovec; transfer_info.iovec = iovec;
transfer_info.iovec_cnt = iovec_cnt; transfer_info.iovec_cnt = iovec_cnt;
return vrend_renderer_transfer_iov(&transfer_info, VREND_TRANSFER_WRITE); return vrend_renderer_transfer_iov(&transfer_info, VREND_TRANSFER_WRITE);
} }
int virgl_renderer_transfer_read_iov(uint32_t handle, uint32_t ctx_id, int virgl_renderer_transfer_read_iov(uint32_t handle, uint32_t ctx_id,
@ -111,23 +111,23 @@ int virgl_renderer_transfer_read_iov(uint32_t handle, uint32_t ctx_id,
uint64_t offset, struct iovec *iovec, uint64_t offset, struct iovec *iovec,
int iovec_cnt) int iovec_cnt)
{ {
struct vrend_transfer_info transfer_info; struct vrend_transfer_info transfer_info;
transfer_info.handle = handle; transfer_info.handle = handle;
transfer_info.ctx_id = ctx_id; transfer_info.ctx_id = ctx_id;
transfer_info.level = level; transfer_info.level = level;
transfer_info.stride = stride; transfer_info.stride = stride;
transfer_info.layer_stride = layer_stride; transfer_info.layer_stride = layer_stride;
transfer_info.box = (struct pipe_box *)box; transfer_info.box = (struct pipe_box *)box;
transfer_info.offset = offset; transfer_info.offset = offset;
transfer_info.iovec = iovec; transfer_info.iovec = iovec;
transfer_info.iovec_cnt = iovec_cnt; transfer_info.iovec_cnt = iovec_cnt;
return vrend_renderer_transfer_iov(&transfer_info, VREND_TRANSFER_READ); return vrend_renderer_transfer_iov(&transfer_info, VREND_TRANSFER_READ);
} }
int virgl_renderer_resource_attach_iov(int res_handle, struct iovec *iov, int virgl_renderer_resource_attach_iov(int res_handle, struct iovec *iov,
int num_iovs) int num_iovs)
{ {
return vrend_renderer_resource_attach_iov(res_handle, iov, num_iovs); return vrend_renderer_resource_attach_iov(res_handle, iov, num_iovs);
} }
@ -174,7 +174,7 @@ void virgl_renderer_get_cap_set(uint32_t cap_set, uint32_t *max_ver,
} }
void virgl_renderer_get_rect(int resource_id, struct iovec *iov, unsigned int num_iovs, void virgl_renderer_get_rect(int resource_id, struct iovec *iov, unsigned int num_iovs,
uint32_t offset, int x, int y, int width, int height) uint32_t offset, int x, int y, int width, int height)
{ {
vrend_renderer_get_rect(resource_id, iov, num_iovs, offset, x, y, width, height); vrend_renderer_get_rect(resource_id, iov, num_iovs, offset, x, y, width, height);
} }
@ -188,19 +188,19 @@ static int use_egl_context;
static struct vrend_if_cbs virgl_cbs; static struct vrend_if_cbs virgl_cbs;
void vrend_transfer_write_return(void *data, uint32_t bytes, uint64_t offset, void vrend_transfer_write_return(void *data, uint32_t bytes, uint64_t offset,
struct iovec *iov, int num_iovs) struct iovec *iov, int num_iovs)
{ {
vrend_write_to_iovec(iov, num_iovs, offset, data, bytes); vrend_write_to_iovec(iov, num_iovs, offset, data, bytes);
} }
void vrend_transfer_write_tex_return(struct pipe_resource *res, void vrend_transfer_write_tex_return(struct pipe_resource *res,
struct pipe_box *box, struct pipe_box *box,
uint32_t level, uint32_t level,
uint32_t dst_stride, uint32_t dst_stride,
uint64_t offset, uint64_t offset,
struct iovec *iov, struct iovec *iov,
int num_iovs, int num_iovs,
void *myptr, int size, int invert) void *myptr, int size, int invert)
{ {
int elsize = util_format_get_blocksize(res->format); int elsize = util_format_get_blocksize(res->format);
int h; int h;
@ -227,33 +227,33 @@ void vrend_transfer_write_tex_return(struct pipe_resource *res,
static void virgl_write_fence(uint32_t fence_id) static void virgl_write_fence(uint32_t fence_id)
{ {
rcbs->write_fence(dev_cookie, fence_id); rcbs->write_fence(dev_cookie, fence_id);
} }
static virgl_renderer_gl_context create_gl_context(int scanout_idx, struct virgl_gl_ctx_param *param) static virgl_renderer_gl_context create_gl_context(int scanout_idx, struct virgl_gl_ctx_param *param)
{ {
struct virgl_renderer_gl_ctx_param vparam; struct virgl_renderer_gl_ctx_param vparam;
if (use_egl_context) if (use_egl_context)
return virgl_egl_create_context(egl_info, param); return virgl_egl_create_context(egl_info, param);
vparam.version = 1; vparam.version = 1;
vparam.shared = param->shared; vparam.shared = param->shared;
vparam.major_ver = param->major_ver; vparam.major_ver = param->major_ver;
vparam.minor_ver = param->minor_ver; vparam.minor_ver = param->minor_ver;
return rcbs->create_gl_context(dev_cookie, scanout_idx, &vparam); return rcbs->create_gl_context(dev_cookie, scanout_idx, &vparam);
} }
static void destroy_gl_context(virgl_renderer_gl_context ctx) static void destroy_gl_context(virgl_renderer_gl_context ctx)
{ {
if (use_egl_context) if (use_egl_context)
return virgl_egl_destroy_context(egl_info, ctx); return virgl_egl_destroy_context(egl_info, ctx);
return rcbs->destroy_gl_context(dev_cookie, ctx); return rcbs->destroy_gl_context(dev_cookie, ctx);
} }
static int make_current(int scanout_idx, virgl_renderer_gl_context ctx) static int make_current(int scanout_idx, virgl_renderer_gl_context ctx)
{ {
if (use_egl_context) if (use_egl_context)
return virgl_egl_make_context_current(egl_info, ctx); return virgl_egl_make_context_current(egl_info, ctx);
return rcbs->make_current(dev_cookie, scanout_idx, ctx); return rcbs->make_current(dev_cookie, scanout_idx, ctx);
} }
static struct vrend_if_cbs virgl_cbs = { static struct vrend_if_cbs virgl_cbs = {
@ -288,7 +288,7 @@ void virgl_renderer_cleanup(void *cookie)
int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks *cbs) int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks *cbs)
{ {
if (!cookie || !cbs) if (!cookie || !cbs)
return -1; return -1;
if (cbs->version != 1) if (cbs->version != 1)
return -1; return -1;
@ -297,10 +297,10 @@ int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks
rcbs = cbs; rcbs = cbs;
if (flags & VIRGL_RENDERER_USE_EGL) { if (flags & VIRGL_RENDERER_USE_EGL) {
egl_info = virgl_egl_init(); egl_info = virgl_egl_init();
if (!egl_info) if (!egl_info)
return -1; return -1;
use_egl_context = 1; use_egl_context = 1;
} }
vrend_renderer_init(&virgl_cbs); vrend_renderer_init(&virgl_cbs);
@ -309,7 +309,7 @@ int virgl_renderer_init(void *cookie, int flags, struct virgl_renderer_callbacks
int virgl_renderer_get_fd_for_texture(uint32_t tex_id, int *fd) int virgl_renderer_get_fd_for_texture(uint32_t tex_id, int *fd)
{ {
return virgl_egl_get_fd_for_texture(egl_info, tex_id, fd); return virgl_egl_get_fd_for_texture(egl_info, tex_id, fd);
} }
void virgl_renderer_reset(void) void virgl_renderer_reset(void)

@ -97,7 +97,7 @@ struct virgl_renderer_resource_create_args {
}; };
/* new API */ /* new API */
VIRGL_EXPORT int virgl_renderer_resource_create(struct virgl_renderer_resource_create_args *args, struct iovec *iov, uint32_t num_iovs); VIRGL_EXPORT int virgl_renderer_resource_create(struct virgl_renderer_resource_create_args *args, struct iovec *iov, uint32_t num_iovs);
VIRGL_EXPORT void virgl_renderer_resource_unref(uint32_t res_handle); VIRGL_EXPORT void virgl_renderer_resource_unref(uint32_t res_handle);
@ -109,11 +109,11 @@ VIRGL_EXPORT int virgl_renderer_submit_cmd(void *buffer,
int ndw); int ndw);
VIRGL_EXPORT int virgl_renderer_transfer_read_iov(uint32_t handle, uint32_t ctx_id, VIRGL_EXPORT int virgl_renderer_transfer_read_iov(uint32_t handle, uint32_t ctx_id,
uint32_t level, uint32_t stride, uint32_t level, uint32_t stride,
uint32_t layer_stride, uint32_t layer_stride,
struct virgl_box *box, struct virgl_box *box,
uint64_t offset, struct iovec *iov, uint64_t offset, struct iovec *iov,
int iovec_cnt); int iovec_cnt);
VIRGL_EXPORT int virgl_renderer_transfer_write_iov(uint32_t handle, VIRGL_EXPORT int virgl_renderer_transfer_write_iov(uint32_t handle,
uint32_t ctx_id, uint32_t ctx_id,
@ -132,7 +132,7 @@ VIRGL_EXPORT void virgl_renderer_fill_caps(uint32_t set, uint32_t version,
void *caps); void *caps);
VIRGL_EXPORT int virgl_renderer_resource_attach_iov(int res_handle, struct iovec *iov, VIRGL_EXPORT int virgl_renderer_resource_attach_iov(int res_handle, struct iovec *iov,
int num_iovs); int num_iovs);
VIRGL_EXPORT void virgl_renderer_resource_detach_iov(int res_handle, struct iovec **iov, int *num_iovs); VIRGL_EXPORT void virgl_renderer_resource_detach_iov(int res_handle, struct iovec **iov, int *num_iovs);
VIRGL_EXPORT int virgl_renderer_create_fence(int client_fence_id, uint32_t ctx_id); VIRGL_EXPORT int virgl_renderer_create_fence(int client_fence_id, uint32_t ctx_id);

@ -50,261 +50,261 @@
#include "vrend_blitter.h" #include "vrend_blitter.h"
struct vrend_blitter_ctx { struct vrend_blitter_ctx {
virgl_gl_context gl_context; virgl_gl_context gl_context;
bool initialised; bool initialised;
GLuint vaoid; GLuint vaoid;
GLuint vs; GLuint vs;
GLuint vs_pos_only; GLuint vs_pos_only;
GLuint fs_texfetch_col[PIPE_MAX_TEXTURE_TYPES]; GLuint fs_texfetch_col[PIPE_MAX_TEXTURE_TYPES];
GLuint fs_texfetch_depth[PIPE_MAX_TEXTURE_TYPES]; GLuint fs_texfetch_depth[PIPE_MAX_TEXTURE_TYPES];
GLuint fs_texfetch_depth_msaa[PIPE_MAX_TEXTURE_TYPES]; GLuint fs_texfetch_depth_msaa[PIPE_MAX_TEXTURE_TYPES];
GLuint fb_id; GLuint fb_id;
unsigned dst_width; unsigned dst_width;
unsigned dst_height; unsigned dst_height;
GLuint vbo_id; GLuint vbo_id;
GLfloat vertices[4][2][4]; /**< {pos, color} or {pos, texcoord} */ GLfloat vertices[4][2][4]; /**< {pos, color} or {pos, texcoord} */
}; };
static struct vrend_blitter_ctx vrend_blit_ctx; static struct vrend_blitter_ctx vrend_blit_ctx;
static bool build_and_check(GLuint id, const char *buf) static bool build_and_check(GLuint id, const char *buf)
{ {
GLint param; GLint param;
glShaderSource(id, 1, (const char **)&buf, NULL); glShaderSource(id, 1, (const char **)&buf, NULL);
glCompileShader(id); glCompileShader(id);
glGetShaderiv(id, GL_COMPILE_STATUS, &param); glGetShaderiv(id, GL_COMPILE_STATUS, &param);
if (param == GL_FALSE) { if (param == GL_FALSE) {
char infolog[65536]; char infolog[65536];
int len; int len;
glGetShaderInfoLog(id, 65536, &len, infolog); glGetShaderInfoLog(id, 65536, &len, infolog);
fprintf(stderr,"shader failed to compile\n%s\n", infolog); fprintf(stderr,"shader failed to compile\n%s\n", infolog);
fprintf(stderr,"GLSL:\n%s\n", buf); fprintf(stderr,"GLSL:\n%s\n", buf);
return false; return false;
} }
return true; return true;
} }
static bool blit_build_vs_passthrough(struct vrend_blitter_ctx *blit_ctx) static bool blit_build_vs_passthrough(struct vrend_blitter_ctx *blit_ctx)
{ {
blit_ctx->vs = glCreateShader(GL_VERTEX_SHADER); blit_ctx->vs = glCreateShader(GL_VERTEX_SHADER);
if (!build_and_check(blit_ctx->vs, vs_passthrough)) { if (!build_and_check(blit_ctx->vs, vs_passthrough)) {
glDeleteShader(blit_ctx->vs); glDeleteShader(blit_ctx->vs);
blit_ctx->vs = 0; blit_ctx->vs = 0;
return false; return false;
} }
return true; return true;
} }
static GLuint blit_build_frag_tex_col(struct vrend_blitter_ctx *blit_ctx, int tgsi_tex_target) static GLuint blit_build_frag_tex_col(struct vrend_blitter_ctx *blit_ctx, int tgsi_tex_target)
{ {
GLuint fs_id; GLuint fs_id;
char shader_buf[4096]; char shader_buf[4096];
int is_shad; int is_shad;
const char *twm; const char *twm;
char *ext_str = ""; char *ext_str = "";
switch (tgsi_tex_target) { switch (tgsi_tex_target) {
case TGSI_TEXTURE_1D: case TGSI_TEXTURE_1D:
case TGSI_TEXTURE_BUFFER: case TGSI_TEXTURE_BUFFER:
twm = ".x"; twm = ".x";
break; break;
case TGSI_TEXTURE_1D_ARRAY: case TGSI_TEXTURE_1D_ARRAY:
case TGSI_TEXTURE_2D: case TGSI_TEXTURE_2D:
case TGSI_TEXTURE_RECT: case TGSI_TEXTURE_RECT:
case TGSI_TEXTURE_2D_MSAA: case TGSI_TEXTURE_2D_MSAA:
default: default:
twm = ".xy"; twm = ".xy";
break; break;
case TGSI_TEXTURE_SHADOW1D: case TGSI_TEXTURE_SHADOW1D:
case TGSI_TEXTURE_SHADOW2D: case TGSI_TEXTURE_SHADOW2D:
case TGSI_TEXTURE_SHADOW1D_ARRAY: case TGSI_TEXTURE_SHADOW1D_ARRAY:
case TGSI_TEXTURE_SHADOWRECT: case TGSI_TEXTURE_SHADOWRECT:
case TGSI_TEXTURE_3D: case TGSI_TEXTURE_3D:
case TGSI_TEXTURE_CUBE: case TGSI_TEXTURE_CUBE:
case TGSI_TEXTURE_2D_ARRAY: case TGSI_TEXTURE_2D_ARRAY:
case TGSI_TEXTURE_2D_ARRAY_MSAA: case TGSI_TEXTURE_2D_ARRAY_MSAA:
twm = ".xyz"; twm = ".xyz";
break; break;
case TGSI_TEXTURE_SHADOWCUBE: case TGSI_TEXTURE_SHADOWCUBE:
case TGSI_TEXTURE_SHADOW2D_ARRAY: case TGSI_TEXTURE_SHADOW2D_ARRAY:
case TGSI_TEXTURE_SHADOWCUBE_ARRAY: case TGSI_TEXTURE_SHADOWCUBE_ARRAY:
case TGSI_TEXTURE_CUBE_ARRAY: case TGSI_TEXTURE_CUBE_ARRAY:
twm = ""; twm = "";
break; break;
} }
if (tgsi_tex_target == TGSI_TEXTURE_CUBE_ARRAY || if (tgsi_tex_target == TGSI_TEXTURE_CUBE_ARRAY ||
tgsi_tex_target == TGSI_TEXTURE_SHADOWCUBE_ARRAY) tgsi_tex_target == TGSI_TEXTURE_SHADOWCUBE_ARRAY)
ext_str = "#extension GL_ARB_texture_cube_map_array : require\n"; ext_str = "#extension GL_ARB_texture_cube_map_array : require\n";
snprintf(shader_buf, 4096, fs_texfetch_col, ext_str, vrend_shader_samplertypeconv(tgsi_tex_target, &is_shad), twm, ""); snprintf(shader_buf, 4096, fs_texfetch_col, ext_str, vrend_shader_samplertypeconv(tgsi_tex_target, &is_shad), twm, "");
fs_id = glCreateShader(GL_FRAGMENT_SHADER); fs_id = glCreateShader(GL_FRAGMENT_SHADER);
if (!build_and_check(fs_id, shader_buf)) { if (!build_and_check(fs_id, shader_buf)) {
glDeleteShader(fs_id); glDeleteShader(fs_id);
return 0; return 0;
} }
return fs_id; return fs_id;
} }
static GLuint blit_build_frag_tex_writedepth(struct vrend_blitter_ctx *blit_ctx, int tgsi_tex_target) static GLuint blit_build_frag_tex_writedepth(struct vrend_blitter_ctx *blit_ctx, int tgsi_tex_target)
{ {
GLuint fs_id; GLuint fs_id;
char shader_buf[4096]; char shader_buf[4096];
int is_shad; int is_shad;
const char *twm; const char *twm;
switch (tgsi_tex_target) { switch (tgsi_tex_target) {
case TGSI_TEXTURE_1D: case TGSI_TEXTURE_1D:
case TGSI_TEXTURE_BUFFER: case TGSI_TEXTURE_BUFFER:
twm = ".x"; twm = ".x";
break; break;
case TGSI_TEXTURE_1D_ARRAY: case TGSI_TEXTURE_1D_ARRAY:
case TGSI_TEXTURE_2D: case TGSI_TEXTURE_2D:
case TGSI_TEXTURE_RECT: case TGSI_TEXTURE_RECT:
case TGSI_TEXTURE_2D_MSAA: case TGSI_TEXTURE_2D_MSAA:
default: default:
twm = ".xy"; twm = ".xy";
break; break;
case TGSI_TEXTURE_SHADOW1D: case TGSI_TEXTURE_SHADOW1D:
case TGSI_TEXTURE_SHADOW2D: case TGSI_TEXTURE_SHADOW2D:
case TGSI_TEXTURE_SHADOW1D_ARRAY: case TGSI_TEXTURE_SHADOW1D_ARRAY:
case TGSI_TEXTURE_SHADOWRECT: case TGSI_TEXTURE_SHADOWRECT:
case TGSI_TEXTURE_3D: case TGSI_TEXTURE_3D:
case TGSI_TEXTURE_CUBE: case TGSI_TEXTURE_CUBE:
case TGSI_TEXTURE_2D_ARRAY: case TGSI_TEXTURE_2D_ARRAY:
case TGSI_TEXTURE_2D_ARRAY_MSAA: case TGSI_TEXTURE_2D_ARRAY_MSAA:
twm = ".xyz"; twm = ".xyz";
break; break;
case TGSI_TEXTURE_SHADOWCUBE: case TGSI_TEXTURE_SHADOWCUBE:
case TGSI_TEXTURE_SHADOW2D_ARRAY: case TGSI_TEXTURE_SHADOW2D_ARRAY:
case TGSI_TEXTURE_SHADOWCUBE_ARRAY: case TGSI_TEXTURE_SHADOWCUBE_ARRAY:
case TGSI_TEXTURE_CUBE_ARRAY: case TGSI_TEXTURE_CUBE_ARRAY:
twm = ""; twm = "";
break; break;
} }
snprintf(shader_buf, 4096, fs_texfetch_ds, vrend_shader_samplertypeconv(tgsi_tex_target, &is_shad), twm); snprintf(shader_buf, 4096, fs_texfetch_ds, vrend_shader_samplertypeconv(tgsi_tex_target, &is_shad), twm);
fs_id = glCreateShader(GL_FRAGMENT_SHADER); fs_id = glCreateShader(GL_FRAGMENT_SHADER);
if (!build_and_check(fs_id, shader_buf)) { if (!build_and_check(fs_id, shader_buf)) {
glDeleteShader(fs_id); glDeleteShader(fs_id);
return 0; return 0;
} }
return fs_id; return fs_id;
} }
static GLuint blit_build_frag_blit_msaa_depth(struct vrend_blitter_ctx *blit_ctx, int tgsi_tex_target) static GLuint blit_build_frag_blit_msaa_depth(struct vrend_blitter_ctx *blit_ctx, int tgsi_tex_target)
{ {
GLuint fs_id; GLuint fs_id;
char shader_buf[4096]; char shader_buf[4096];
int is_shad; int is_shad;
const char *twm; const char *twm;
const char *ivec; const char *ivec;
switch (tgsi_tex_target) { switch (tgsi_tex_target) {
case TGSI_TEXTURE_2D_MSAA: case TGSI_TEXTURE_2D_MSAA:
twm = ".xy"; twm = ".xy";
ivec = "ivec2"; ivec = "ivec2";
break; break;
case TGSI_TEXTURE_2D_ARRAY_MSAA: case TGSI_TEXTURE_2D_ARRAY_MSAA:
twm = ".xyz"; twm = ".xyz";
ivec = "ivec3"; ivec = "ivec3";
break; break;
default: default:
return 0; return 0;
} }
snprintf(shader_buf, 4096, fs_texfetch_ds_msaa, vrend_shader_samplertypeconv(tgsi_tex_target, &is_shad), ivec, twm); snprintf(shader_buf, 4096, fs_texfetch_ds_msaa, vrend_shader_samplertypeconv(tgsi_tex_target, &is_shad), ivec, twm);
fs_id = glCreateShader(GL_FRAGMENT_SHADER); fs_id = glCreateShader(GL_FRAGMENT_SHADER);
if (!build_and_check(fs_id, shader_buf)) { if (!build_and_check(fs_id, shader_buf)) {
glDeleteShader(fs_id); glDeleteShader(fs_id);
return 0; return 0;
} }
return fs_id; return fs_id;
} }
static GLuint blit_get_frag_tex_writedepth(struct vrend_blitter_ctx *blit_ctx, int pipe_tex_target, unsigned nr_samples) static GLuint blit_get_frag_tex_writedepth(struct vrend_blitter_ctx *blit_ctx, int pipe_tex_target, unsigned nr_samples)
{ {
assert(pipe_tex_target < PIPE_MAX_TEXTURE_TYPES); assert(pipe_tex_target < PIPE_MAX_TEXTURE_TYPES);
if (nr_samples > 1) { if (nr_samples > 1) {
GLuint *shader = &blit_ctx->fs_texfetch_depth_msaa[pipe_tex_target]; GLuint *shader = &blit_ctx->fs_texfetch_depth_msaa[pipe_tex_target];
if (!*shader) { if (!*shader) {
unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(pipe_tex_target, nr_samples); unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(pipe_tex_target, nr_samples);
*shader = blit_build_frag_blit_msaa_depth(blit_ctx, tgsi_tex); *shader = blit_build_frag_blit_msaa_depth(blit_ctx, tgsi_tex);
} }
return *shader; return *shader;
} else { } else {
GLuint *shader = &blit_ctx->fs_texfetch_depth[pipe_tex_target]; GLuint *shader = &blit_ctx->fs_texfetch_depth[pipe_tex_target];
if (!*shader) { if (!*shader) {
unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(pipe_tex_target, 0); unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(pipe_tex_target, 0);
*shader = blit_build_frag_tex_writedepth(blit_ctx, tgsi_tex); *shader = blit_build_frag_tex_writedepth(blit_ctx, tgsi_tex);
} }
return *shader; return *shader;
} }
} }
static GLuint blit_get_frag_tex_col(struct vrend_blitter_ctx *blit_ctx, int pipe_tex_target, unsigned nr_samples) static GLuint blit_get_frag_tex_col(struct vrend_blitter_ctx *blit_ctx, int pipe_tex_target, unsigned nr_samples)
{ {
assert(pipe_tex_target < PIPE_MAX_TEXTURE_TYPES); assert(pipe_tex_target < PIPE_MAX_TEXTURE_TYPES);
if (nr_samples > 1) { if (nr_samples > 1) {
return 0; return 0;
} else { } else {
GLuint *shader = &blit_ctx->fs_texfetch_col[pipe_tex_target]; GLuint *shader = &blit_ctx->fs_texfetch_col[pipe_tex_target];
if (!*shader) { if (!*shader) {
unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(pipe_tex_target, 0); unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(pipe_tex_target, 0);
*shader = blit_build_frag_tex_col(blit_ctx, tgsi_tex); *shader = blit_build_frag_tex_col(blit_ctx, tgsi_tex);
} }
return *shader; return *shader;
} }
} }
static void vrend_renderer_init_blit_ctx(struct vrend_blitter_ctx *blit_ctx) static void vrend_renderer_init_blit_ctx(struct vrend_blitter_ctx *blit_ctx)
{ {
struct virgl_gl_ctx_param ctx_params; struct virgl_gl_ctx_param ctx_params;
int i; int i;
if (blit_ctx->initialised) { if (blit_ctx->initialised) {
vrend_clicbs->make_current(0, blit_ctx->gl_context); vrend_clicbs->make_current(0, blit_ctx->gl_context);
return; return;
} }
ctx_params.shared = true; ctx_params.shared = true;
ctx_params.major_ver = VREND_GL_VER_MAJOR; ctx_params.major_ver = VREND_GL_VER_MAJOR;
ctx_params.minor_ver = VREND_GL_VER_MINOR; ctx_params.minor_ver = VREND_GL_VER_MINOR;
blit_ctx->gl_context = vrend_clicbs->create_gl_context(0, &ctx_params); blit_ctx->gl_context = vrend_clicbs->create_gl_context(0, &ctx_params);
vrend_clicbs->make_current(0, blit_ctx->gl_context); vrend_clicbs->make_current(0, blit_ctx->gl_context);
glGenVertexArrays(1, &blit_ctx->vaoid); glGenVertexArrays(1, &blit_ctx->vaoid);
glGenFramebuffers(1, &blit_ctx->fb_id); glGenFramebuffers(1, &blit_ctx->fb_id);
glGenBuffers(1, &blit_ctx->vbo_id); glGenBuffers(1, &blit_ctx->vbo_id);
blit_build_vs_passthrough(blit_ctx); blit_build_vs_passthrough(blit_ctx);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
blit_ctx->vertices[i][0][3] = 1; /*v.w*/ blit_ctx->vertices[i][0][3] = 1; /*v.w*/
glBindVertexArray(blit_ctx->vaoid); glBindVertexArray(blit_ctx->vaoid);
glBindBuffer(GL_ARRAY_BUFFER, blit_ctx->vbo_id); glBindBuffer(GL_ARRAY_BUFFER, blit_ctx->vbo_id);
} }
static inline GLenum convert_mag_filter(unsigned int filter) static inline GLenum convert_mag_filter(unsigned int filter)
@ -317,33 +317,33 @@ static inline GLenum convert_mag_filter(unsigned int filter)
static void blitter_set_dst_dim(struct vrend_blitter_ctx *blit_ctx, static void blitter_set_dst_dim(struct vrend_blitter_ctx *blit_ctx,
unsigned width, unsigned height) unsigned width, unsigned height)
{ {
blit_ctx->dst_width = width; blit_ctx->dst_width = width;
blit_ctx->dst_height = height; blit_ctx->dst_height = height;
} }
static void blitter_set_rectangle(struct vrend_blitter_ctx *blit_ctx, static void blitter_set_rectangle(struct vrend_blitter_ctx *blit_ctx,
int x1, int y1, int x2, int y2, int x1, int y1, int x2, int y2,
float depth) float depth)
{ {
int i; int i;
/* set vertex positions */ /* set vertex positions */
blit_ctx->vertices[0][0][0] = (float)x1 / blit_ctx->dst_width * 2.0f - 1.0f; /*v0.x*/ blit_ctx->vertices[0][0][0] = (float)x1 / blit_ctx->dst_width * 2.0f - 1.0f; /*v0.x*/
blit_ctx->vertices[0][0][1] = (float)y1 / blit_ctx->dst_height * 2.0f - 1.0f; /*v0.y*/ blit_ctx->vertices[0][0][1] = (float)y1 / blit_ctx->dst_height * 2.0f - 1.0f; /*v0.y*/
blit_ctx->vertices[1][0][0] = (float)x2 / blit_ctx->dst_width * 2.0f - 1.0f; /*v1.x*/ blit_ctx->vertices[1][0][0] = (float)x2 / blit_ctx->dst_width * 2.0f - 1.0f; /*v1.x*/
blit_ctx->vertices[1][0][1] = (float)y1 / blit_ctx->dst_height * 2.0f - 1.0f; /*v1.y*/ blit_ctx->vertices[1][0][1] = (float)y1 / blit_ctx->dst_height * 2.0f - 1.0f; /*v1.y*/
blit_ctx->vertices[2][0][0] = (float)x2 / blit_ctx->dst_width * 2.0f - 1.0f; /*v2.x*/ blit_ctx->vertices[2][0][0] = (float)x2 / blit_ctx->dst_width * 2.0f - 1.0f; /*v2.x*/
blit_ctx->vertices[2][0][1] = (float)y2 / blit_ctx->dst_height * 2.0f - 1.0f; /*v2.y*/ blit_ctx->vertices[2][0][1] = (float)y2 / blit_ctx->dst_height * 2.0f - 1.0f; /*v2.y*/
blit_ctx->vertices[3][0][0] = (float)x1 / blit_ctx->dst_width * 2.0f - 1.0f; /*v3.x*/ blit_ctx->vertices[3][0][0] = (float)x1 / blit_ctx->dst_width * 2.0f - 1.0f; /*v3.x*/
blit_ctx->vertices[3][0][1] = (float)y2 / blit_ctx->dst_height * 2.0f - 1.0f; /*v3.y*/ blit_ctx->vertices[3][0][1] = (float)y2 / blit_ctx->dst_height * 2.0f - 1.0f; /*v3.y*/
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
blit_ctx->vertices[i][0][2] = depth; /*z*/ blit_ctx->vertices[i][0][2] = depth; /*z*/
glViewport(0, 0, blit_ctx->dst_width, blit_ctx->dst_height); glViewport(0, 0, blit_ctx->dst_width, blit_ctx->dst_height);
} }
static void get_texcoords(struct vrend_resource *src_res, static void get_texcoords(struct vrend_resource *src_res,
@ -352,7 +352,7 @@ static void get_texcoords(struct vrend_resource *src_res,
float out[4]) float out[4])
{ {
bool normalized = src_res->base.target != PIPE_TEXTURE_RECT && bool normalized = src_res->base.target != PIPE_TEXTURE_RECT &&
src_res->base.nr_samples <= 1; src_res->base.nr_samples <= 1;
if (normalized) { if (normalized) {
out[0] = x1 / (float)u_minify(src_res->base.width0, src_level); out[0] = x1 / (float)u_minify(src_res->base.width0, src_level);
@ -407,13 +407,13 @@ static void blitter_set_texcoords(struct vrend_blitter_ctx *blit_ctx,
switch (src_res->base.target) { switch (src_res->base.target) {
case PIPE_TEXTURE_3D: case PIPE_TEXTURE_3D:
{ {
float r = layer / (float)u_minify(src_res->base.depth0, float r = layer / (float)u_minify(src_res->base.depth0,
level); level);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
blit_ctx->vertices[i][1][2] = r; /*r*/ blit_ctx->vertices[i][1][2] = r; /*r*/
} }
break; break;
case PIPE_TEXTURE_1D_ARRAY: case PIPE_TEXTURE_1D_ARRAY:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
@ -431,140 +431,140 @@ static void blitter_set_texcoords(struct vrend_blitter_ctx *blit_ctx,
blit_ctx->vertices[i][1][3] = (float) ((unsigned)layer / 6); /*w*/ blit_ctx->vertices[i][1][3] = (float) ((unsigned)layer / 6); /*w*/
break; break;
case PIPE_TEXTURE_2D: case PIPE_TEXTURE_2D:
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
blit_ctx->vertices[i][1][3] = (float) sample; /*r*/ blit_ctx->vertices[i][1][3] = (float) sample; /*r*/
} }
break; break;
default:; default:;
} }
} }
#if 0 #if 0
static void set_dsa_keep_depth_stencil(void) static void set_dsa_keep_depth_stencil(void)
{ {
glDisable(GL_STENCIL_TEST); glDisable(GL_STENCIL_TEST);
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE); glDepthMask(GL_FALSE);
} }
#endif #endif
static void set_dsa_write_depth_keep_stencil(void) static void set_dsa_write_depth_keep_stencil(void)
{ {
glDisable(GL_STENCIL_TEST); glDisable(GL_STENCIL_TEST);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_ALWAYS); glDepthFunc(GL_ALWAYS);
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
} }
/* implement blitting using OpenGL. */ /* implement blitting using OpenGL. */
void vrend_renderer_blit_gl(struct vrend_context *ctx, void vrend_renderer_blit_gl(struct vrend_context *ctx,
struct vrend_resource *src_res, struct vrend_resource *src_res,
struct vrend_resource *dst_res, struct vrend_resource *dst_res,
const struct pipe_blit_info *info) const struct pipe_blit_info *info)
{ {
struct vrend_blitter_ctx *blit_ctx = &vrend_blit_ctx; struct vrend_blitter_ctx *blit_ctx = &vrend_blit_ctx;
GLuint prog_id; GLuint prog_id;
GLuint fs_id; GLuint fs_id;
GLint lret; GLint lret;
GLenum filter; GLenum filter;
GLuint pos_loc, tc_loc; GLuint pos_loc, tc_loc;
GLuint samp_loc; GLuint samp_loc;
bool has_depth, has_stencil; bool has_depth, has_stencil;
bool blit_stencil, blit_depth; bool blit_stencil, blit_depth;
int dst_z; int dst_z;
const struct util_format_description *src_desc = const struct util_format_description *src_desc =
util_format_description(src_res->base.format); util_format_description(src_res->base.format);
const struct util_format_description *dst_desc = const struct util_format_description *dst_desc =
util_format_description(dst_res->base.format); util_format_description(dst_res->base.format);
has_depth = util_format_has_depth(src_desc) && has_depth = util_format_has_depth(src_desc) &&
util_format_has_depth(dst_desc); util_format_has_depth(dst_desc);
has_stencil = util_format_has_stencil(src_desc) && has_stencil = util_format_has_stencil(src_desc) &&
util_format_has_stencil(dst_desc); util_format_has_stencil(dst_desc);
blit_depth = has_depth && (info->mask & PIPE_MASK_Z); blit_depth = has_depth && (info->mask & PIPE_MASK_Z);
blit_stencil = has_stencil && (info->mask & PIPE_MASK_S) & 0; blit_stencil = has_stencil && (info->mask & PIPE_MASK_S) & 0;
filter = convert_mag_filter(info->filter); filter = convert_mag_filter(info->filter);
vrend_renderer_init_blit_ctx(blit_ctx); vrend_renderer_init_blit_ctx(blit_ctx);
blitter_set_dst_dim(blit_ctx, blitter_set_dst_dim(blit_ctx,
u_minify(dst_res->base.width0, info->dst.level), u_minify(dst_res->base.width0, info->dst.level),
u_minify(dst_res->base.height0, info->dst.level)); u_minify(dst_res->base.height0, info->dst.level));
blitter_set_rectangle(blit_ctx, info->dst.box.x, info->dst.box.y, blitter_set_rectangle(blit_ctx, info->dst.box.x, info->dst.box.y,
info->dst.box.x + info->dst.box.width, info->dst.box.x + info->dst.box.width,
info->dst.box.y + info->dst.box.height, 0); info->dst.box.y + info->dst.box.height, 0);
prog_id = glCreateProgram(); prog_id = glCreateProgram();
glAttachShader(prog_id, blit_ctx->vs); glAttachShader(prog_id, blit_ctx->vs);
if (blit_depth || blit_stencil) if (blit_depth || blit_stencil)
fs_id = blit_get_frag_tex_writedepth(blit_ctx, src_res->base.target, src_res->base.nr_samples); fs_id = blit_get_frag_tex_writedepth(blit_ctx, src_res->base.target, src_res->base.nr_samples);
else else
fs_id = blit_get_frag_tex_col(blit_ctx, src_res->base.target, src_res->base.nr_samples); fs_id = blit_get_frag_tex_col(blit_ctx, src_res->base.target, src_res->base.nr_samples);
glAttachShader(prog_id, fs_id); glAttachShader(prog_id, fs_id);
glLinkProgram(prog_id); glLinkProgram(prog_id);
glGetProgramiv(prog_id, GL_LINK_STATUS, &lret); glGetProgramiv(prog_id, GL_LINK_STATUS, &lret);
if (lret == GL_FALSE) { if (lret == GL_FALSE) {
char infolog[65536]; char infolog[65536];
int len; int len;
glGetProgramInfoLog(prog_id, 65536, &len, infolog); glGetProgramInfoLog(prog_id, 65536, &len, infolog);
fprintf(stderr,"got error linking\n%s\n", infolog); fprintf(stderr,"got error linking\n%s\n", infolog);
/* dump shaders */ /* dump shaders */
glDeleteProgram(prog_id); glDeleteProgram(prog_id);
return; return;
} }
glUseProgram(prog_id); glUseProgram(prog_id);
glBindFramebuffer(GL_FRAMEBUFFER_EXT, blit_ctx->fb_id); glBindFramebuffer(GL_FRAMEBUFFER_EXT, blit_ctx->fb_id);
vrend_fb_bind_texture(dst_res, 0, info->dst.level, info->dst.box.z); vrend_fb_bind_texture(dst_res, 0, info->dst.level, info->dst.box.z);
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
glBindTexture(src_res->target, src_res->id); glBindTexture(src_res->target, src_res->id);
glTexParameteri(src_res->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(src_res->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(src_res->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(src_res->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(src_res->target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); glTexParameteri(src_res->target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTexParameteri(src_res->target, GL_TEXTURE_BASE_LEVEL, info->src.level); glTexParameteri(src_res->target, GL_TEXTURE_BASE_LEVEL, info->src.level);
glTexParameteri(src_res->target, GL_TEXTURE_MAX_LEVEL, info->src.level); glTexParameteri(src_res->target, GL_TEXTURE_MAX_LEVEL, info->src.level);
glTexParameterf(src_res->target, GL_TEXTURE_MAG_FILTER, filter); glTexParameterf(src_res->target, GL_TEXTURE_MAG_FILTER, filter);
glTexParameterf(src_res->target, GL_TEXTURE_MIN_FILTER, filter); glTexParameterf(src_res->target, GL_TEXTURE_MIN_FILTER, filter);
pos_loc = glGetAttribLocation(prog_id, "arg0"); pos_loc = glGetAttribLocation(prog_id, "arg0");
tc_loc = glGetAttribLocation(prog_id, "arg1"); tc_loc = glGetAttribLocation(prog_id, "arg1");
samp_loc = glGetUniformLocation(prog_id, "samp"); samp_loc = glGetUniformLocation(prog_id, "samp");
glUniform1i(samp_loc, 0); glUniform1i(samp_loc, 0);
glVertexAttribPointer(pos_loc, 4, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void *)0); glVertexAttribPointer(pos_loc, 4, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void *)0);
glVertexAttribPointer(tc_loc, 4, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void *)(4 * sizeof(float))); glVertexAttribPointer(tc_loc, 4, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void *)(4 * sizeof(float)));
glEnableVertexAttribArray(pos_loc); glEnableVertexAttribArray(pos_loc);
glEnableVertexAttribArray(tc_loc); glEnableVertexAttribArray(tc_loc);
set_dsa_write_depth_keep_stencil(); set_dsa_write_depth_keep_stencil();
for (dst_z = 0; dst_z < info->dst.box.depth; dst_z++) { for (dst_z = 0; dst_z < info->dst.box.depth; dst_z++) {
float dst2src_scale = info->src.box.depth / (float)info->dst.box.depth; float dst2src_scale = info->src.box.depth / (float)info->dst.box.depth;
float dst_offset = ((info->src.box.depth - 1) - float dst_offset = ((info->src.box.depth - 1) -
(info->dst.box.depth - 1) * dst2src_scale) * 0.5; (info->dst.box.depth - 1) * dst2src_scale) * 0.5;
float src_z = (dst_z + dst_offset) * dst2src_scale; float src_z = (dst_z + dst_offset) * dst2src_scale;
glBindFramebuffer(GL_FRAMEBUFFER_EXT, blit_ctx->fb_id); glBindFramebuffer(GL_FRAMEBUFFER_EXT, blit_ctx->fb_id);
vrend_fb_bind_texture(dst_res, 0, info->dst.level, dst_z); vrend_fb_bind_texture(dst_res, 0, info->dst.level, dst_z);
glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
blitter_set_texcoords(blit_ctx, src_res, info->src.level, blitter_set_texcoords(blit_ctx, src_res, info->src.level,
info->src.box.z + src_z, 0, info->src.box.z + src_z, 0,
info->src.box.x, info->src.box.y, info->src.box.x, info->src.box.y,
info->src.box.x + info->src.box.width, info->src.box.x + info->src.box.width,
info->src.box.y + info->src.box.height); info->src.box.y + info->src.box.height);
glBufferData(GL_ARRAY_BUFFER, sizeof(blit_ctx->vertices), blit_ctx->vertices, GL_STATIC_DRAW); glBufferData(GL_ARRAY_BUFFER, sizeof(blit_ctx->vertices), blit_ctx->vertices, GL_STATIC_DRAW);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
} }
} }

@ -1,5 +1,28 @@
#ifndef VREND_BLITTER /**************************************************************************
#define VREND_BLITTER *
* Copyright (C) 2014 Red Hat Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#ifndef VREND_BLITTER_H
#define VREND_BLITTER_H
/* shaders for blitting */ /* shaders for blitting */

@ -62,8 +62,8 @@ static inline void *get_buf_ptr(struct vrend_decode_ctx *ctx,
} }
static int vrend_decode_create_shader(struct vrend_decode_ctx *ctx, uint32_t type, static int vrend_decode_create_shader(struct vrend_decode_ctx *ctx, uint32_t type,
uint32_t handle, uint32_t handle,
uint16_t length) uint16_t length)
{ {
struct pipe_shader_state *state; struct pipe_shader_state *state;
struct tgsi_token *tokens; struct tgsi_token *tokens;
@ -96,12 +96,12 @@ static int vrend_decode_create_shader(struct vrend_decode_ctx *ctx, uint32_t typ
state->stream_output.stride[i] = get_buf_entry(ctx, VIRGL_OBJ_SHADER_SO_STRIDE(i)); state->stream_output.stride[i] = get_buf_entry(ctx, VIRGL_OBJ_SHADER_SO_STRIDE(i));
for (i = 0; i < state->stream_output.num_outputs; i++) { for (i = 0; i < state->stream_output.num_outputs; i++) {
uint32_t tmp = get_buf_entry(ctx, VIRGL_OBJ_SHADER_SO_OUTPUT0(i)); uint32_t tmp = get_buf_entry(ctx, VIRGL_OBJ_SHADER_SO_OUTPUT0(i));
state->stream_output.output[i].register_index = tmp & 0xff; state->stream_output.output[i].register_index = tmp & 0xff;
state->stream_output.output[i].start_component = (tmp >> 8) & 0x3; state->stream_output.output[i].start_component = (tmp >> 8) & 0x3;
state->stream_output.output[i].num_components = (tmp >> 10) & 0x7; state->stream_output.output[i].num_components = (tmp >> 10) & 0x7;
state->stream_output.output[i].output_buffer = (tmp >> 13) & 0x7; state->stream_output.output[i].output_buffer = (tmp >> 13) & 0x7;
state->stream_output.output[i].dst_offset = (tmp >> 16) & 0xffff; state->stream_output.output[i].dst_offset = (tmp >> 16) & 0xffff;
} }
shader_offset = 8 + state->stream_output.num_outputs; shader_offset = 8 + state->stream_output.num_outputs;
} else } else
@ -207,7 +207,7 @@ static int vrend_decode_set_viewport_state(struct vrend_decode_ctx *ctx, int len
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
vps[v].translate[i] = uif(get_buf_entry(ctx, VIRGL_SET_VIEWPORT_STATE_TRANSLATE_0(v) + i)); vps[v].translate[i] = uif(get_buf_entry(ctx, VIRGL_SET_VIEWPORT_STATE_TRANSLATE_0(v) + i));
} }
vrend_set_viewport_states(ctx->grctx, start_slot, num_viewports, vps); vrend_set_viewport_states(ctx->grctx, start_slot, num_viewports, vps);
return 0; return 0;
} }
@ -263,8 +263,8 @@ static int vrend_decode_set_vertex_buffers(struct vrend_decode_ctx *ctx, uint16_
num_vbo = (length / 3); num_vbo = (length / 3);
if (num_vbo > PIPE_MAX_ATTRIBS) if (num_vbo > PIPE_MAX_ATTRIBS)
return EINVAL; return EINVAL;
for (i = 0; i < num_vbo; i++) { for (i = 0; i < num_vbo; i++) {
vrend_set_single_vbo(ctx->grctx, i, vrend_set_single_vbo(ctx->grctx, i,
get_buf_entry(ctx, VIRGL_SET_VERTEX_BUFFER_STRIDE(i)), get_buf_entry(ctx, VIRGL_SET_VERTEX_BUFFER_STRIDE(i)),
@ -307,7 +307,7 @@ static int vrend_decode_resource_inline_write(struct vrend_decode_ctx *ctx, uint
return EINVAL; return EINVAL;
if (length + ctx->ds->buf_offset > ctx->ds->buf_total) if (length + ctx->ds->buf_offset > ctx->ds->buf_total)
return EINVAL; return EINVAL;
res_handle = get_buf_entry(ctx, VIRGL_RESOURCE_IW_RES_HANDLE); res_handle = get_buf_entry(ctx, VIRGL_RESOURCE_IW_RES_HANDLE);
data_len = (length - 11) * 4; data_len = (length - 11) * 4;
@ -423,7 +423,7 @@ static int vrend_decode_create_dsa(struct vrend_decode_ctx *ctx, uint32_t handle
dsa_state = CALLOC_STRUCT(pipe_depth_stencil_alpha_state); dsa_state = CALLOC_STRUCT(pipe_depth_stencil_alpha_state);
if (!dsa_state) if (!dsa_state)
return ENOMEM; return ENOMEM;
tmp = get_buf_entry(ctx, VIRGL_OBJ_DSA_S0); tmp = get_buf_entry(ctx, VIRGL_OBJ_DSA_S0);
dsa_state->depth.enabled = tmp & 0x1; dsa_state->depth.enabled = tmp & 0x1;
dsa_state->depth.writemask = (tmp >> 1) & 0x1; dsa_state->depth.writemask = (tmp >> 1) & 0x1;
@ -510,9 +510,9 @@ static int vrend_decode_create_rasterizer(struct vrend_decode_ctx *ctx, uint32_t
rs_state->offset_units = uif(get_buf_entry(ctx, VIRGL_OBJ_RS_OFFSET_UNITS)); rs_state->offset_units = uif(get_buf_entry(ctx, VIRGL_OBJ_RS_OFFSET_UNITS));
rs_state->offset_scale = uif(get_buf_entry(ctx, VIRGL_OBJ_RS_OFFSET_SCALE)); rs_state->offset_scale = uif(get_buf_entry(ctx, VIRGL_OBJ_RS_OFFSET_SCALE));
rs_state->offset_clamp = uif(get_buf_entry(ctx, VIRGL_OBJ_RS_OFFSET_CLAMP)); rs_state->offset_clamp = uif(get_buf_entry(ctx, VIRGL_OBJ_RS_OFFSET_CLAMP));
tmp = vrend_renderer_object_insert(ctx->grctx, rs_state, sizeof(struct pipe_rasterizer_state), handle, tmp = vrend_renderer_object_insert(ctx->grctx, rs_state, sizeof(struct pipe_rasterizer_state), handle,
VIRGL_OBJECT_RASTERIZER); VIRGL_OBJECT_RASTERIZER);
if (tmp == 0) { if (tmp == 0) {
FREE(rs_state); FREE(rs_state);
return ENOMEM; return ENOMEM;
@ -527,7 +527,7 @@ static int vrend_decode_create_surface(struct vrend_decode_ctx *ctx, uint32_t ha
if (length != VIRGL_OBJ_SURFACE_SIZE) if (length != VIRGL_OBJ_SURFACE_SIZE)
return EINVAL; return EINVAL;
res_handle = get_buf_entry(ctx, VIRGL_OBJ_SURFACE_RES_HANDLE); res_handle = get_buf_entry(ctx, VIRGL_OBJ_SURFACE_RES_HANDLE);
format = get_buf_entry(ctx, VIRGL_OBJ_SURFACE_FORMAT); format = get_buf_entry(ctx, VIRGL_OBJ_SURFACE_FORMAT);
/* decide later if these are texture or buffer */ /* decide later if these are texture or buffer */
@ -543,7 +543,7 @@ static int vrend_decode_create_sampler_view(struct vrend_decode_ctx *ctx, uint32
if (length != VIRGL_OBJ_SAMPLER_VIEW_SIZE) if (length != VIRGL_OBJ_SAMPLER_VIEW_SIZE)
return EINVAL; return EINVAL;
res_handle = get_buf_entry(ctx, VIRGL_OBJ_SAMPLER_VIEW_RES_HANDLE); res_handle = get_buf_entry(ctx, VIRGL_OBJ_SAMPLER_VIEW_RES_HANDLE);
format = get_buf_entry(ctx, VIRGL_OBJ_SAMPLER_VIEW_FORMAT); format = get_buf_entry(ctx, VIRGL_OBJ_SAMPLER_VIEW_FORMAT);
val0 = get_buf_entry(ctx, VIRGL_OBJ_SAMPLER_VIEW_BUFFER_FIRST_ELEMENT); val0 = get_buf_entry(ctx, VIRGL_OBJ_SAMPLER_VIEW_BUFFER_FIRST_ELEMENT);
@ -595,17 +595,17 @@ static int vrend_decode_create_ve(struct vrend_decode_ctx *ctx, uint32_t handle,
num_elements = (length - 1) / 4; num_elements = (length - 1) / 4;
if (num_elements) { if (num_elements) {
ve = calloc(num_elements, sizeof(struct pipe_vertex_element)); ve = calloc(num_elements, sizeof(struct pipe_vertex_element));
if (!ve) if (!ve)
return ENOMEM; return ENOMEM;
for (i = 0; i < num_elements; i++) { for (i = 0; i < num_elements; i++) {
ve[i].src_offset = get_buf_entry(ctx, VIRGL_OBJ_VERTEX_ELEMENTS_V0_SRC_OFFSET(i)); ve[i].src_offset = get_buf_entry(ctx, VIRGL_OBJ_VERTEX_ELEMENTS_V0_SRC_OFFSET(i));
ve[i].instance_divisor = get_buf_entry(ctx, VIRGL_OBJ_VERTEX_ELEMENTS_V0_INSTANCE_DIVISOR(i)); ve[i].instance_divisor = get_buf_entry(ctx, VIRGL_OBJ_VERTEX_ELEMENTS_V0_INSTANCE_DIVISOR(i));
ve[i].vertex_buffer_index = get_buf_entry(ctx, VIRGL_OBJ_VERTEX_ELEMENTS_V0_VERTEX_BUFFER_INDEX(i)); ve[i].vertex_buffer_index = get_buf_entry(ctx, VIRGL_OBJ_VERTEX_ELEMENTS_V0_VERTEX_BUFFER_INDEX(i));
ve[i].src_format = get_buf_entry(ctx, VIRGL_OBJ_VERTEX_ELEMENTS_V0_SRC_FORMAT(i)); ve[i].src_format = get_buf_entry(ctx, VIRGL_OBJ_VERTEX_ELEMENTS_V0_SRC_FORMAT(i));
} }
} }
ret = vrend_create_vertex_elements_state(ctx->grctx, handle, num_elements, ve); ret = vrend_create_vertex_elements_state(ctx->grctx, handle, num_elements, ve);
@ -622,7 +622,7 @@ static int vrend_decode_create_query(struct vrend_decode_ctx *ctx, uint32_t hand
if (length != VIRGL_OBJ_QUERY_SIZE) if (length != VIRGL_OBJ_QUERY_SIZE)
return EINVAL; return EINVAL;
query_type = get_buf_entry(ctx, VIRGL_OBJ_QUERY_TYPE); query_type = get_buf_entry(ctx, VIRGL_OBJ_QUERY_TYPE);
offset = get_buf_entry(ctx, VIRGL_OBJ_QUERY_OFFSET); offset = get_buf_entry(ctx, VIRGL_OBJ_QUERY_OFFSET);
res_handle = get_buf_entry(ctx, VIRGL_OBJ_QUERY_RES_HANDLE); res_handle = get_buf_entry(ctx, VIRGL_OBJ_QUERY_RES_HANDLE);
@ -638,7 +638,7 @@ static int vrend_decode_create_object(struct vrend_decode_ctx *ctx, int length)
int ret = 0; int ret = 0;
if (length < 1) if (length < 1)
return EINVAL; return EINVAL;
switch (obj_type){ switch (obj_type){
case VIRGL_OBJECT_BLEND: case VIRGL_OBJECT_BLEND:
@ -736,7 +736,7 @@ static int vrend_decode_set_stencil_ref(struct vrend_decode_ctx *ctx, int length
if (length != VIRGL_SET_STENCIL_REF_SIZE) if (length != VIRGL_SET_STENCIL_REF_SIZE)
return EINVAL; return EINVAL;
ref.ref_value[0] = val & 0xff; ref.ref_value[0] = val & 0xff;
ref.ref_value[1] = (val >> 8) & 0xff; ref.ref_value[1] = (val >> 8) & 0xff;
vrend_set_stencil_ref(ctx->grctx, &ref); vrend_set_stencil_ref(ctx->grctx, &ref);
@ -750,7 +750,7 @@ static int vrend_decode_set_blend_color(struct vrend_decode_ctx *ctx, int length
if (length != VIRGL_SET_BLEND_COLOR_SIZE) if (length != VIRGL_SET_BLEND_COLOR_SIZE)
return EINVAL; return EINVAL;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
color.color[i] = uif(get_buf_entry(ctx, VIRGL_SET_BLEND_COLOR(i))); color.color[i] = uif(get_buf_entry(ctx, VIRGL_SET_BLEND_COLOR(i)));
@ -840,7 +840,7 @@ static int vrend_decode_resource_copy_region(struct vrend_decode_ctx *ctx, int l
if (length != VIRGL_CMD_RESOURCE_COPY_REGION_SIZE) if (length != VIRGL_CMD_RESOURCE_COPY_REGION_SIZE)
return EINVAL; return EINVAL;
dst_handle = get_buf_entry(ctx, VIRGL_CMD_RCR_DST_RES_HANDLE); dst_handle = get_buf_entry(ctx, VIRGL_CMD_RCR_DST_RES_HANDLE);
dst_level = get_buf_entry(ctx, VIRGL_CMD_RCR_DST_LEVEL); dst_level = get_buf_entry(ctx, VIRGL_CMD_RCR_DST_LEVEL);
dstx = get_buf_entry(ctx, VIRGL_CMD_RCR_DST_X); dstx = get_buf_entry(ctx, VIRGL_CMD_RCR_DST_X);
@ -856,9 +856,9 @@ static int vrend_decode_resource_copy_region(struct vrend_decode_ctx *ctx, int l
box.depth = get_buf_entry(ctx, VIRGL_CMD_RCR_SRC_D); box.depth = get_buf_entry(ctx, VIRGL_CMD_RCR_SRC_D);
vrend_renderer_resource_copy_region(ctx->grctx, dst_handle, vrend_renderer_resource_copy_region(ctx->grctx, dst_handle,
dst_level, dstx, dsty, dstz, dst_level, dstx, dsty, dstz,
src_handle, src_level, src_handle, src_level,
&box); &box);
return 0; return 0;
} }
@ -1011,17 +1011,17 @@ static int vrend_decode_set_streamout_targets(struct vrend_decode_ctx *ctx,
} }
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)
{ {
struct vrend_decode_ctx *dctx; struct vrend_decode_ctx *dctx;
if (handle > VREND_MAX_CTX) if (handle > VREND_MAX_CTX)
return; return;
dctx = malloc(sizeof(struct vrend_decode_ctx)); dctx = malloc(sizeof(struct vrend_decode_ctx));
if (!dctx) if (!dctx)
return; return;
dctx->grctx = vrend_create_context(handle, nlen, debug_name); dctx->grctx = vrend_create_context(handle, nlen, debug_name);
if (!dctx->grctx) { if (!dctx->grctx) {
free(dctx); free(dctx);
@ -1055,13 +1055,13 @@ void vrend_renderer_context_destroy(uint32_t handle)
ctx = dec_ctx[handle]; ctx = dec_ctx[handle];
if (!ctx) if (!ctx)
return; return;
dec_ctx[handle] = NULL; dec_ctx[handle] = NULL;
ret = vrend_destroy_context(ctx->grctx); ret = vrend_destroy_context(ctx->grctx);
free(ctx); free(ctx);
/* switch to ctx 0 */ /* switch to ctx 0 */
if (ret && handle != 0) if (ret && handle != 0)
vrend_hw_switch_context(dec_ctx[0]->grctx, true); vrend_hw_switch_context(dec_ctx[0]->grctx, true);
} }
struct vrend_context *vrend_lookup_renderer_ctx(uint32_t ctx_id) struct vrend_context *vrend_lookup_renderer_ctx(uint32_t ctx_id)
@ -1107,7 +1107,7 @@ int vrend_decode_block(uint32_t ctx_id, uint32_t *block, int ndw)
break; break;
} }
// fprintf(stderr,"[%d] cmd is %d (obj %d) len %d\n", gdctx->ds->buf_offset, header & 0xff, (header >> 8 & 0xff), (len)); // fprintf(stderr,"[%d] cmd is %d (obj %d) len %d\n", gdctx->ds->buf_offset, header & 0xff, (header >> 8 & 0xff), (len));
switch (header & 0xff) { switch (header & 0xff) {
case VIRGL_CCMD_CREATE_OBJECT: case VIRGL_CCMD_CREATE_OBJECT:
ret = vrend_decode_create_object(gdctx, len); ret = vrend_decode_create_object(gdctx, len);
@ -1206,11 +1206,11 @@ int vrend_decode_block(uint32_t ctx_id, uint32_t *block, int ndw)
goto out; goto out;
} }
if (ret == ENOMEM) if (ret == ENOMEM)
goto out; goto out;
gdctx->ds->buf_offset += (len) + 1; gdctx->ds->buf_offset += (len) + 1;
} }
return 0; return 0;
out: out:
return ret; return ret;
} }
@ -1221,20 +1221,20 @@ void vrend_decode_reset(bool ctx_0_only)
vrend_hw_switch_context(dec_ctx[0]->grctx, true); vrend_hw_switch_context(dec_ctx[0]->grctx, true);
if (ctx_0_only == false) { if (ctx_0_only == false) {
for (i = 1; i < VREND_MAX_CTX; i++) { for (i = 1; i < VREND_MAX_CTX; i++) {
if (!dec_ctx[i]) if (!dec_ctx[i])
continue; continue;
if (!dec_ctx[i]->grctx) if (!dec_ctx[i]->grctx)
continue; continue;
vrend_destroy_context(dec_ctx[i]->grctx); vrend_destroy_context(dec_ctx[i]->grctx);
free(dec_ctx[i]); free(dec_ctx[i]);
dec_ctx[i] = NULL; dec_ctx[i] = NULL;
} }
} else { } else {
vrend_destroy_context(dec_ctx[0]->grctx); vrend_destroy_context(dec_ctx[0]->grctx);
free(dec_ctx[0]); free(dec_ctx[0]);
dec_ctx[0] = NULL; dec_ctx[0] = NULL;
} }
} }

@ -28,331 +28,331 @@
#include "util/u_format.h" #include "util/u_format.h"
/* fill the format table */ /* fill the format table */
static struct vrend_format_table base_rgba_formats[] = static struct vrend_format_table base_rgba_formats[] =
{ {
{ VIRGL_FORMAT_B8G8R8X8_UNORM, GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, 0 }, { VIRGL_FORMAT_B8G8R8X8_UNORM, GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, 0 },
{ VIRGL_FORMAT_B8G8R8A8_UNORM, GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, 0 }, { VIRGL_FORMAT_B8G8R8A8_UNORM, GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, 0 },
{ VIRGL_FORMAT_R8G8B8X8_UNORM, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, 0 }, { VIRGL_FORMAT_R8G8B8X8_UNORM, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, 0 },
{ VIRGL_FORMAT_R8G8B8A8_UNORM, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, 0 }, { VIRGL_FORMAT_R8G8B8A8_UNORM, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, 0 },
{ VIRGL_FORMAT_A8R8G8B8_UNORM, GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 0 }, { VIRGL_FORMAT_A8R8G8B8_UNORM, GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 0 },
{ VIRGL_FORMAT_X8R8G8B8_UNORM, GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 0 }, { VIRGL_FORMAT_X8R8G8B8_UNORM, GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 0 },
{ VIRGL_FORMAT_A8B8G8R8_UNORM, GL_RGBA8, GL_ABGR_EXT, GL_UNSIGNED_BYTE, 0}, { VIRGL_FORMAT_A8B8G8R8_UNORM, GL_RGBA8, GL_ABGR_EXT, GL_UNSIGNED_BYTE, 0},
{ VIRGL_FORMAT_B4G4R4A4_UNORM, GL_RGBA4, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV }, { VIRGL_FORMAT_B4G4R4A4_UNORM, GL_RGBA4, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV },
{ VIRGL_FORMAT_B4G4R4X4_UNORM, GL_RGBA4, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV }, { VIRGL_FORMAT_B4G4R4X4_UNORM, GL_RGBA4, GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV },
{ VIRGL_FORMAT_B5G5R5X1_UNORM, GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV }, { VIRGL_FORMAT_B5G5R5X1_UNORM, GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV },
{ VIRGL_FORMAT_B5G5R5A1_UNORM, GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV }, { VIRGL_FORMAT_B5G5R5A1_UNORM, GL_RGB5_A1, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV },
{ VIRGL_FORMAT_B5G6R5_UNORM, GL_RGB4, GL_RGB, GL_UNSIGNED_SHORT_5_6_5 }, { VIRGL_FORMAT_B5G6R5_UNORM, GL_RGB4, GL_RGB, GL_UNSIGNED_SHORT_5_6_5 },
{ VIRGL_FORMAT_B2G3R3_UNORM, GL_R3_G3_B2, GL_RGB, GL_UNSIGNED_BYTE_3_3_2 }, { VIRGL_FORMAT_B2G3R3_UNORM, GL_R3_G3_B2, GL_RGB, GL_UNSIGNED_BYTE_3_3_2 },
{ VIRGL_FORMAT_R16G16B16X16_UNORM, GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT }, { VIRGL_FORMAT_R16G16B16X16_UNORM, GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT },
{ VIRGL_FORMAT_R16G16B16A16_UNORM, GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT }, { VIRGL_FORMAT_R16G16B16A16_UNORM, GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT },
}; };
static struct vrend_format_table base_depth_formats[] = static struct vrend_format_table base_depth_formats[] =
{ {
{ VIRGL_FORMAT_Z16_UNORM, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, 0 }, { VIRGL_FORMAT_Z16_UNORM, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, 0 },
{ VIRGL_FORMAT_Z32_UNORM, GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 0 }, { VIRGL_FORMAT_Z32_UNORM, GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, 0 },
{ VIRGL_FORMAT_S8_UINT_Z24_UNORM, GL_DEPTH24_STENCIL8_EXT, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 0 }, { VIRGL_FORMAT_S8_UINT_Z24_UNORM, GL_DEPTH24_STENCIL8_EXT, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 0 },
{ VIRGL_FORMAT_Z24X8_UNORM, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT }, { VIRGL_FORMAT_Z24X8_UNORM, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT },
{ VIRGL_FORMAT_Z32_FLOAT, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT }, { VIRGL_FORMAT_Z32_FLOAT, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT },
/* this is probably a separate format */ /* this is probably a separate format */
{ VIRGL_FORMAT_Z32_FLOAT_S8X24_UINT, GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV}, { VIRGL_FORMAT_Z32_FLOAT_S8X24_UINT, GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV},
}; };
static struct vrend_format_table base_la_formats[] = { static struct vrend_format_table base_la_formats[] = {
{ VIRGL_FORMAT_A8_UNORM, GL_ALPHA8, GL_ALPHA, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_A8_UNORM, GL_ALPHA8, GL_ALPHA, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_L8_UNORM, GL_LUMINANCE8, GL_LUMINANCE, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_L8_UNORM, GL_LUMINANCE8, GL_LUMINANCE, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_L8A8_UNORM, GL_LUMINANCE8_ALPHA8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_L8A8_UNORM, GL_LUMINANCE8_ALPHA8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_A16_UNORM, GL_ALPHA16, GL_ALPHA, GL_UNSIGNED_SHORT }, { VIRGL_FORMAT_A16_UNORM, GL_ALPHA16, GL_ALPHA, GL_UNSIGNED_SHORT },
{ VIRGL_FORMAT_L16_UNORM, GL_LUMINANCE16, GL_LUMINANCE, GL_UNSIGNED_SHORT }, { VIRGL_FORMAT_L16_UNORM, GL_LUMINANCE16, GL_LUMINANCE, GL_UNSIGNED_SHORT },
{ VIRGL_FORMAT_L16A16_UNORM, GL_LUMINANCE16_ALPHA16, GL_LUMINANCE_ALPHA, GL_UNSIGNED_SHORT }, { VIRGL_FORMAT_L16A16_UNORM, GL_LUMINANCE16_ALPHA16, GL_LUMINANCE_ALPHA, GL_UNSIGNED_SHORT },
}; };
static struct vrend_format_table rg_base_formats[] = { static struct vrend_format_table rg_base_formats[] = {
{ VIRGL_FORMAT_R8_UNORM, GL_R8, GL_RED, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_R8_UNORM, GL_R8, GL_RED, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_R8G8_UNORM, GL_RG8, GL_RG, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_R8G8_UNORM, GL_RG8, GL_RG, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_R16_UNORM, GL_R16, GL_RED, GL_UNSIGNED_SHORT }, { VIRGL_FORMAT_R16_UNORM, GL_R16, GL_RED, GL_UNSIGNED_SHORT },
{ VIRGL_FORMAT_R16G16_UNORM, GL_RG16, GL_RG, GL_UNSIGNED_SHORT }, { VIRGL_FORMAT_R16G16_UNORM, GL_RG16, GL_RG, GL_UNSIGNED_SHORT },
}; };
static struct vrend_format_table integer_base_formats[] = { static struct vrend_format_table integer_base_formats[] = {
{ VIRGL_FORMAT_R8G8B8A8_UINT, GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_R8G8B8A8_UINT, GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_R8G8B8A8_SINT, GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE }, { VIRGL_FORMAT_R8G8B8A8_SINT, GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE },
{ VIRGL_FORMAT_R16G16B16A16_UINT, GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT }, { VIRGL_FORMAT_R16G16B16A16_UINT, GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT },
{ VIRGL_FORMAT_R16G16B16A16_SINT, GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT }, { VIRGL_FORMAT_R16G16B16A16_SINT, GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT },
{ VIRGL_FORMAT_R32G32B32A32_UINT, GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT }, { VIRGL_FORMAT_R32G32B32A32_UINT, GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT },
{ VIRGL_FORMAT_R32G32B32A32_SINT, GL_RGBA32I, GL_RGBA_INTEGER, GL_INT }, { VIRGL_FORMAT_R32G32B32A32_SINT, GL_RGBA32I, GL_RGBA_INTEGER, GL_INT },
}; };
static struct vrend_format_table integer_3comp_formats[] = { static struct vrend_format_table integer_3comp_formats[] = {
{ VIRGL_FORMAT_R8G8B8_UINT, GL_RGB8UI, GL_RGB_INTEGER, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_R8G8B8_UINT, GL_RGB8UI, GL_RGB_INTEGER, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_R8G8B8_SINT, GL_RGB8I, GL_RGB_INTEGER, GL_BYTE }, { VIRGL_FORMAT_R8G8B8_SINT, GL_RGB8I, GL_RGB_INTEGER, GL_BYTE },
{ VIRGL_FORMAT_R16G16B16_UINT, GL_RGB16UI, GL_RGB_INTEGER, GL_UNSIGNED_SHORT }, { VIRGL_FORMAT_R16G16B16_UINT, GL_RGB16UI, GL_RGB_INTEGER, GL_UNSIGNED_SHORT },
{ VIRGL_FORMAT_R16G16B16_SINT, GL_RGB16I, GL_RGB_INTEGER, GL_SHORT }, { VIRGL_FORMAT_R16G16B16_SINT, GL_RGB16I, GL_RGB_INTEGER, GL_SHORT },
{ VIRGL_FORMAT_R32G32B32_UINT, GL_RGB32UI, GL_RGB_INTEGER, GL_UNSIGNED_INT }, { VIRGL_FORMAT_R32G32B32_UINT, GL_RGB32UI, GL_RGB_INTEGER, GL_UNSIGNED_INT },
{ VIRGL_FORMAT_R32G32B32_SINT, GL_RGB32I, GL_RGB_INTEGER, GL_INT }, { VIRGL_FORMAT_R32G32B32_SINT, GL_RGB32I, GL_RGB_INTEGER, GL_INT },
}; };
static struct vrend_format_table float_base_formats[] = { static struct vrend_format_table float_base_formats[] = {
{ VIRGL_FORMAT_R16G16B16A16_FLOAT, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT }, { VIRGL_FORMAT_R16G16B16A16_FLOAT, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT },
{ VIRGL_FORMAT_R32G32B32A32_FLOAT, GL_RGBA32F, GL_RGBA, GL_FLOAT }, { VIRGL_FORMAT_R32G32B32A32_FLOAT, GL_RGBA32F, GL_RGBA, GL_FLOAT },
}; };
static struct vrend_format_table float_la_formats[] = { static struct vrend_format_table float_la_formats[] = {
{ VIRGL_FORMAT_A16_FLOAT, GL_ALPHA16F_ARB, GL_ALPHA, GL_HALF_FLOAT }, { VIRGL_FORMAT_A16_FLOAT, GL_ALPHA16F_ARB, GL_ALPHA, GL_HALF_FLOAT },
{ VIRGL_FORMAT_L16_FLOAT, GL_LUMINANCE16F_ARB, GL_LUMINANCE, GL_HALF_FLOAT }, { VIRGL_FORMAT_L16_FLOAT, GL_LUMINANCE16F_ARB, GL_LUMINANCE, GL_HALF_FLOAT },
{ VIRGL_FORMAT_L16A16_FLOAT, GL_LUMINANCE_ALPHA16F_ARB, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT }, { VIRGL_FORMAT_L16A16_FLOAT, GL_LUMINANCE_ALPHA16F_ARB, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT },
{ VIRGL_FORMAT_A32_FLOAT, GL_ALPHA32F_ARB, GL_ALPHA, GL_FLOAT }, { VIRGL_FORMAT_A32_FLOAT, GL_ALPHA32F_ARB, GL_ALPHA, GL_FLOAT },
{ VIRGL_FORMAT_L32_FLOAT, GL_LUMINANCE32F_ARB, GL_LUMINANCE, GL_FLOAT }, { VIRGL_FORMAT_L32_FLOAT, GL_LUMINANCE32F_ARB, GL_LUMINANCE, GL_FLOAT },
{ VIRGL_FORMAT_L32A32_FLOAT, GL_LUMINANCE_ALPHA32F_ARB, GL_LUMINANCE_ALPHA, GL_FLOAT }, { VIRGL_FORMAT_L32A32_FLOAT, GL_LUMINANCE_ALPHA32F_ARB, GL_LUMINANCE_ALPHA, GL_FLOAT },
}; };
static struct vrend_format_table integer_rg_formats[] = { static struct vrend_format_table integer_rg_formats[] = {
{ VIRGL_FORMAT_R8_UINT, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_R8_UINT, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_R8G8_UINT, GL_RG8UI, GL_RG_INTEGER, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_R8G8_UINT, GL_RG8UI, GL_RG_INTEGER, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_R8_SINT, GL_R8I, GL_RED_INTEGER, GL_BYTE }, { VIRGL_FORMAT_R8_SINT, GL_R8I, GL_RED_INTEGER, GL_BYTE },
{ VIRGL_FORMAT_R8G8_SINT, GL_RG8I, GL_RG_INTEGER, GL_BYTE }, { VIRGL_FORMAT_R8G8_SINT, GL_RG8I, GL_RG_INTEGER, GL_BYTE },
{ VIRGL_FORMAT_R16_UINT, GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT }, { VIRGL_FORMAT_R16_UINT, GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT },
{ VIRGL_FORMAT_R16G16_UINT, GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT }, { VIRGL_FORMAT_R16G16_UINT, GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT },
{ VIRGL_FORMAT_R16_SINT, GL_R16I, GL_RED_INTEGER, GL_SHORT }, { VIRGL_FORMAT_R16_SINT, GL_R16I, GL_RED_INTEGER, GL_SHORT },
{ VIRGL_FORMAT_R16G16_SINT, GL_RG16I, GL_RG_INTEGER, GL_SHORT }, { VIRGL_FORMAT_R16G16_SINT, GL_RG16I, GL_RG_INTEGER, GL_SHORT },
{ VIRGL_FORMAT_R32_UINT, GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT }, { VIRGL_FORMAT_R32_UINT, GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT },
{ VIRGL_FORMAT_R32G32_UINT, GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT }, { VIRGL_FORMAT_R32G32_UINT, GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT },
{ VIRGL_FORMAT_R32_SINT, GL_R32I, GL_RED_INTEGER, GL_INT }, { VIRGL_FORMAT_R32_SINT, GL_R32I, GL_RED_INTEGER, GL_INT },
{ VIRGL_FORMAT_R32G32_SINT, GL_RG32I, GL_RG_INTEGER, GL_INT }, { VIRGL_FORMAT_R32G32_SINT, GL_RG32I, GL_RG_INTEGER, GL_INT },
}; };
static struct vrend_format_table float_rg_formats[] = { static struct vrend_format_table float_rg_formats[] = {
{ VIRGL_FORMAT_R16_FLOAT, GL_R16F, GL_RED, GL_HALF_FLOAT }, { VIRGL_FORMAT_R16_FLOAT, GL_R16F, GL_RED, GL_HALF_FLOAT },
{ VIRGL_FORMAT_R16G16_FLOAT, GL_RG16F, GL_RG, GL_HALF_FLOAT }, { VIRGL_FORMAT_R16G16_FLOAT, GL_RG16F, GL_RG, GL_HALF_FLOAT },
{ VIRGL_FORMAT_R32_FLOAT, GL_R32F, GL_RED, GL_FLOAT }, { VIRGL_FORMAT_R32_FLOAT, GL_R32F, GL_RED, GL_FLOAT },
{ VIRGL_FORMAT_R32G32_FLOAT, GL_RG32F, GL_RG, GL_FLOAT }, { VIRGL_FORMAT_R32G32_FLOAT, GL_RG32F, GL_RG, GL_FLOAT },
}; };
static struct vrend_format_table float_3comp_formats[] = { static struct vrend_format_table float_3comp_formats[] = {
{ VIRGL_FORMAT_R16G16B16_FLOAT, GL_RGB16F, GL_RGB, GL_HALF_FLOAT }, { VIRGL_FORMAT_R16G16B16_FLOAT, GL_RGB16F, GL_RGB, GL_HALF_FLOAT },
{ VIRGL_FORMAT_R32G32B32_FLOAT, GL_RGB32F, GL_RGB, GL_FLOAT }, { VIRGL_FORMAT_R32G32B32_FLOAT, GL_RGB32F, GL_RGB, GL_FLOAT },
}; };
static struct vrend_format_table integer_la_formats[] = { static struct vrend_format_table integer_la_formats[] = {
{ VIRGL_FORMAT_A8_UINT, GL_ALPHA8UI_EXT, GL_ALPHA_INTEGER, GL_UNSIGNED_BYTE}, { VIRGL_FORMAT_A8_UINT, GL_ALPHA8UI_EXT, GL_ALPHA_INTEGER, GL_UNSIGNED_BYTE},
{ VIRGL_FORMAT_L8_UINT, GL_LUMINANCE8UI_EXT, GL_LUMINANCE_INTEGER_EXT, GL_UNSIGNED_BYTE}, { VIRGL_FORMAT_L8_UINT, GL_LUMINANCE8UI_EXT, GL_LUMINANCE_INTEGER_EXT, GL_UNSIGNED_BYTE},
{ VIRGL_FORMAT_L8A8_UINT, GL_LUMINANCE_ALPHA8UI_EXT, GL_LUMINANCE_ALPHA_INTEGER_EXT, GL_UNSIGNED_BYTE}, { VIRGL_FORMAT_L8A8_UINT, GL_LUMINANCE_ALPHA8UI_EXT, GL_LUMINANCE_ALPHA_INTEGER_EXT, GL_UNSIGNED_BYTE},
{ VIRGL_FORMAT_A8_SINT, GL_ALPHA8I_EXT, GL_ALPHA_INTEGER, GL_BYTE}, { VIRGL_FORMAT_A8_SINT, GL_ALPHA8I_EXT, GL_ALPHA_INTEGER, GL_BYTE},
{ VIRGL_FORMAT_L8_SINT, GL_LUMINANCE8I_EXT, GL_LUMINANCE_INTEGER_EXT, GL_BYTE}, { VIRGL_FORMAT_L8_SINT, GL_LUMINANCE8I_EXT, GL_LUMINANCE_INTEGER_EXT, GL_BYTE},
{ VIRGL_FORMAT_L8A8_SINT, GL_LUMINANCE_ALPHA8I_EXT, GL_LUMINANCE_ALPHA_INTEGER_EXT, GL_BYTE}, { VIRGL_FORMAT_L8A8_SINT, GL_LUMINANCE_ALPHA8I_EXT, GL_LUMINANCE_ALPHA_INTEGER_EXT, GL_BYTE},
{ VIRGL_FORMAT_A16_UINT, GL_ALPHA16UI_EXT, GL_ALPHA_INTEGER, GL_UNSIGNED_SHORT}, { VIRGL_FORMAT_A16_UINT, GL_ALPHA16UI_EXT, GL_ALPHA_INTEGER, GL_UNSIGNED_SHORT},
{ VIRGL_FORMAT_L16_UINT, GL_LUMINANCE16UI_EXT, GL_LUMINANCE_INTEGER_EXT, GL_UNSIGNED_SHORT}, { VIRGL_FORMAT_L16_UINT, GL_LUMINANCE16UI_EXT, GL_LUMINANCE_INTEGER_EXT, GL_UNSIGNED_SHORT},
{ VIRGL_FORMAT_L16A16_UINT, GL_LUMINANCE_ALPHA16UI_EXT, GL_LUMINANCE_ALPHA_INTEGER_EXT, GL_UNSIGNED_SHORT}, { VIRGL_FORMAT_L16A16_UINT, GL_LUMINANCE_ALPHA16UI_EXT, GL_LUMINANCE_ALPHA_INTEGER_EXT, GL_UNSIGNED_SHORT},
{ VIRGL_FORMAT_A16_SINT, GL_ALPHA16I_EXT, GL_ALPHA_INTEGER, GL_SHORT}, { VIRGL_FORMAT_A16_SINT, GL_ALPHA16I_EXT, GL_ALPHA_INTEGER, GL_SHORT},
{ VIRGL_FORMAT_L16_SINT, GL_LUMINANCE16I_EXT, GL_LUMINANCE_INTEGER_EXT, GL_SHORT}, { VIRGL_FORMAT_L16_SINT, GL_LUMINANCE16I_EXT, GL_LUMINANCE_INTEGER_EXT, GL_SHORT},
{ VIRGL_FORMAT_L16A16_SINT, GL_LUMINANCE_ALPHA16I_EXT, GL_LUMINANCE_ALPHA_INTEGER_EXT, GL_SHORT}, { VIRGL_FORMAT_L16A16_SINT, GL_LUMINANCE_ALPHA16I_EXT, GL_LUMINANCE_ALPHA_INTEGER_EXT, GL_SHORT},
{ VIRGL_FORMAT_A32_UINT, GL_ALPHA32UI_EXT, GL_ALPHA_INTEGER, GL_UNSIGNED_INT}, { VIRGL_FORMAT_A32_UINT, GL_ALPHA32UI_EXT, GL_ALPHA_INTEGER, GL_UNSIGNED_INT},
{ VIRGL_FORMAT_L32_UINT, GL_LUMINANCE32UI_EXT, GL_LUMINANCE_INTEGER_EXT, GL_UNSIGNED_INT}, { VIRGL_FORMAT_L32_UINT, GL_LUMINANCE32UI_EXT, GL_LUMINANCE_INTEGER_EXT, GL_UNSIGNED_INT},
{ VIRGL_FORMAT_L32A32_UINT, GL_LUMINANCE_ALPHA32UI_EXT, GL_LUMINANCE_ALPHA_INTEGER_EXT, GL_UNSIGNED_INT}, { VIRGL_FORMAT_L32A32_UINT, GL_LUMINANCE_ALPHA32UI_EXT, GL_LUMINANCE_ALPHA_INTEGER_EXT, GL_UNSIGNED_INT},
{ VIRGL_FORMAT_A32_SINT, GL_ALPHA32I_EXT, GL_ALPHA_INTEGER, GL_INT}, { VIRGL_FORMAT_A32_SINT, GL_ALPHA32I_EXT, GL_ALPHA_INTEGER, GL_INT},
{ VIRGL_FORMAT_L32_SINT, GL_LUMINANCE32I_EXT, GL_LUMINANCE_INTEGER_EXT, GL_INT}, { VIRGL_FORMAT_L32_SINT, GL_LUMINANCE32I_EXT, GL_LUMINANCE_INTEGER_EXT, GL_INT},
{ VIRGL_FORMAT_L32A32_SINT, GL_LUMINANCE_ALPHA32I_EXT, GL_LUMINANCE_ALPHA_INTEGER_EXT, GL_INT}, { VIRGL_FORMAT_L32A32_SINT, GL_LUMINANCE_ALPHA32I_EXT, GL_LUMINANCE_ALPHA_INTEGER_EXT, GL_INT},
}; };
static struct vrend_format_table snorm_formats[] = { static struct vrend_format_table snorm_formats[] = {
{ VIRGL_FORMAT_R8_SNORM, GL_R8_SNORM, GL_RED, GL_BYTE }, { VIRGL_FORMAT_R8_SNORM, GL_R8_SNORM, GL_RED, GL_BYTE },
{ VIRGL_FORMAT_R8G8_SNORM, GL_RG8_SNORM, GL_RG, GL_BYTE }, { VIRGL_FORMAT_R8G8_SNORM, GL_RG8_SNORM, GL_RG, GL_BYTE },
{ VIRGL_FORMAT_R8G8B8A8_SNORM, GL_RGBA8_SNORM, GL_RGBA, GL_BYTE }, { VIRGL_FORMAT_R8G8B8A8_SNORM, GL_RGBA8_SNORM, GL_RGBA, GL_BYTE },
{ VIRGL_FORMAT_R8G8B8X8_SNORM, GL_RGBA8_SNORM, GL_RGBA, GL_BYTE }, { VIRGL_FORMAT_R8G8B8X8_SNORM, GL_RGBA8_SNORM, GL_RGBA, GL_BYTE },
{ VIRGL_FORMAT_R16_SNORM, GL_R16_SNORM, GL_RED, GL_SHORT }, { VIRGL_FORMAT_R16_SNORM, GL_R16_SNORM, GL_RED, GL_SHORT },
{ VIRGL_FORMAT_R16G16_SNORM, GL_RG16_SNORM, GL_RG, GL_SHORT }, { VIRGL_FORMAT_R16G16_SNORM, GL_RG16_SNORM, GL_RG, GL_SHORT },
{ VIRGL_FORMAT_R16G16B16A16_SNORM, GL_RGBA16_SNORM, GL_RGBA, GL_SHORT }, { VIRGL_FORMAT_R16G16B16A16_SNORM, GL_RGBA16_SNORM, GL_RGBA, GL_SHORT },
{ VIRGL_FORMAT_R16G16B16X16_SNORM, GL_RGBA16_SNORM, GL_RGBA, GL_SHORT }, { VIRGL_FORMAT_R16G16B16X16_SNORM, GL_RGBA16_SNORM, GL_RGBA, GL_SHORT },
}; };
static struct vrend_format_table snorm_la_formats[] = { static struct vrend_format_table snorm_la_formats[] = {
{ VIRGL_FORMAT_A8_SNORM, GL_ALPHA8_SNORM, GL_ALPHA, GL_BYTE }, { VIRGL_FORMAT_A8_SNORM, GL_ALPHA8_SNORM, GL_ALPHA, GL_BYTE },
{ VIRGL_FORMAT_L8_SNORM, GL_LUMINANCE8_SNORM, GL_LUMINANCE, GL_BYTE }, { VIRGL_FORMAT_L8_SNORM, GL_LUMINANCE8_SNORM, GL_LUMINANCE, GL_BYTE },
{ VIRGL_FORMAT_L8A8_SNORM, GL_LUMINANCE8_ALPHA8_SNORM, GL_LUMINANCE_ALPHA, GL_BYTE }, { VIRGL_FORMAT_L8A8_SNORM, GL_LUMINANCE8_ALPHA8_SNORM, GL_LUMINANCE_ALPHA, GL_BYTE },
{ VIRGL_FORMAT_A16_SNORM, GL_ALPHA16_SNORM, GL_ALPHA, GL_SHORT }, { VIRGL_FORMAT_A16_SNORM, GL_ALPHA16_SNORM, GL_ALPHA, GL_SHORT },
{ VIRGL_FORMAT_L16_SNORM, GL_LUMINANCE16_SNORM, GL_LUMINANCE, GL_SHORT }, { VIRGL_FORMAT_L16_SNORM, GL_LUMINANCE16_SNORM, GL_LUMINANCE, GL_SHORT },
{ VIRGL_FORMAT_L16A16_SNORM, GL_LUMINANCE16_ALPHA16_SNORM, GL_LUMINANCE_ALPHA, GL_SHORT }, { VIRGL_FORMAT_L16A16_SNORM, GL_LUMINANCE16_ALPHA16_SNORM, GL_LUMINANCE_ALPHA, GL_SHORT },
}; };
static struct vrend_format_table dxtn_formats[] = { static struct vrend_format_table dxtn_formats[] = {
{ VIRGL_FORMAT_DXT1_RGB, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_DXT1_RGB, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_DXT1_RGBA, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_RGBA, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_DXT1_RGBA, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_RGBA, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_DXT3_RGBA, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_DXT3_RGBA, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_DXT5_RGBA, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_DXT5_RGBA, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_BYTE },
}; };
static struct vrend_format_table dxtn_srgb_formats[] = { static struct vrend_format_table dxtn_srgb_formats[] = {
{ VIRGL_FORMAT_DXT1_SRGB, GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_DXT1_SRGB, GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_DXT1_SRGBA, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_RGBA, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_DXT1_SRGBA, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_RGBA, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_DXT3_SRGBA, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_DXT3_SRGBA, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_DXT5_SRGBA, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_DXT5_SRGBA, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_BYTE },
}; };
static struct vrend_format_table rgtc_formats[] = { static struct vrend_format_table rgtc_formats[] = {
{ VIRGL_FORMAT_RGTC1_UNORM, GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_RGTC1_UNORM, GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_RGTC1_SNORM, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_RED, GL_BYTE }, { VIRGL_FORMAT_RGTC1_SNORM, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_RED, GL_BYTE },
{ VIRGL_FORMAT_RGTC2_UNORM, GL_COMPRESSED_RG_RGTC2, GL_RG, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_RGTC2_UNORM, GL_COMPRESSED_RG_RGTC2, GL_RG, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_RGTC2_SNORM, GL_COMPRESSED_SIGNED_RG_RGTC2, GL_RG, GL_BYTE }, { VIRGL_FORMAT_RGTC2_SNORM, GL_COMPRESSED_SIGNED_RG_RGTC2, GL_RG, GL_BYTE },
}; };
static struct vrend_format_table srgb_formats[] = { static struct vrend_format_table srgb_formats[] = {
{ VIRGL_FORMAT_B8G8R8X8_SRGB, GL_SRGB8_ALPHA8, GL_BGRA, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_B8G8R8X8_SRGB, GL_SRGB8_ALPHA8, GL_BGRA, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_B8G8R8A8_SRGB, GL_SRGB8_ALPHA8, GL_BGRA, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_B8G8R8A8_SRGB, GL_SRGB8_ALPHA8, GL_BGRA, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_R8G8B8X8_SRGB, GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_R8G8B8X8_SRGB, GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_L8_SRGB, GL_SLUMINANCE8_EXT, GL_LUMINANCE, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_L8_SRGB, GL_SLUMINANCE8_EXT, GL_LUMINANCE, GL_UNSIGNED_BYTE },
{ VIRGL_FORMAT_L8A8_SRGB, GL_SLUMINANCE8_ALPHA8_EXT, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE }, { VIRGL_FORMAT_L8A8_SRGB, GL_SLUMINANCE8_ALPHA8_EXT, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE },
}; };
static struct vrend_format_table bit10_formats[] = { static struct vrend_format_table bit10_formats[] = {
{ VIRGL_FORMAT_B10G10R10X2_UNORM, GL_RGB10_A2, GL_BGRA, GL_UNSIGNED_INT_2_10_10_10_REV }, { VIRGL_FORMAT_B10G10R10X2_UNORM, GL_RGB10_A2, GL_BGRA, GL_UNSIGNED_INT_2_10_10_10_REV },
{ VIRGL_FORMAT_B10G10R10A2_UNORM, GL_RGB10_A2, GL_BGRA, GL_UNSIGNED_INT_2_10_10_10_REV }, { VIRGL_FORMAT_B10G10R10A2_UNORM, GL_RGB10_A2, GL_BGRA, GL_UNSIGNED_INT_2_10_10_10_REV },
{ VIRGL_FORMAT_B10G10R10A2_UINT, GL_RGB10_A2UI, GL_BGRA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV }, { VIRGL_FORMAT_B10G10R10A2_UINT, GL_RGB10_A2UI, GL_BGRA_INTEGER, GL_UNSIGNED_INT_2_10_10_10_REV },
}; };
static struct vrend_format_table packed_float_formats[] = { static struct vrend_format_table packed_float_formats[] = {
{ VIRGL_FORMAT_R11G11B10_FLOAT, GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV}, { VIRGL_FORMAT_R11G11B10_FLOAT, GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV},
}; };
static struct vrend_format_table exponent_float_formats[] = { static struct vrend_format_table exponent_float_formats[] = {
{ VIRGL_FORMAT_R9G9B9E5_FLOAT, GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV}, { VIRGL_FORMAT_R9G9B9E5_FLOAT, GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV},
}; };
static void vrend_add_formats(struct vrend_format_table *table, int num_entries) static void vrend_add_formats(struct vrend_format_table *table, int num_entries)
{ {
int i; int i;
uint32_t binding = 0; uint32_t binding = 0;
GLuint tex_id, fb_id; GLuint tex_id, fb_id;
for (i = 0; i < num_entries; i++) { for (i = 0; i < num_entries; i++) {
GLenum status; GLenum status;
bool is_depth = false; bool is_depth = false;
/**/ /**/
glGenTextures(1, &tex_id); glGenTextures(1, &tex_id);
glGenFramebuffers(1, &fb_id); glGenFramebuffers(1, &fb_id);
glBindTexture(GL_TEXTURE_2D, tex_id); glBindTexture(GL_TEXTURE_2D, tex_id);
glBindFramebuffer(GL_FRAMEBUFFER, fb_id); glBindFramebuffer(GL_FRAMEBUFFER, fb_id);
glTexImage2D(GL_TEXTURE_2D, 0, table[i].internalformat, 32, 32, 0, table[i].glformat, table[i].gltype, NULL); glTexImage2D(GL_TEXTURE_2D, 0, table[i].internalformat, 32, 32, 0, table[i].glformat, table[i].gltype, NULL);
status = glGetError(); status = glGetError();
if (status == GL_INVALID_VALUE) { if (status == GL_INVALID_VALUE) {
struct vrend_format_table *entry = NULL; struct vrend_format_table *entry = NULL;
uint8_t swizzle[4]; uint8_t swizzle[4];
binding = VREND_BIND_SAMPLER | VREND_BIND_NEED_SWIZZLE; binding = VREND_BIND_SAMPLER | VREND_BIND_NEED_SWIZZLE;
switch (table[i].format) { switch (table[i].format) {
case PIPE_FORMAT_A8_UNORM: case PIPE_FORMAT_A8_UNORM:
entry = &rg_base_formats[0]; entry = &rg_base_formats[0];
swizzle[0] = swizzle[1] = swizzle[2] = PIPE_SWIZZLE_ZERO; swizzle[0] = swizzle[1] = swizzle[2] = PIPE_SWIZZLE_ZERO;
swizzle[3] = PIPE_SWIZZLE_RED; swizzle[3] = PIPE_SWIZZLE_RED;
break; break;
case PIPE_FORMAT_A16_UNORM: case PIPE_FORMAT_A16_UNORM:
entry = &rg_base_formats[2]; entry = &rg_base_formats[2];
swizzle[0] = swizzle[1] = swizzle[2] = PIPE_SWIZZLE_ZERO; swizzle[0] = swizzle[1] = swizzle[2] = PIPE_SWIZZLE_ZERO;
swizzle[3] = PIPE_SWIZZLE_RED; swizzle[3] = PIPE_SWIZZLE_RED;
break; break;
default: default:
break; break;
}
if (entry) {
vrend_insert_format_swizzle(table[i].format, entry, binding, swizzle);
}
glDeleteTextures(1, &tex_id);
glDeleteFramebuffers(1, &fb_id);
continue;
} }
if (util_format_is_depth_or_stencil(table[i].format)) { if (entry) {
GLenum attachment; vrend_insert_format_swizzle(table[i].format, entry, binding, swizzle);
if (table[i].format == VIRGL_FORMAT_Z24X8_UNORM || table[i].format == VIRGL_FORMAT_Z32_UNORM || table[i].format == VIRGL_FORMAT_Z16_UNORM || table[i].format == VIRGL_FORMAT_Z32_FLOAT)
attachment = GL_DEPTH_ATTACHMENT;
else
attachment = GL_DEPTH_STENCIL_ATTACHMENT;
glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_2D, tex_id, 0);
is_depth = true;
glDrawBuffer(GL_NONE);
} else {
glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex_id, 0);
glDrawBuffer(GL_COLOR_ATTACHMENT0);
} }
status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
binding = VREND_BIND_SAMPLER;
if (status == GL_FRAMEBUFFER_COMPLETE)
binding |= (is_depth ? VREND_BIND_DEPTHSTENCIL : VREND_BIND_RENDER);
glDeleteTextures(1, &tex_id); glDeleteTextures(1, &tex_id);
glDeleteFramebuffers(1, &fb_id); glDeleteFramebuffers(1, &fb_id);
vrend_insert_format(&table[i], binding); continue;
} }
if (util_format_is_depth_or_stencil(table[i].format)) {
GLenum attachment;
if (table[i].format == VIRGL_FORMAT_Z24X8_UNORM || table[i].format == VIRGL_FORMAT_Z32_UNORM || table[i].format == VIRGL_FORMAT_Z16_UNORM || table[i].format == VIRGL_FORMAT_Z32_FLOAT)
attachment = GL_DEPTH_ATTACHMENT;
else
attachment = GL_DEPTH_STENCIL_ATTACHMENT;
glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, attachment, GL_TEXTURE_2D, tex_id, 0);
is_depth = true;
glDrawBuffer(GL_NONE);
} else {
glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex_id, 0);
glDrawBuffer(GL_COLOR_ATTACHMENT0);
}
status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
binding = VREND_BIND_SAMPLER;
if (status == GL_FRAMEBUFFER_COMPLETE)
binding |= (is_depth ? VREND_BIND_DEPTHSTENCIL : VREND_BIND_RENDER);
glDeleteTextures(1, &tex_id);
glDeleteFramebuffers(1, &fb_id);
vrend_insert_format(&table[i], binding);
}
} }
#define add_formats(x) vrend_add_formats((x), ARRAY_SIZE((x))) #define add_formats(x) vrend_add_formats((x), ARRAY_SIZE((x)))
void vrend_build_format_list(void) void vrend_build_format_list(void)
{ {
add_formats(base_rgba_formats); add_formats(base_rgba_formats);
add_formats(base_depth_formats); add_formats(base_depth_formats);
add_formats(base_la_formats); add_formats(base_la_formats);
/* float support */ /* float support */
add_formats(float_base_formats); add_formats(float_base_formats);
add_formats(float_la_formats); add_formats(float_la_formats);
add_formats(float_3comp_formats); add_formats(float_3comp_formats);
/* texture integer support ? */ /* texture integer support ? */
add_formats(integer_base_formats); add_formats(integer_base_formats);
add_formats(integer_la_formats); add_formats(integer_la_formats);
add_formats(integer_3comp_formats); add_formats(integer_3comp_formats);
/* RG support? */ /* RG support? */
add_formats(rg_base_formats); add_formats(rg_base_formats);
/* integer + rg */ /* integer + rg */
add_formats(integer_rg_formats); add_formats(integer_rg_formats);
/* float + rg */ /* float + rg */
add_formats(float_rg_formats); add_formats(float_rg_formats);
/* snorm */ /* snorm */
add_formats(snorm_formats); add_formats(snorm_formats);
add_formats(snorm_la_formats); add_formats(snorm_la_formats);
/* compressed */ /* compressed */
add_formats(rgtc_formats); add_formats(rgtc_formats);
add_formats(dxtn_formats); add_formats(dxtn_formats);
add_formats(dxtn_srgb_formats); add_formats(dxtn_srgb_formats);
add_formats(srgb_formats); add_formats(srgb_formats);
add_formats(bit10_formats); add_formats(bit10_formats);
add_formats(packed_float_formats); add_formats(packed_float_formats);
add_formats(exponent_float_formats); add_formats(exponent_float_formats);
} }

@ -34,7 +34,7 @@ struct vrend_object_types {
static void (*resource_unref)(void *); static void (*resource_unref)(void *);
void vrend_object_set_destroy_callback(int type, void (*cb)(void *)) void vrend_object_set_destroy_callback(int type, void (*cb)(void *))
{ {
obj_types[type].unref = cb; obj_types[type].unref = cb;
} }
@ -102,7 +102,7 @@ void vrend_object_fini_ctx_table(struct util_hash_table *ctx_hash)
{ {
if (!ctx_hash) if (!ctx_hash)
return; return;
util_hash_table_foreach(ctx_hash, free_cb, NULL); util_hash_table_foreach(ctx_hash, free_cb, NULL);
util_hash_table_destroy(ctx_hash); util_hash_table_destroy(ctx_hash);
} }
@ -166,12 +166,12 @@ vrend_object_remove(struct util_hash_table *handle_hash,
return; return;
util_hash_table_remove(handle_hash, intptr_to_pointer(handle)); util_hash_table_remove(handle_hash, intptr_to_pointer(handle));
vrend_object_free(obj); vrend_object_free(obj);
} }
void *vrend_object_lookup(struct util_hash_table *handle_hash, void *vrend_object_lookup(struct util_hash_table *handle_hash,
uint32_t handle, enum virgl_object_type type) uint32_t handle, enum virgl_object_type type)
{ {
struct vrend_object *obj; struct vrend_object *obj;

File diff suppressed because it is too large Load Diff

@ -79,15 +79,15 @@ struct vrend_format_table {
}; };
struct vrend_transfer_info { struct vrend_transfer_info {
uint32_t handle; uint32_t handle;
uint32_t ctx_id; uint32_t ctx_id;
int level; int level;
uint32_t stride; uint32_t stride;
uint32_t layer_stride; uint32_t layer_stride;
struct pipe_box *box; struct pipe_box *box;
uint64_t offset; uint64_t offset;
struct iovec *iovec; struct iovec *iovec;
unsigned int iovec_cnt; unsigned int iovec_cnt;
}; };
struct vrend_if_cbs { struct vrend_if_cbs {
@ -128,7 +128,7 @@ void vrend_draw_vbo(struct vrend_context *ctx,
void vrend_set_framebuffer_state(struct vrend_context *ctx, void vrend_set_framebuffer_state(struct vrend_context *ctx,
uint32_t nr_cbufs, uint32_t surf_handle[8], uint32_t nr_cbufs, uint32_t surf_handle[8],
uint32_t zsurf_handle); uint32_t zsurf_handle);
void vrend_flush(struct vrend_context *ctx); void vrend_flush(struct vrend_context *ctx);
@ -165,7 +165,7 @@ struct vrend_renderer_resource_create_args {
uint32_t nr_samples; uint32_t nr_samples;
uint32_t flags; uint32_t flags;
}; };
int vrend_renderer_resource_create(struct vrend_renderer_resource_create_args *args, struct iovec *iov, uint32_t num_iovs); int vrend_renderer_resource_create(struct vrend_renderer_resource_create_args *args, struct iovec *iov, uint32_t num_iovs);
void vrend_renderer_resource_unref(uint32_t handle); void vrend_renderer_resource_unref(uint32_t handle);
@ -202,12 +202,12 @@ void vrend_bind_vertex_elements_state(struct vrend_context *ctx,
uint32_t handle); uint32_t handle);
void vrend_set_single_vbo(struct vrend_context *ctx, void vrend_set_single_vbo(struct vrend_context *ctx,
int index, int index,
uint32_t stride, uint32_t stride,
uint32_t buffer_offset, uint32_t buffer_offset,
uint32_t res_handle); uint32_t res_handle);
void vrend_set_num_vbo(struct vrend_context *ctx, void vrend_set_num_vbo(struct vrend_context *ctx,
int num_vbo); int num_vbo);
int vrend_transfer_inline_write(struct vrend_context *ctx, int vrend_transfer_inline_write(struct vrend_context *ctx,
struct vrend_transfer_info *info, struct vrend_transfer_info *info,
@ -228,7 +228,7 @@ void vrend_set_single_sampler_view(struct vrend_context *ctx,
void vrend_object_bind_blend(struct vrend_context *ctx, void vrend_object_bind_blend(struct vrend_context *ctx,
uint32_t handle); uint32_t handle);
void vrend_object_bind_dsa(struct vrend_context *ctx, void vrend_object_bind_dsa(struct vrend_context *ctx,
uint32_t handle); uint32_t handle);
void vrend_object_bind_rasterizer(struct vrend_context *ctx, void vrend_object_bind_rasterizer(struct vrend_context *ctx,
uint32_t handle); uint32_t handle);
@ -248,14 +248,14 @@ void vrend_set_index_buffer(struct vrend_context *ctx,
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);
void vrend_renderer_resource_copy_region(struct vrend_context *ctx, void vrend_renderer_resource_copy_region(struct vrend_context *ctx,
uint32_t dst_handle, uint32_t dst_level, uint32_t dst_handle, uint32_t dst_level,
uint32_t dstx, uint32_t dsty, uint32_t dstz, uint32_t dstx, uint32_t dsty, uint32_t dstz,
uint32_t src_handle, uint32_t src_level, uint32_t src_handle, uint32_t src_level,
const struct pipe_box *src_box); const struct pipe_box *src_box);
void vrend_renderer_blit(struct vrend_context *ctx, void vrend_renderer_blit(struct vrend_context *ctx,
uint32_t dst_handle, uint32_t src_handle, uint32_t dst_handle, uint32_t src_handle,
const struct pipe_blit_info *info); const struct pipe_blit_info *info);
void vrend_set_stencil_ref(struct vrend_context *ctx, struct pipe_stencil_ref *ref); void vrend_set_stencil_ref(struct vrend_context *ctx, struct pipe_stencil_ref *ref);
void vrend_set_blend_color(struct vrend_context *ctx, struct pipe_blend_color *color); void vrend_set_blend_color(struct vrend_context *ctx, struct pipe_blend_color *color);
@ -280,16 +280,16 @@ void vrend_set_uniform_buffer(struct vrend_context *ctx, uint32_t shader,
uint32_t res_handle); uint32_t res_handle);
void vrend_transfer_write_return(void *data, uint32_t bytes, uint64_t offset, void vrend_transfer_write_return(void *data, uint32_t bytes, uint64_t offset,
struct iovec *iov, int iovec_cnt); struct iovec *iov, int iovec_cnt);
void vrend_transfer_write_tex_return(struct pipe_resource *res, void vrend_transfer_write_tex_return(struct pipe_resource *res,
struct pipe_box *box, struct pipe_box *box,
uint32_t level, uint32_t level,
uint32_t dst_stride, uint32_t dst_stride,
uint64_t offset, uint64_t offset,
struct iovec *iov, struct iovec *iov,
int num_iovs, int num_iovs,
void *myptr, int size, int invert); void *myptr, int size, int invert);
void vrend_renderer_fini(void); void vrend_renderer_fini(void);
@ -303,7 +303,7 @@ void vrend_renderer_check_queries(void);
bool vrend_hw_switch_context(struct vrend_context *ctx, bool now); bool vrend_hw_switch_context(struct vrend_context *ctx, bool now);
uint32_t vrend_renderer_object_insert(struct vrend_context *ctx, void *data, uint32_t vrend_renderer_object_insert(struct vrend_context *ctx, void *data,
uint32_t size, uint32_t handle, enum virgl_object_type type); uint32_t size, uint32_t handle, enum virgl_object_type type);
void vrend_renderer_object_destroy(struct vrend_context *ctx, uint32_t handle); void vrend_renderer_object_destroy(struct vrend_context *ctx, uint32_t handle);
int vrend_create_query(struct vrend_context *ctx, uint32_t handle, int vrend_create_query(struct vrend_context *ctx, uint32_t handle,
@ -321,10 +321,10 @@ void vrend_render_condition(struct vrend_context *ctx,
void *vrend_renderer_get_cursor_contents(uint32_t res_handle, uint32_t *width, uint32_t *height); void *vrend_renderer_get_cursor_contents(uint32_t res_handle, uint32_t *width, uint32_t *height);
void vrend_bind_va(GLuint vaoid); void vrend_bind_va(GLuint vaoid);
int vrend_renderer_flush_buffer_res(struct vrend_resource *res, int vrend_renderer_flush_buffer_res(struct vrend_resource *res,
struct pipe_box *box); struct pipe_box *box);
void vrend_renderer_fill_caps(uint32_t set, uint32_t version, void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
union virgl_caps *caps); union virgl_caps *caps);
GLint64 vrend_renderer_get_timestamp(void); GLint64 vrend_renderer_get_timestamp(void);
/* formats */ /* formats */
@ -350,7 +350,7 @@ vrend_resource_reference(struct vrend_resource **ptr, struct vrend_resource *tex
void vrend_renderer_force_ctx_0(void); void vrend_renderer_force_ctx_0(void);
void vrend_renderer_get_rect(int resource_id, struct iovec *iov, unsigned int num_iovs, void vrend_renderer_get_rect(int resource_id, struct iovec *iov, unsigned int num_iovs,
uint32_t offset, int x, int y, int width, int height); uint32_t offset, int x, int y, int width, int height);
void vrend_renderer_attach_res_ctx(int ctx_id, int resource_id); void vrend_renderer_attach_res_ctx(int ctx_id, int resource_id);
void vrend_renderer_detach_res_ctx(int ctx_id, int resource_id); void vrend_renderer_detach_res_ctx(int ctx_id, int resource_id);
@ -372,7 +372,7 @@ int vrend_renderer_resource_get_info(int res_handle,
#define VREND_CAP_SET 1 #define VREND_CAP_SET 1
void vrend_renderer_get_cap_set(uint32_t cap_set, uint32_t *max_ver, void vrend_renderer_get_cap_set(uint32_t cap_set, uint32_t *max_ver,
uint32_t *max_size); uint32_t *max_size);
void vrend_renderer_create_sub_ctx(struct vrend_context *ctx, int sub_ctx_id); void vrend_renderer_create_sub_ctx(struct vrend_context *ctx, int sub_ctx_id);
void vrend_renderer_destroy_sub_ctx(struct vrend_context *ctx, int sub_ctx_id); void vrend_renderer_destroy_sub_ctx(struct vrend_context *ctx, int sub_ctx_id);

@ -31,12 +31,6 @@
#include <errno.h> #include <errno.h>
#include "vrend_shader.h" #include "vrend_shader.h"
extern int vrend_dump_shaders; extern int vrend_dump_shaders;
/*
* TODO list
* loops
* DDX/DDY/TXD
* missing opcodes
*/
/* start convert of tgsi to glsl */ /* start convert of tgsi to glsl */
@ -101,7 +95,7 @@ struct dump_ctx {
int ubo_idx[32]; int ubo_idx[32];
int ubo_sizes[32]; int ubo_sizes[32];
int num_address; int num_address;
struct pipe_stream_output_info *so; struct pipe_stream_output_info *so;
char **so_names; char **so_names;
bool write_so_outputs[PIPE_MAX_SO_OUTPUTS]; bool write_so_outputs[PIPE_MAX_SO_OUTPUTS];
@ -180,7 +174,7 @@ static inline bool fs_emit_layout(struct dump_ctx *ctx)
if coord origin is 1 and invert is 0 - emit nothing (lower) if coord origin is 1 and invert is 0 - emit nothing (lower)
if coord_origin is 1 and invert is 1 - emit origin upper left */ if coord_origin is 1 and invert is 1 - emit origin upper left */
if (!(ctx->fs_coord_origin ^ ctx->key->invert_fs_origin)) if (!(ctx->fs_coord_origin ^ ctx->key->invert_fs_origin))
return true; return true;
return false; return false;
} }
@ -482,8 +476,8 @@ iter_declaration(struct tgsi_iterate_context *iter,
ctx->outputs[i].override_no_wm = true; ctx->outputs[i].override_no_wm = true;
ctx->outputs[i].is_int = true; ctx->outputs[i].is_int = true;
name_prefix = "gl_ViewportIndex"; name_prefix = "gl_ViewportIndex";
if (ctx->glsl_ver_required >= 140) if (ctx->glsl_ver_required >= 140)
ctx->has_viewport_idx = true; ctx->has_viewport_idx = true;
break; break;
} }
case TGSI_SEMANTIC_GENERIC: case TGSI_SEMANTIC_GENERIC:
@ -529,10 +523,10 @@ iter_declaration(struct tgsi_iterate_context *iter,
break; break;
case TGSI_FILE_CONSTANT: case TGSI_FILE_CONSTANT:
if (decl->Declaration.Dimension) { if (decl->Declaration.Dimension) {
if (ctx->num_ubo >= ARRAY_SIZE(ctx->ubo_idx)) { if (ctx->num_ubo >= ARRAY_SIZE(ctx->ubo_idx)) {
fprintf(stderr, "Number of uniforms exceeded, max is %lu\n", ARRAY_SIZE(ctx->ubo_idx)); fprintf(stderr, "Number of uniforms exceeded, max is %lu\n", ARRAY_SIZE(ctx->ubo_idx));
return FALSE; return FALSE;
} }
ctx->ubo_idx[ctx->num_ubo] = decl->Dim.Index2D; ctx->ubo_idx[ctx->num_ubo] = decl->Dim.Index2D;
ctx->ubo_sizes[ctx->num_ubo] = decl->Range.Last + 1; ctx->ubo_sizes[ctx->num_ubo] = decl->Range.Last + 1;
ctx->num_ubo++; ctx->num_ubo++;
@ -559,7 +553,7 @@ iter_declaration(struct tgsi_iterate_context *iter,
name_prefix = "gl_InstanceID"; name_prefix = "gl_InstanceID";
ctx->has_instanceid = true; ctx->has_instanceid = true;
} else if (decl->Semantic.Name == TGSI_SEMANTIC_VERTEXID) { } else if (decl->Semantic.Name == TGSI_SEMANTIC_VERTEXID) {
name_prefix = "gl_VertexID"; name_prefix = "gl_VertexID";
ctx->has_ints = true; ctx->has_ints = true;
} else { } else {
fprintf(stderr, "unsupported system value %d\n", decl->Semantic.Name); fprintf(stderr, "unsupported system value %d\n", decl->Semantic.Name);
@ -618,8 +612,8 @@ iter_immediate(
int first = ctx->num_imm; int first = ctx->num_imm;
if (first >= ARRAY_SIZE(ctx->imm)) { if (first >= ARRAY_SIZE(ctx->imm)) {
fprintf(stderr, "Number of immediates exceeded, max is: %lu\n", ARRAY_SIZE(ctx->imm)); fprintf(stderr, "Number of immediates exceeded, max is: %lu\n", ARRAY_SIZE(ctx->imm));
return FALSE; return FALSE;
} }
ctx->imm[first].type = imm->Immediate.DataType; ctx->imm[first].type = imm->Immediate.DataType;
@ -632,7 +626,7 @@ iter_immediate(
} else if (imm->Immediate.DataType == TGSI_IMM_INT32) { } else if (imm->Immediate.DataType == TGSI_IMM_INT32) {
ctx->has_ints = true; ctx->has_ints = true;
ctx->imm[first].val[i].i = imm->u[i].Int; ctx->imm[first].val[i].i = imm->u[i].Int;
} }
} }
ctx->num_imm++; ctx->num_imm++;
return TRUE; return TRUE;
@ -725,7 +719,7 @@ static int emit_prescale(struct dump_ctx *ctx)
{ {
char buf[255]; char buf[255];
char *sret; char *sret;
snprintf(buf, 255, "gl_Position.y = gl_Position.y * winsys_adjust.y;\n"); snprintf(buf, 255, "gl_Position.y = gl_Position.y * winsys_adjust.y;\n");
sret = add_str_to_glsl_main(ctx, buf); sret = add_str_to_glsl_main(ctx, buf);
if (!sret) if (!sret)
@ -763,13 +757,13 @@ static int emit_so_movs(struct dump_ctx *ctx)
writemask[0] = 0; writemask[0] = 0;
if (ctx->so->output[i].num_components == 4 && writemask[0] == 0 && !(ctx->outputs[ctx->so->output[i].register_index].name == TGSI_SEMANTIC_CLIPDIST) && !(ctx->outputs[ctx->so->output[i].register_index].name == TGSI_SEMANTIC_POSITION)) { if (ctx->so->output[i].num_components == 4 && writemask[0] == 0 && !(ctx->outputs[ctx->so->output[i].register_index].name == TGSI_SEMANTIC_CLIPDIST) && !(ctx->outputs[ctx->so->output[i].register_index].name == TGSI_SEMANTIC_POSITION)) {
if (ctx->so->output[i].register_index > ctx->num_outputs) if (ctx->so->output[i].register_index > ctx->num_outputs)
ctx->so_names[i] = NULL; ctx->so_names[i] = NULL;
else if (ctx->outputs[ctx->so->output[i].register_index].name == TGSI_SEMANTIC_CLIPVERTEX && ctx->has_clipvertex) { else if (ctx->outputs[ctx->so->output[i].register_index].name == TGSI_SEMANTIC_CLIPVERTEX && ctx->has_clipvertex) {
ctx->so_names[i] = strdup("clipv_tmp"); ctx->so_names[i] = strdup("clipv_tmp");
ctx->has_clipvertex_so = true; ctx->has_clipvertex_so = true;
} else } else
ctx->so_names[i] = strdup(ctx->outputs[ctx->so->output[i].register_index].glsl_name); ctx->so_names[i] = strdup(ctx->outputs[ctx->so->output[i].register_index].glsl_name);
ctx->write_so_outputs[i] = false; ctx->write_so_outputs[i] = false;
} else { } else {
@ -858,19 +852,19 @@ static int emit_buf(struct dump_ctx *ctx, char *buf)
return sret ? 0 : ENOMEM; return sret ? 0 : ENOMEM;
} }
#define EMIT_BUF_WITH_RET(ctx, buf) do { \ #define EMIT_BUF_WITH_RET(ctx, buf) do { \
int ret = emit_buf((ctx), (buf)); \ int ret = emit_buf((ctx), (buf)); \
if (ret) return FALSE; \ if (ret) return FALSE; \
} while(0) } while(0)
static int translate_tex(struct dump_ctx *ctx, static int translate_tex(struct dump_ctx *ctx,
struct tgsi_full_instruction *inst, struct tgsi_full_instruction *inst,
int sreg_index, int sreg_index,
char srcs[4][255], char srcs[4][255],
char dsts[3][255], char dsts[3][255],
const char *writemask, const char *writemask,
const char *dstconv, const char *dstconv,
const char *dtypeprefix) const char *dtypeprefix)
{ {
char *twm, *gwm = NULL, *txfi; char *twm, *gwm = NULL, *txfi;
bool is_shad = false; bool is_shad = false;
@ -929,12 +923,12 @@ static int translate_tex(struct dump_ctx *ctx,
/* need to emit a textureQueryLevels */ /* need to emit a textureQueryLevels */
if (inst->Dst[0].Register.WriteMask & 0x8) { if (inst->Dst[0].Register.WriteMask & 0x8) {
ctx->uses_txq_levels = true; ctx->uses_txq_levels = true;
snprintf(buf, 255, "%s = %s(%s(textureQueryLevels(%s)));\n", dsts[0], dstconv, dtypeprefix, srcs[sampler_index]); snprintf(buf, 255, "%s = %s(%s(textureQueryLevels(%s)));\n", dsts[0], dstconv, dtypeprefix, srcs[sampler_index]);
return emit_buf(ctx, buf); return emit_buf(ctx, buf);
} else { } else {
snprintf(buf, 255, "%s = %s(%s(textureSize(%s%s)));\n", dsts[0], dstconv, dtypeprefix, srcs[sampler_index], bias); snprintf(buf, 255, "%s = %s(%s(textureSize(%s%s)));\n", dsts[0], dstconv, dtypeprefix, srcs[sampler_index], bias);
return emit_buf(ctx, buf); return emit_buf(ctx, buf);
} }
} }
@ -1070,9 +1064,9 @@ static int translate_tex(struct dump_ctx *ctx,
tex_ext = "Grad"; tex_ext = "Grad";
} else if (inst->Instruction.Opcode == TGSI_OPCODE_TG4) { } else if (inst->Instruction.Opcode == TGSI_OPCODE_TG4) {
if (inst->Texture.NumOffsets == 1) if (inst->Texture.NumOffsets == 1)
tex_ext = "GatherOffset"; tex_ext = "GatherOffset";
else else
tex_ext = "Gather"; tex_ext = "Gather";
} else { } else {
if (inst->Texture.NumOffsets == 1) if (inst->Texture.NumOffsets == 1)
tex_ext = "Offset"; tex_ext = "Offset";
@ -1160,13 +1154,13 @@ iter_instruction(struct tgsi_iterate_context *iter,
} else { } else {
switch (dtype) { switch (dtype) {
case TGSI_TYPE_UNSIGNED: case TGSI_TYPE_UNSIGNED:
dtypeprefix = "uintBitsToFloat"; dtypeprefix = "uintBitsToFloat";
break; break;
case TGSI_TYPE_SIGNED: case TGSI_TYPE_SIGNED:
dtypeprefix = "intBitsToFloat"; dtypeprefix = "intBitsToFloat";
break; break;
default: default:
break; break;
} }
} }
@ -1216,8 +1210,8 @@ iter_instruction(struct tgsi_iterate_context *iter,
snprintf(udstconv, 6, "uvec%d", wm_idx-1); snprintf(udstconv, 6, "uvec%d", wm_idx-1);
} }
} else { } else {
snprintf(dstconv, 6, "vec4"); snprintf(dstconv, 6, "vec4");
snprintf(udstconv, 6, "uvec4"); snprintf(udstconv, 6, "uvec4");
} }
if (dst->Register.File == TGSI_FILE_OUTPUT) { if (dst->Register.File == TGSI_FILE_OUTPUT) {
for (j = 0; j < ctx->num_outputs; j++) { for (j = 0; j < ctx->num_outputs; j++) {
@ -1248,7 +1242,7 @@ iter_instruction(struct tgsi_iterate_context *iter,
snprintf(dsts[i], 255, "temps[%d]%s", dst->Register.Index, writemask); snprintf(dsts[i], 255, "temps[%d]%s", dst->Register.Index, writemask);
} }
} }
for (i = 0; i < inst->Instruction.NumSrcRegs; i++) { for (i = 0; i < inst->Instruction.NumSrcRegs; i++) {
const struct tgsi_full_src_register *src = &inst->Src[i]; const struct tgsi_full_src_register *src = &inst->Src[i];
char swizzle[8] = {0}; char swizzle[8] = {0};
@ -1256,7 +1250,7 @@ iter_instruction(struct tgsi_iterate_context *iter,
char arrayname[8] = {0}; char arrayname[8] = {0};
int swz_idx = 0, pre_idx = 0; int swz_idx = 0, pre_idx = 0;
boolean isabsolute = src->Register.Absolute; boolean isabsolute = src->Register.Absolute;
override_no_wm[i] = false; override_no_wm[i] = false;
if (isabsolute) if (isabsolute)
swizzle[swz_idx++] = ')'; swizzle[swz_idx++] = ')';
@ -1299,12 +1293,12 @@ iter_instruction(struct tgsi_iterate_context *iter,
snprintf(srcs[i], 255, "%s(vec4(intBitsToFloat(%s)))", stypeprefix, ctx->inputs[j].glsl_name); snprintf(srcs[i], 255, "%s(vec4(intBitsToFloat(%s)))", stypeprefix, ctx->inputs[j].glsl_name);
else if (ctx->inputs[j].name == TGSI_SEMANTIC_FACE) else if (ctx->inputs[j].name == TGSI_SEMANTIC_FACE)
snprintf(srcs[i], 255, "%s(%s ? 1.0 : -1.0)", stypeprefix, ctx->inputs[j].glsl_name); snprintf(srcs[i], 255, "%s(%s ? 1.0 : -1.0)", stypeprefix, ctx->inputs[j].glsl_name);
else if (ctx->inputs[j].name == TGSI_SEMANTIC_CLIPDIST) { else if (ctx->inputs[j].name == TGSI_SEMANTIC_CLIPDIST) {
int idx; int idx;
idx = ctx->inputs[j].sid * 4; idx = ctx->inputs[j].sid * 4;
idx += src->Register.SwizzleX; idx += src->Register.SwizzleX;
snprintf(srcs[i], 255, "%s(vec4(%s%s%s[%d]))", stypeprefix, prefix, arrayname, ctx->inputs[j].glsl_name, idx); snprintf(srcs[i], 255, "%s(vec4(%s%s%s[%d]))", stypeprefix, prefix, arrayname, ctx->inputs[j].glsl_name, idx);
} else } else
snprintf(srcs[i], 255, "%s(%s%s%s%s)", stypeprefix, prefix, ctx->inputs[j].glsl_name, arrayname, swizzle); snprintf(srcs[i], 255, "%s(%s%s%s%s)", stypeprefix, prefix, ctx->inputs[j].glsl_name, arrayname, swizzle);
override_no_wm[i] = ctx->inputs[j].override_no_wm; override_no_wm[i] = ctx->inputs[j].override_no_wm;
break; break;
@ -1316,33 +1310,33 @@ iter_instruction(struct tgsi_iterate_context *iter,
} else } else
snprintf(srcs[i], 255, "%s%c%stemps[%d]%s%c", stypeprefix, stprefix ? '(' : ' ', prefix, src->Register.Index, swizzle, stprefix ? ')' : ' '); snprintf(srcs[i], 255, "%s%c%stemps[%d]%s%c", stypeprefix, stprefix ? '(' : ' ', prefix, src->Register.Index, swizzle, stprefix ? ')' : ' ');
} else if (src->Register.File == TGSI_FILE_CONSTANT) { } else if (src->Register.File == TGSI_FILE_CONSTANT) {
const char *cname = tgsi_proc_to_prefix(ctx->prog_type); const char *cname = tgsi_proc_to_prefix(ctx->prog_type);
int dim = 0; int dim = 0;
if (src->Register.Dimension) { if (src->Register.Dimension) {
dim = src->Dimension.Index; dim = src->Dimension.Index;
if (src->Register.Indirect) { if (src->Register.Indirect) {
snprintf(srcs[i], 255, "%s(%s%subo%dcontents[addr0 + %d]%s)", stypeprefix, prefix, cname, dim, src->Register.Index, swizzle); snprintf(srcs[i], 255, "%s(%s%subo%dcontents[addr0 + %d]%s)", stypeprefix, prefix, cname, dim, src->Register.Index, swizzle);
} else } else
snprintf(srcs[i], 255, "%s(%s%subo%dcontents[%d]%s)", stypeprefix, prefix, cname, dim, src->Register.Index, swizzle); snprintf(srcs[i], 255, "%s(%s%subo%dcontents[%d]%s)", stypeprefix, prefix, cname, dim, src->Register.Index, swizzle);
} else { } else {
const char *csp; const char *csp;
ctx->has_ints = true; ctx->has_ints = true;
if (stype == TGSI_TYPE_FLOAT || stype == TGSI_TYPE_UNTYPED) if (stype == TGSI_TYPE_FLOAT || stype == TGSI_TYPE_UNTYPED)
csp = "uintBitsToFloat"; csp = "uintBitsToFloat";
else if (stype == TGSI_TYPE_SIGNED) else if (stype == TGSI_TYPE_SIGNED)
csp = "ivec4"; csp = "ivec4";
else else
csp = ""; csp = "";
if (src->Register.Indirect) { if (src->Register.Indirect) {
snprintf(srcs[i], 255, "%s%s(%sconst%d[addr0 + %d]%s)", prefix, csp, cname, dim, src->Register.Index, swizzle); snprintf(srcs[i], 255, "%s%s(%sconst%d[addr0 + %d]%s)", prefix, csp, cname, dim, src->Register.Index, swizzle);
} else } else
snprintf(srcs[i], 255, "%s%s(%sconst%d[%d]%s)", prefix, csp, cname, dim, src->Register.Index, swizzle); snprintf(srcs[i], 255, "%s%s(%sconst%d[%d]%s)", prefix, csp, cname, dim, src->Register.Index, swizzle);
} }
} else if (src->Register.File == TGSI_FILE_SAMPLER) { } else if (src->Register.File == TGSI_FILE_SAMPLER) {
const char *cname = tgsi_proc_to_prefix(ctx->prog_type); const char *cname = tgsi_proc_to_prefix(ctx->prog_type);
snprintf(srcs[i], 255, "%ssamp%d%s", cname, src->Register.Index, swizzle); snprintf(srcs[i], 255, "%ssamp%d%s", cname, src->Register.Index, swizzle);
sreg_index = src->Register.Index; sreg_index = src->Register.Index;
} else if (src->Register.File == TGSI_FILE_IMMEDIATE) { } else if (src->Register.File == TGSI_FILE_IMMEDIATE) {
struct immed *imd = &ctx->imm[(src->Register.Index)]; struct immed *imd = &ctx->imm[(src->Register.Index)];
int idx = src->Register.SwizzleX; int idx = src->Register.SwizzleX;
@ -1367,7 +1361,6 @@ iter_instruction(struct tgsi_iterate_context *iter,
imm_stypeprefix = "uintBitsToFloat"; imm_stypeprefix = "uintBitsToFloat";
} else if (stype == TGSI_TYPE_UNSIGNED || stype == TGSI_TYPE_SIGNED) } else if (stype == TGSI_TYPE_UNSIGNED || stype == TGSI_TYPE_SIGNED)
imm_stypeprefix = ""; imm_stypeprefix = "";
} }
/* build up a vec4 of immediates */ /* build up a vec4 of immediates */
@ -1519,7 +1512,7 @@ iter_instruction(struct tgsi_iterate_context *iter,
case TGSI_OPCODE_SCS: case TGSI_OPCODE_SCS:
snprintf(buf, 255, "%s = %s(vec4(cos(%s.x), sin(%s.x), 0, 1)%s);\n", dsts[0], dstconv, snprintf(buf, 255, "%s = %s(vec4(cos(%s.x), sin(%s.x), 0, 1)%s);\n", dsts[0], dstconv,
srcs[0], srcs[0], writemask); srcs[0], srcs[0], writemask);
EMIT_BUF_WITH_RET(ctx, buf); EMIT_BUF_WITH_RET(ctx, buf);
break; break;
case TGSI_OPCODE_DDX: case TGSI_OPCODE_DDX:
emit_op1("dFdx"); emit_op1("dFdx");
@ -1663,11 +1656,11 @@ iter_instruction(struct tgsi_iterate_context *iter,
EMIT_BUF_WITH_RET(ctx, buf); EMIT_BUF_WITH_RET(ctx, buf);
break; break;
case TGSI_OPCODE_F2I: case TGSI_OPCODE_F2I:
snprintf(buf, 255, "%s = %s(%s(ivec4(%s)));\n", dsts[0], dstconv, dtypeprefix, srcs[0]); snprintf(buf, 255, "%s = %s(%s(ivec4(%s)));\n", dsts[0], dstconv, dtypeprefix, srcs[0]);
EMIT_BUF_WITH_RET(ctx, buf); EMIT_BUF_WITH_RET(ctx, buf);
break; break;
case TGSI_OPCODE_F2U: case TGSI_OPCODE_F2U:
snprintf(buf, 255, "%s = %s(%s(uvec4(%s)));\n", dsts[0], dstconv, dtypeprefix, srcs[0]); snprintf(buf, 255, "%s = %s(%s(uvec4(%s)));\n", dsts[0], dstconv, dtypeprefix, srcs[0]);
EMIT_BUF_WITH_RET(ctx, buf); EMIT_BUF_WITH_RET(ctx, buf);
break; break;
case TGSI_OPCODE_NOT: case TGSI_OPCODE_NOT:
@ -1721,9 +1714,9 @@ iter_instruction(struct tgsi_iterate_context *iter,
EMIT_BUF_WITH_RET(ctx, buf); EMIT_BUF_WITH_RET(ctx, buf);
break; break;
case TGSI_OPCODE_CMP: case TGSI_OPCODE_CMP:
snprintf(buf, 255, "%s = mix(%s, %s, greaterThanEqual(%s, vec4(0.0)))%s;\n", dsts[0], srcs[1], srcs[2], srcs[0], writemask); snprintf(buf, 255, "%s = mix(%s, %s, greaterThanEqual(%s, vec4(0.0)))%s;\n", dsts[0], srcs[1], srcs[2], srcs[0], writemask);
EMIT_BUF_WITH_RET(ctx, buf); EMIT_BUF_WITH_RET(ctx, buf);
break; break;
case TGSI_OPCODE_UCMP: case TGSI_OPCODE_UCMP:
snprintf(buf, 255, "%s = mix(%s, %s, notEqual(floatBitsToUint(%s), uvec4(0.0)))%s;\n", dsts[0], srcs[2], srcs[1], srcs[0], writemask); snprintf(buf, 255, "%s = mix(%s, %s, notEqual(floatBitsToUint(%s), uvec4(0.0)))%s;\n", dsts[0], srcs[2], srcs[1], srcs[0], writemask);
EMIT_BUF_WITH_RET(ctx, buf); EMIT_BUF_WITH_RET(ctx, buf);
@ -1798,7 +1791,7 @@ iter_instruction(struct tgsi_iterate_context *iter,
break; break;
case TGSI_OPCODE_EMIT: case TGSI_OPCODE_EMIT:
if (ctx->so && ctx->key->gs_present) { if (ctx->so && ctx->key->gs_present) {
emit_so_movs(ctx); emit_so_movs(ctx);
} }
ret = emit_prescale(ctx); ret = emit_prescale(ctx);
if (ret) if (ret)
@ -1822,7 +1815,6 @@ iter_instruction(struct tgsi_iterate_context *iter,
snprintf(buf, 255, "%s = clamp(%s, 0.0, 1.0);\n", dsts[0], dsts[0]); snprintf(buf, 255, "%s = clamp(%s, 0.0, 1.0);\n", dsts[0], dsts[0]);
EMIT_BUF_WITH_RET(ctx, buf); EMIT_BUF_WITH_RET(ctx, buf);
} }
return TRUE; return TRUE;
} }
@ -1842,7 +1834,7 @@ prolog(struct tgsi_iterate_context *iter)
} }
#define STRCAT_WITH_RET(mainstr, buf) do { \ #define STRCAT_WITH_RET(mainstr, buf) do { \
(mainstr) = strcat_realloc((mainstr), (buf)); \ (mainstr) = strcat_realloc((mainstr), (buf)); \
if ((mainstr) == NULL) return NULL; \ if ((mainstr) == NULL) return NULL; \
} while(0) } while(0)
@ -1884,27 +1876,27 @@ static char *emit_header(struct dump_ctx *ctx, char *glsl_hdr)
const char *vrend_shader_samplertypeconv(int sampler_type, int *is_shad) const char *vrend_shader_samplertypeconv(int sampler_type, int *is_shad)
{ {
switch (sampler_type) { switch (sampler_type) {
case TGSI_TEXTURE_BUFFER: return "Buffer"; case TGSI_TEXTURE_BUFFER: return "Buffer";
case TGSI_TEXTURE_1D: return "1D"; case TGSI_TEXTURE_1D: return "1D";
case TGSI_TEXTURE_2D: return "2D"; case TGSI_TEXTURE_2D: return "2D";
case TGSI_TEXTURE_3D: return "3D"; case TGSI_TEXTURE_3D: return "3D";
case TGSI_TEXTURE_CUBE: return "Cube"; case TGSI_TEXTURE_CUBE: return "Cube";
case TGSI_TEXTURE_RECT: return "2DRect"; case TGSI_TEXTURE_RECT: return "2DRect";
case TGSI_TEXTURE_SHADOW1D: *is_shad = 1; return "1DShadow"; case TGSI_TEXTURE_SHADOW1D: *is_shad = 1; return "1DShadow";
case TGSI_TEXTURE_SHADOW2D: *is_shad = 1; return "2DShadow"; case TGSI_TEXTURE_SHADOW2D: *is_shad = 1; return "2DShadow";
case TGSI_TEXTURE_SHADOWRECT: *is_shad = 1; return "2DRectShadow"; case TGSI_TEXTURE_SHADOWRECT: *is_shad = 1; return "2DRectShadow";
case TGSI_TEXTURE_1D_ARRAY: return "1DArray"; case TGSI_TEXTURE_1D_ARRAY: return "1DArray";
case TGSI_TEXTURE_2D_ARRAY: return "2DArray"; case TGSI_TEXTURE_2D_ARRAY: return "2DArray";
case TGSI_TEXTURE_SHADOW1D_ARRAY: *is_shad = 1; return "1DArrayShadow"; case TGSI_TEXTURE_SHADOW1D_ARRAY: *is_shad = 1; return "1DArrayShadow";
case TGSI_TEXTURE_SHADOW2D_ARRAY: *is_shad = 1; return "2DArrayShadow"; case TGSI_TEXTURE_SHADOW2D_ARRAY: *is_shad = 1; return "2DArrayShadow";
case TGSI_TEXTURE_SHADOWCUBE: *is_shad = 1; return "CubeShadow"; case TGSI_TEXTURE_SHADOWCUBE: *is_shad = 1; return "CubeShadow";
case TGSI_TEXTURE_CUBE_ARRAY: return "CubeArray"; case TGSI_TEXTURE_CUBE_ARRAY: return "CubeArray";
case TGSI_TEXTURE_SHADOWCUBE_ARRAY: *is_shad = 1; return "CubeArrayShadow"; case TGSI_TEXTURE_SHADOWCUBE_ARRAY: *is_shad = 1; return "CubeArrayShadow";
case TGSI_TEXTURE_2D_MSAA: return "2DMS"; case TGSI_TEXTURE_2D_MSAA: return "2DMS";
case TGSI_TEXTURE_2D_ARRAY_MSAA: return "2DMSArray"; case TGSI_TEXTURE_2D_ARRAY_MSAA: return "2DMSArray";
default: return NULL; default: return NULL;
} }
} }
static const char *get_interp_string(int interpolate, bool flatshade) static const char *get_interp_string(int interpolate, bool flatshade)
@ -1934,7 +1926,7 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
if (ctx->prog_type == TGSI_PROCESSOR_FRAGMENT) { if (ctx->prog_type == TGSI_PROCESSOR_FRAGMENT) {
if (fs_emit_layout(ctx)) { if (fs_emit_layout(ctx)) {
bool upper_left = !(ctx->fs_coord_origin ^ ctx->key->invert_fs_origin); bool upper_left = !(ctx->fs_coord_origin ^ ctx->key->invert_fs_origin);
char comma = (upper_left && ctx->fs_pixel_center) ? ',' : ' '; char comma = (upper_left && ctx->fs_pixel_center) ? ',' : ' ';
snprintf(buf, 255, "layout(%s%c%s) in vec4 gl_FragCoord;\n", snprintf(buf, 255, "layout(%s%c%s) in vec4 gl_FragCoord;\n",
@ -1947,11 +1939,11 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
if (ctx->prog_type == TGSI_PROCESSOR_GEOMETRY) { if (ctx->prog_type == TGSI_PROCESSOR_GEOMETRY) {
snprintf(buf, 255, "layout(%s) in;\n", prim_to_name(ctx->gs_in_prim)); snprintf(buf, 255, "layout(%s) in;\n", prim_to_name(ctx->gs_in_prim));
STRCAT_WITH_RET(glsl_hdr, buf); STRCAT_WITH_RET(glsl_hdr, buf);
snprintf(buf, 255, "layout(%s, max_vertices = %d) out;\n", prim_to_name(ctx->gs_out_prim), ctx->gs_max_out_verts); snprintf(buf, 255, "layout(%s, max_vertices = %d) out;\n", prim_to_name(ctx->gs_out_prim), ctx->gs_max_out_verts);
STRCAT_WITH_RET(glsl_hdr, buf); STRCAT_WITH_RET(glsl_hdr, buf);
} }
for (i = 0; i < ctx->num_inputs; i++) { for (i = 0; i < ctx->num_inputs; i++) {
if (!ctx->inputs[i].glsl_predefined_no_emit) { if (!ctx->inputs[i].glsl_predefined_no_emit) {
if (ctx->prog_type == TGSI_PROCESSOR_VERTEX && ctx->cfg->use_explicit_locations) { if (ctx->prog_type == TGSI_PROCESSOR_VERTEX && ctx->cfg->use_explicit_locations) {
snprintf(buf, 255, "layout(location=%d) ", ctx->inputs[i].first); snprintf(buf, 255, "layout(location=%d) ", ctx->inputs[i].first);
STRCAT_WITH_RET(glsl_hdr, buf); STRCAT_WITH_RET(glsl_hdr, buf);
@ -1998,8 +1990,8 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
STRCAT_WITH_RET(glsl_hdr, buf); STRCAT_WITH_RET(glsl_hdr, buf);
if (ctx->has_clipvertex) { if (ctx->has_clipvertex) {
snprintf(buf, 255, "%svec4 clipv_tmp;\n", ctx->has_clipvertex_so ? "out " : ""); snprintf(buf, 255, "%svec4 clipv_tmp;\n", ctx->has_clipvertex_so ? "out " : "");
STRCAT_WITH_RET(glsl_hdr, buf); STRCAT_WITH_RET(glsl_hdr, buf);
} }
if (ctx->num_clip_dist || ctx->key->clip_plane_enable) { if (ctx->num_clip_dist || ctx->key->clip_plane_enable) {
@ -2033,7 +2025,7 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
STRCAT_WITH_RET(glsl_hdr, buf); STRCAT_WITH_RET(glsl_hdr, buf);
} }
} }
if (ctx->so) { if (ctx->so) {
char outtype[6] = {0}; char outtype[6] = {0};
for (i = 0; i < ctx->so->num_outputs; i++) { for (i = 0; i < ctx->so->num_outputs; i++) {
@ -2147,7 +2139,7 @@ static boolean fill_interpolants(struct dump_ctx *ctx, struct vrend_shader_info
sinfo->interpinfo = calloc(ctx->num_interps, sizeof(struct vrend_interp_info)); sinfo->interpinfo = calloc(ctx->num_interps, sizeof(struct vrend_interp_info));
if (!sinfo->interpinfo) if (!sinfo->interpinfo)
return FALSE; return FALSE;
ret = fill_fragment_interpolants(ctx, sinfo); ret = fill_fragment_interpolants(ctx, sinfo);
if (ret == FALSE) if (ret == FALSE)
goto out_fail; goto out_fail;
@ -2256,7 +2248,7 @@ static void replace_interp(char *program,
int mylen = strlen(INTERP_PREFIX) + strlen("out vec4 "); int mylen = strlen(INTERP_PREFIX) + strlen("out vec4 ");
ptr = strstr(program, var_name); ptr = strstr(program, var_name);
if (!ptr) if (!ptr)
return; return;

@ -63,7 +63,7 @@ struct vrend_shader_key {
bool gs_present; bool gs_present;
bool flatshade; bool flatshade;
}; };
struct vrend_shader_cfg { struct vrend_shader_cfg {
int glsl_version; int glsl_version;
bool use_core_profile; bool use_core_profile;

Loading…
Cancel
Save