renderer: move away from pipe bind flag definitions.

macos/master
Dave Airlie 10 years ago
parent ebcc110592
commit e13ebc57e1
  1. 12
      src/virglrenderer.h
  2. 30
      src/vrend_renderer.c
  3. 12
      src/vrend_renderer.h

@ -70,6 +70,18 @@ VIRGL_EXPORT int virgl_renderer_get_fd_for_texture(uint32_t tex_id, int *fd);
struct virgl_resource;
/* virgl bind flags - these are compatible with mesa 10.5 gallium.
but are fixed, no other should be passed to virgl either. */
#define VIRGL_RES_BIND_DEPTH_STENCIL (1 << 0)
#define VIRGL_RES_BIND_RENDER_TARGET (1 << 1)
#define VIRGL_RES_BIND_SAMPLER_VIEW (1 << 3)
#define VIRGL_RES_BIND_VERTEX_BUFFER (1 << 4)
#define VIRGL_RES_BIND_INDEX_BUFFER (1 << 5)
#define VIRGL_RES_BIND_CONSTANT_BUFFER (1 << 6)
#define VIRGL_RES_BIND_STREAM_OUTPUT (1 << 11)
#define VIRGL_RES_BIND_CURSOR (1 << 16)
#define VIRGL_RES_BIND_CUSTOM (1 << 17)
struct virgl_renderer_resource_create_args {
uint32_t handle;
uint32_t target;

@ -3330,20 +3330,20 @@ static int check_resource_valid(struct vrend_renderer_resource_create_args *args
}
if (args->bind == 0 ||
args->bind == PIPE_BIND_CUSTOM ||
args->bind == PIPE_BIND_INDEX_BUFFER ||
args->bind == PIPE_BIND_STREAM_OUTPUT ||
args->bind == PIPE_BIND_VERTEX_BUFFER ||
args->bind == PIPE_BIND_CONSTANT_BUFFER) {
args->bind == VREND_RES_BIND_CUSTOM ||
args->bind == VREND_RES_BIND_INDEX_BUFFER ||
args->bind == VREND_RES_BIND_STREAM_OUTPUT ||
args->bind == VREND_RES_BIND_VERTEX_BUFFER ||
args->bind == VREND_RES_BIND_CONSTANT_BUFFER) {
if (args->target != PIPE_BUFFER)
return -1;
if (args->height != 1 || args->depth != 1)
return -1;
} else {
if (!((args->bind & PIPE_BIND_SAMPLER_VIEW) ||
(args->bind & PIPE_BIND_DEPTH_STENCIL) ||
(args->bind & PIPE_BIND_RENDER_TARGET) ||
(args->bind & PIPE_BIND_CURSOR)))
if (!((args->bind & VREND_RES_BIND_SAMPLER_VIEW) ||
(args->bind & VREND_RES_BIND_DEPTH_STENCIL) ||
(args->bind & VREND_RES_BIND_RENDER_TARGET) ||
(args->bind & VREND_RES_BIND_CURSOR)))
return -1;
if (args->target == PIPE_TEXTURE_2D ||
@ -3393,29 +3393,29 @@ int vrend_renderer_resource_create(struct vrend_renderer_resource_create_args *a
pipe_reference_init(&gr->base.reference, 1);
if (args->bind == PIPE_BIND_CUSTOM) {
if (args->bind == VREND_RES_BIND_CUSTOM) {
/* custom shuold only be for buffers */
gr->ptr = malloc(args->width);
if (!gr->ptr) {
FREE(gr);
return ENOMEM;
}
} else if (args->bind == PIPE_BIND_INDEX_BUFFER) {
} else if (args->bind == VREND_RES_BIND_INDEX_BUFFER) {
gr->target = GL_ELEMENT_ARRAY_BUFFER_ARB;
glGenBuffersARB(1, &gr->id);
glBindBufferARB(gr->target, gr->id);
glBufferData(gr->target, args->width, NULL, GL_STREAM_DRAW);
} else if (args->bind == PIPE_BIND_STREAM_OUTPUT) {
} else if (args->bind == VREND_RES_BIND_STREAM_OUTPUT) {
gr->target = GL_TRANSFORM_FEEDBACK_BUFFER;
glGenBuffersARB(1, &gr->id);
glBindBuffer(gr->target, gr->id);
glBufferData(gr->target, args->width, NULL, GL_STREAM_DRAW);
} else if (args->bind == PIPE_BIND_VERTEX_BUFFER) {
} else if (args->bind == VREND_RES_BIND_VERTEX_BUFFER) {
gr->target = GL_ARRAY_BUFFER_ARB;
glGenBuffersARB(1, &gr->id);
glBindBufferARB(gr->target, gr->id);
glBufferData(gr->target, args->width, NULL, GL_STREAM_DRAW);
} else if (args->bind == PIPE_BIND_CONSTANT_BUFFER) {
} else if (args->bind == VREND_RES_BIND_CONSTANT_BUFFER) {
gr->target = GL_UNIFORM_BUFFER;
glGenBuffersARB(1, &gr->id);
glBindBufferARB(gr->target, gr->id);
@ -3425,7 +3425,7 @@ int vrend_renderer_resource_create(struct vrend_renderer_resource_create_args *a
glGenBuffersARB(1, &gr->id);
glBindBufferARB(gr->target, gr->id);
glBufferData(gr->target, args->width, NULL, GL_STREAM_DRAW);
} else if (args->target == PIPE_BUFFER && (args->bind & PIPE_BIND_SAMPLER_VIEW)) {
} else if (args->target == PIPE_BUFFER && (args->bind & VREND_RES_BIND_SAMPLER_VIEW)) {
GLenum internalformat;
/* need to check GL version here */
gr->target = GL_TEXTURE_BUFFER;

@ -140,6 +140,18 @@ int vrend_renderer_context_create(uint32_t handle, uint32_t nlen, const char *na
void vrend_renderer_context_create_internal(uint32_t handle, uint32_t nlen, const char *name);
void vrend_renderer_context_destroy(uint32_t handle);
/* virgl bind flags - these are compatible with mesa 10.5 gallium.
but are fixed, no other should be passed to virgl either. */
#define VREND_RES_BIND_DEPTH_STENCIL (1 << 0)
#define VREND_RES_BIND_RENDER_TARGET (1 << 1)
#define VREND_RES_BIND_SAMPLER_VIEW (1 << 3)
#define VREND_RES_BIND_VERTEX_BUFFER (1 << 4)
#define VREND_RES_BIND_INDEX_BUFFER (1 << 5)
#define VREND_RES_BIND_CONSTANT_BUFFER (1 << 6)
#define VREND_RES_BIND_STREAM_OUTPUT (1 << 11)
#define VREND_RES_BIND_CURSOR (1 << 16)
#define VREND_RES_BIND_CUSTOM (1 << 17)
struct vrend_renderer_resource_create_args {
uint32_t handle;
enum pipe_texture_target target;

Loading…
Cancel
Save