]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rsurf.c
properly detect glsl 1.3 support
[xonotic/darkplaces.git] / gl_rsurf.c
index 6689a44ff9dd1d254f552978541555631fabbd50..f04bb2b671f9839df434bbce644e9e5530a131f5 100644 (file)
@@ -119,7 +119,7 @@ void R_BuildLightMap (const entity_render_t *ent, msurface_t *surface)
                }
        }
 
-       R_UpdateTexture(surface->lightmaptexture, templight, surface->lightmapinfo->lightmaporigin[0], surface->lightmapinfo->lightmaporigin[1], smax, tmax);
+       R_UpdateTexture(surface->lightmaptexture, templight, surface->lightmapinfo->lightmaporigin[0], surface->lightmapinfo->lightmaporigin[1], 0, smax, tmax, 1);
 
        // update the surface's deluxemap if it has one
        if (surface->deluxemaptexture != r_texture_blanknormalmap)
@@ -157,7 +157,7 @@ void R_BuildLightMap (const entity_render_t *ent, msurface_t *surface)
                        l = (int)(n[2] * 128 + 128);out[0] = bound(0, l, 255);
                        out[3] = 255;
                }
-               R_UpdateTexture(surface->deluxemaptexture, templight, surface->lightmapinfo->lightmaporigin[0], surface->lightmapinfo->lightmaporigin[1], smax, tmax);
+               R_UpdateTexture(surface->deluxemaptexture, templight, surface->lightmapinfo->lightmaporigin[0], surface->lightmapinfo->lightmaporigin[1], 0, smax, tmax, 1);
        }
 }
 
@@ -609,7 +609,6 @@ void R_Q1BSP_DrawDepth(entity_render_t *ent)
        GL_DepthTest(true);
        GL_BlendFunc(GL_ONE, GL_ZERO);
        GL_DepthMask(true);
-       GL_AlphaTest(false);
 //     R_Mesh_ResetTextureState();
        R_SetupShader_DepthOrShadow();
        if (ent == r_refdef.scene.worldentity)
@@ -1058,11 +1057,8 @@ static void R_Q1BSP_CallRecursiveGetLightInfo(r_q1bsp_getlightinfo_t *info, qboo
        {
                float origin[3];
                VectorCopy(info->relativelightorigin, origin);
-               if (!r_svbsp.nodes)
-               {
-                       r_svbsp.maxnodes = max(r_svbsp.maxnodes, 1<<18);
-                       r_svbsp.nodes = (svbsp_node_t*) Mem_Alloc(r_main_mempool, r_svbsp.maxnodes * sizeof(svbsp_node_t));
-               }
+               r_svbsp.maxnodes = max(r_svbsp.maxnodes, 1<<12);
+               r_svbsp.nodes = (svbsp_node_t*) R_FrameData_Alloc(r_svbsp.maxnodes * sizeof(svbsp_node_t));
                info->svbsp_active = true;
                info->svbsp_insertoccluder = true;
                for (;;)
@@ -1075,9 +1071,10 @@ static void R_Q1BSP_CallRecursiveGetLightInfo(r_q1bsp_getlightinfo_t *info, qboo
                                // an upper limit is imposed
                                if (r_svbsp.maxnodes >= 2<<22)
                                        break;
-                               Mem_Free(r_svbsp.nodes);
                                r_svbsp.maxnodes *= 2;
-                               r_svbsp.nodes = (svbsp_node_t*) Mem_Alloc(tempmempool, r_svbsp.maxnodes * sizeof(svbsp_node_t));
+                               r_svbsp.nodes = (svbsp_node_t*) R_FrameData_Alloc(r_svbsp.maxnodes * sizeof(svbsp_node_t));
+                               //Mem_Free(r_svbsp.nodes);
+                               //r_svbsp.nodes = (svbsp_node_t*) Mem_Alloc(tempmempool, r_svbsp.maxnodes * sizeof(svbsp_node_t));
                        }
                        else
                                break;
@@ -1131,6 +1128,8 @@ static void R_Q1BSP_CallRecursiveGetLightInfo(r_q1bsp_getlightinfo_t *info, qboo
        }
        else
                R_Q1BSP_RecursiveGetLightInfo_BSP(info, false);
+       // we're using temporary framedata memory, so this pointer will be invalid soon, clear it
+       r_svbsp.nodes = NULL;
        if (developer_extra.integer && use_svbsp)
        {
                Con_DPrintf("GetLightInfo: svbsp built with %i nodes, polygon stats:\n", r_svbsp.numnodes);
@@ -1274,6 +1273,7 @@ void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, const vec3_t relativelightor
        // check the box in modelspace, it was already checked in worldspace
        if (!BoxesOverlap(model->normalmins, model->normalmaxs, lightmins, lightmaxs))
                return;
+       R_FrameData_SetMark();
        if (ent->model->brush.submodel)
                GL_PolygonOffset(r_refdef.shadowpolygonfactor + r_polygonoffset_submodel_factor.value, r_refdef.shadowpolygonoffset + r_polygonoffset_submodel_offset.value);
        if (model->brush.shadowmesh)
@@ -1311,6 +1311,7 @@ void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, const vec3_t relativelightor
        }
        if (ent->model->brush.submodel)
                GL_PolygonOffset(r_refdef.shadowpolygonfactor, r_refdef.shadowpolygonoffset);
+       R_FrameData_ReturnToMark();
 }
 
 void R_Q1BSP_CompileShadowMap(entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativelightdirection, float lightradius, int numsurfaces, const int *surfacelist)
@@ -1347,6 +1348,7 @@ void R_Q1BSP_DrawShadowMap(int side, entity_render_t *ent, const vec3_t relative
        // check the box in modelspace, it was already checked in worldspace
        if (!BoxesOverlap(model->normalmins, model->normalmaxs, lightmins, lightmaxs))
                return;
+       R_FrameData_SetMark();
        // identify lit faces within the bounding box
        for (modelsurfacelistindex = 0;modelsurfacelistindex < modelnumsurfaces;modelsurfacelistindex++)
        {
@@ -1377,10 +1379,14 @@ void R_Q1BSP_DrawShadowMap(int side, entity_render_t *ent, const vec3_t relative
                }
                --modelsurfacelistindex;
                GL_CullFace(rsurface.texture->currentmaterialflags & MATERIALFLAG_NOCULLFACE ? GL_NONE : r_refdef.view.cullface_back);
-               RSurf_PrepareVerticesForBatch(BATCHNEED_VERTEXPOSITION, batchnumsurfaces, batchsurfacelist);
-               R_Mesh_PrepareVertices_Position(rsurface.batchnumvertices, rsurface.batchvertexposition, rsurface.batchvertexpositionbuffer);
+               RSurf_PrepareVerticesForBatch(BATCHNEED_ARRAY_VERTEX, batchnumsurfaces, batchsurfacelist);
+               if (rsurface.batchvertex3fbuffer)
+                       R_Mesh_PrepareVertices_Vertex3f(rsurface.batchnumvertices, rsurface.batchvertex3f, rsurface.batchvertex3fbuffer);
+               else
+                       R_Mesh_PrepareVertices_Vertex3f(rsurface.batchnumvertices, rsurface.batchvertex3f, rsurface.batchvertex3f_vertexbuffer);
                RSurf_DrawBatch();
        }
+       R_FrameData_ReturnToMark();
 }
 
 #define BATCHSIZE 1024
@@ -1390,6 +1396,7 @@ static void R_Q1BSP_DrawLight_TransparentCallback(const entity_render_t *ent, co
        int i, j, endsurface;
        texture_t *t;
        const msurface_t *surface;
+       R_FrameData_SetMark();
        // note: in practice this never actually receives batches
        R_Shadow_RenderMode_Begin();
        R_Shadow_RenderMode_ActiveLight(rtlight);
@@ -1411,6 +1418,7 @@ static void R_Q1BSP_DrawLight_TransparentCallback(const entity_render_t *ent, co
                }
        }
        R_Shadow_RenderMode_End();
+       R_FrameData_ReturnToMark();
 }
 
 extern qboolean r_shadow_usingdeferredprepass;
@@ -1422,6 +1430,7 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, int numsurfaces, const int *surface
        const msurface_t **texturesurfacelist;
        texture_t *tex;
        CHECKGLERROR
+       R_FrameData_SetMark();
        // this is a double loop because non-visible surface skipping has to be
        // fast, and even if this is not the world model (and hence no visibility
        // checking) the input surface list and batch buffer are different formats
@@ -1477,6 +1486,7 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, int numsurfaces, const int *surface
                        R_Shadow_RenderLighting(texturenumsurfaces, texturesurfacelist);
                }
        }
+       R_FrameData_ReturnToMark();
 }
 
 //Made by [515]