Example #1
0
void CVertexArrayRange::DrawArrayT2(int drawType,int stride)
{
	if(stripIndex==0 || stripArray[stripIndex-1]!=drawIndex)
		EndStrip();
  glEnableClientState(GL_VERTEX_ARRAY_RANGE_NV);
	glVertexPointer(3,GL_FLOAT,stride,&drawArray[0]);
	glTexCoordPointer(2,GL_FLOAT,stride,&drawArray[3]);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glEnableClientState(GL_VERTEX_ARRAY);
	if(multiTextureEnabled){
		glClientActiveTextureARB(GL_TEXTURE1_ARB);
		glTexCoordPointer(2,GL_FLOAT,stride,&drawArray[5]);
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
		glClientActiveTextureARB(GL_TEXTURE0_ARB);
	}
	int oldIndex=0;
	for(int a=0;a<stripIndex;a++){
		glDrawArrays(drawType,oldIndex*4/stride,stripArray[a]*4/stride-oldIndex*4/stride);
		oldIndex=stripArray[a];
	}
	if(multiTextureEnabled){
		glClientActiveTextureARB(GL_TEXTURE1_ARB);
		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
		glClientActiveTextureARB(GL_TEXTURE0_ARB);
	}
  glSetFenceNV(fence, GL_ALL_COMPLETED_NV);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);						
  glDisableClientState(GL_VERTEX_ARRAY_RANGE_NV);
}
Example #2
0
void Milestone::set() {
    if (glSetFenceNV) {
        glSetFenceNV(glfence, GL_ALL_COMPLETED_NV);
    }

    isSet = true;
}
Example #3
0
static void opengl_fence(int command) {
#ifdef USE_GLES

#else
    if (command == FENCE_SET) {
        if (g_has_nv_fence) {
            //printf("...\n");
            glSetFenceNV(g_fence, GL_ALL_COMPLETED_NV);
            CHECK_GL_ERROR_MSG("glSetFenceNV(g_fence, GL_ALL_COMPLETED_NV)");
        }
        else if (g_has_apple_fence) {
            glSetFenceAPPLE(g_fence);
            CHECK_GL_ERROR_MSG("glSetFenceAPPLE(g_fence)");
        }
        else if (g_has_arb_sync) {
            g_sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
            CHECK_GL_ERROR_MSG("glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0)");
        }
    }
    else if (command == FENCE_WAIT) {
        if (g_has_nv_fence) {
            //printf("-- f --\n");
            //glFinishFenceNV(g_fence);
            //int64_t t1 = fs_get_monotonic_time();
            //fs_ml_usleep(10000);
            while (!glTestFenceNV(g_fence)) {
                CHECK_GL_ERROR_MSG("glTestFenceNV(g_fence)");
                //printf("-> %lld\n", fs_get_monotonic_time() - t1);
                //printf("%d\n", glGetError());
                fs_ml_usleep(1000);
                //printf("-> %lld\n", fs_get_monotonic_time() - t1);
            }
            CHECK_GL_ERROR_MSG("glTestFenceNV(g_fence)");
        }
        else if (g_has_apple_fence) {
            while (!glTestFenceAPPLE(g_fence)) {
                CHECK_GL_ERROR_MSG("glTestFenceAPPLE(g_fence)");
                fs_ml_usleep(1000);
            }
            CHECK_GL_ERROR_MSG("glTestFenceAPPLE(g_fence)");
        }
        else if (g_has_arb_sync) {
            int flags = GL_SYNC_FLUSH_COMMANDS_BIT;
            while (glClientWaitSync(g_sync, flags, 0)
                    == GL_TIMEOUT_EXPIRED) {
                CHECK_GL_ERROR_MSG("glClientWaitSync(g_sync, flags, 0)");
                flags = 0;
                fs_ml_usleep(1000);
            }
            CHECK_GL_ERROR_MSG("glClientWaitSync(g_sync, flags, 0)");
        }
    }
#endif
}
Example #4
0
void CVertexArrayRange::DrawArrayT(int drawType,int stride) {
    CheckEndStrip();
    glVertexPointer(3,GL_FLOAT,stride,&drawArray[0]);
    glTexCoordPointer(2,GL_FLOAT,stride,&drawArray[3]);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glEnableClientState(GL_VERTEX_ARRAY);
    DrawArrays(drawType, stride);
    glSetFenceNV(fence, GL_ALL_COMPLETED_NV);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisableClientState(GL_VERTEX_ARRAY);
}
Example #5
0
	void	set_fence(unsigned int fence_id)
	// Use this to declare all previous glDrawElements() calls as
	// belonging to the specified fence.  A subsequent
	// finish_fence(id) will block until those drawing calls have
	// completed.
	{
		if (glSetFenceNV)
		{
			glSetFenceNV(fence_id, GL_ALL_COMPLETED_NV);
		}
		// else no-op.
	}
Example #6
0
void wined3d_event_query_issue(struct wined3d_event_query *query, IWineD3DDeviceImpl *device)
{
    const struct wined3d_gl_info *gl_info;
    struct wined3d_context *context;

    if (query->context)
    {
        if (!query->context->gl_info->supported[ARB_SYNC] && query->context->tid != GetCurrentThreadId())
        {
#ifdef VBOX_WINE_WITH_SINGLE_CONTEXT
            ERR("unexpected\n");
#endif
            context_free_event_query(query);
            context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
            context_alloc_event_query(context, query);
        }
        else
        {
            context = context_acquire(device, query->context->current_rt, CTXUSAGE_RESOURCELOAD);
        }
    }
    else
    {
        context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
        context_alloc_event_query(context, query);
    }

    gl_info = context->gl_info;

    ENTER_GL();

    if (gl_info->supported[ARB_SYNC])
    {
        if (query->object.sync) GL_EXTCALL(glDeleteSync(query->object.sync));
        checkGLcall("glDeleteSync");
        query->object.sync = GL_EXTCALL(glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0));
        checkGLcall("glFenceSync");
    }
    else if (gl_info->supported[APPLE_FENCE])
    {
        GL_EXTCALL(glSetFenceAPPLE(query->object.id));
        checkGLcall("glSetFenceAPPLE");
    }
    else if (gl_info->supported[NV_FENCE])
    {
        GL_EXTCALL(glSetFenceNV(query->object.id, GL_ALL_COMPLETED_NV));
        checkGLcall("glSetFenceNV");
    }

    LEAVE_GL();

    context_release(context);
}
Example #7
0
void wined3d_event_query_issue(struct wined3d_event_query *query, const struct wined3d_device *device)
{
    const struct wined3d_gl_info *gl_info;
    struct wined3d_context *context;

    if (query->context)
    {
        if (!query->context->gl_info->supported[ARB_SYNC] && query->context->tid != GetCurrentThreadId())
        {
            context_free_event_query(query);
            context = context_acquire(device, NULL);
            context_alloc_event_query(context, query);
        }
        else
        {
            context = context_acquire(device, query->context->current_rt);
        }
    }
    else
    {
        context = context_acquire(device, NULL);
        context_alloc_event_query(context, query);
    }

    gl_info = context->gl_info;

    if (gl_info->supported[ARB_SYNC])
    {
        if (query->object.sync) GL_EXTCALL(glDeleteSync(query->object.sync));
        checkGLcall("glDeleteSync");
        query->object.sync = GL_EXTCALL(glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0));
        checkGLcall("glFenceSync");
    }
    else if (gl_info->supported[APPLE_FENCE])
    {
        GL_EXTCALL(glSetFenceAPPLE(query->object.id));
        checkGLcall("glSetFenceAPPLE");
    }
    else if (gl_info->supported[NV_FENCE])
    {
        GL_EXTCALL(glSetFenceNV(query->object.id, GL_ALL_COMPLETED_NV));
        checkGLcall("glSetFenceNV");
    }

    context_release(context);
}
Example #8
0
void CVertexArrayRange::DrawArrayTC(int drawType, int stride)
{
	if(stripIndex==0 || stripArray[stripIndex-1]!=drawIndex)
		EndStrip();
//  glDisableClientState(GL_VERTEX_ARRAY_RANGE_NV);
	glVertexPointer(3,GL_FLOAT,stride,&drawArray[0]);
	glTexCoordPointer(2,GL_FLOAT,stride,&drawArray[3]);
	glColorPointer(4,GL_UNSIGNED_BYTE,stride,&drawArray[5]);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_COLOR_ARRAY);
	
	int oldIndex=0;
	for(int a=0;a<stripIndex;a++){
		glDrawArrays(drawType,oldIndex*4/stride,stripArray[a]*4/stride-oldIndex*4/stride);
		oldIndex=stripArray[a];
	}
  glSetFenceNV(fence, GL_ALL_COMPLETED_NV);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);						
	glDisableClientState(GL_COLOR_ARRAY);
//  glDisableClientState(GL_VERTEX_ARRAY_RANGE_NV);
}
Example #9
0
void init_display()
{
   int surface_type_id, result, i, value, scrn, num_fbconfigs;
   GLXFBConfig *fbconfigs;
   XVisualInfo *visInfo;
   XSetWindowAttributes attributes;
   Window root;
   int attrib_pbuffer[6] = {GLX_PBUFFER_WIDTH, 0, 
                            GLX_PBUFFER_HEIGHT, 0,
                            GLX_PRESERVED_CONTENTS,
                            0};

   width = horizontal_size;
   height = vertical_size;

   if(chroma_format != CHROMA420)
      error("we only support 4:2:0 chroma formats\n");

   display = XOpenDisplay(NULL);
   root = XDefaultRootWindow(display);
   scrn = XDefaultScreen(display);

   if(!GetPortId(display, &portNum, &surface_type_id))
      error("couldn't find a suitable port\n");



#ifdef USE_DLOPEN
   if(!ResolveFunctions(DLFILENAME))
      error("couldn't resolve necessary functions\n");
#endif

   result = XvMCCreateContext(display, portNum, surface_type_id, 
                              coded_picture_width, coded_picture_height,
                              XVMC_DIRECT, &context);

   if(result != Success)
      error("couldn't create XvMCContext\n");

   for(i = 0; i < numsurfaces; i++) {
      result = XvMCCreateSurface(display, &context, &surfaces[i]);
      if(result != Success) {
          if(i < 4) {
             XvMCDestroyContext(display, &context);
             error("couldn't create enough XvMCSurfaces\n");
          } else {
             numsurfaces = i;
             printf("could only allocate %i surfaces\n", numsurfaces);
          }
      } 
      surface_info[i].reference = 0;
      surface_info[i].sequence_number = 0;      
   }

   slices = slices * mb_width;

   XvMCCreateBlocks(display, &context, slices * 6, &blocks);
   XvMCCreateMacroBlocks(display, &context, slices, &macro_blocks);

   fbconfigs = glXChooseFBConfig(display, scrn, attr_fbconfig, &num_fbconfigs);

   gl_fbconfig = *fbconfigs;

   /* find the first one with no depth buffer */
   for(i = 0; i < num_fbconfigs; i++) {
      glXGetFBConfigAttrib(display, fbconfigs[i], GLX_DEPTH_SIZE, &value);
      if(value == 0) {
         gl_fbconfig = fbconfigs[i];
         break;
      }
   }

   PrintVisual();
 
   visInfo = glXGetVisualFromFBConfig(display, gl_fbconfig);

   attrib_pbuffer[1] = width;
   attrib_pbuffer[3] = bob ? (height/2) : height;
   gl_pbuffer = glXCreatePbuffer(display, gl_fbconfig, attrib_pbuffer);

   gl_context = glXCreateNewContext(display, gl_fbconfig, GLX_RGBA_TYPE, 
                                    NULL, 1);

   attributes.colormap = XCreateColormap(display, root, visInfo->visual,
                                         AllocNone);

   window = XCreateWindow(display, root, 0, 0, width, height, 0,
                          visInfo->depth, InputOutput,
                          visInfo->visual, CWColormap, &attributes);

   gl_window = glXCreateWindow(display, gl_fbconfig, window, NULL);

   XSelectInput(display, window, KeyPressMask | StructureNotifyMask |
                                 Button1MotionMask | ButtonPressMask);
   XMapWindow(display, window);

   glXMakeContextCurrent(display, gl_window, gl_pbuffer, gl_context);
   glDrawBuffer(GL_BACK);
   glReadBuffer(GL_FRONT_LEFT);

   tex_w =  1 << PowerOfTwo(width);
   tex_h = 1 << PowerOfTwo(bob ? (height/2) : height);

   printf("%i x %i texture\n", tex_w, tex_h);

   glClearColor (0.0, 0.0, 0.0, 0.0);

   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
   glTexImage2D(GL_TEXTURE_2D, 0, 3, tex_w, tex_h,
                0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
   glEnable(GL_TEXTURE_2D);
   glShadeModel(GL_FLAT);

   glViewport(0, 0, width, height);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glFrustum(-1.0, 1.0, -1.0, 1.0, 2, 18.0);
   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
   glTranslatef(0.0, 0.0, -8);

#ifdef USE_NV_FENCE
   glGenFencesNV(1, &nvFence);
   glSetFenceNV(&nvFence, GL_ALL_COMPLETED_NV);
#endif

   XSync(display, 0);

   uiclp = uiclip+512;
   for (i= -512; i<512; i++)
      uiclp[i] = (i<-128) ? 0 : ((i>127) ? 255 : i+128);

   iclp = iclip+512;
   for (i= -512; i<512; i++)
      iclp[i] = (i<-128) ? -128 : ((i>127) ? 127 : i);

   niclp = niclip+512;
   for (i= -512; i<512; i++)
   niclp[i] = (i<-256) ? -256 : ((i>255) ? 255 : i);

}