]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
GL: Remove some D3D cruft
authorbones_was_here <bones_was_here@xonotic.au>
Fri, 30 Aug 2024 06:46:46 +0000 (16:46 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Thu, 12 Sep 2024 13:53:36 +0000 (23:53 +1000)
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
cl_screen.c
gl_backend.c
gl_backend.h
gl_rmain.c
r_shadow.c

index 34c06f376f89ffd821cbd0167c97eb66802f1715..7c2ab0dc02a1cc4360038acc9c6b2b584a37f7f9 100644 (file)
@@ -2277,7 +2277,7 @@ void CL_UpdateScreen(void)
 #endif
 
        R_Viewport_InitOrtho(&viewport, &identitymatrix, 0, 0, vid.mode.width, vid.mode.height, 0, 0, vid_conwidth.integer, vid_conheight.integer, -10, 100, NULL);
-       R_Mesh_SetRenderTargets(0, NULL, NULL, NULL, NULL, NULL);
+       R_Mesh_SetRenderTargets(0);
        R_SetViewport(&viewport);
        GL_ScissorTest(false);
        GL_ColorMask(1,1,1,1);
index 02f7bc29cd72c3ea647e660b039b3e0fe8f5360b..9710c0495cfc97f08ca7a438aca929509537139e 100644 (file)
@@ -969,7 +969,7 @@ int R_Mesh_CreateFramebufferObject(rtexture_t *depthtexture, rtexture_t *colorte
                qglGenFramebuffers(1, (GLuint*)&temp);CHECKGLERROR
 
 #ifndef USE_GLES2
-               R_Mesh_SetRenderTargets(temp, NULL, NULL, NULL, NULL, NULL);  // This breaks GLES2.
+               R_Mesh_SetRenderTargets(temp);  // This breaks GLES2.
                // GL_ARB_framebuffer_object (GL3-class hardware) - depth stencil attachment
 #endif
 
@@ -1056,19 +1056,8 @@ void R_Mesh_DestroyFramebufferObject(int fbo)
        }
 }
 
-void R_Mesh_SetRenderTargets(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, rtexture_t *colortexture2, rtexture_t *colortexture3, rtexture_t *colortexture4)
+void R_Mesh_SetRenderTargets(int fbo)
 {
-       unsigned int i;
-       unsigned int j;
-       rtexture_t *textures[5];
-       Vector4Set(textures, colortexture, colortexture2, colortexture3, colortexture4);
-       textures[4] = depthtexture;
-       // unbind any matching textures immediately, otherwise D3D will complain about a bound texture being used as a render target
-       for (j = 0;j < 5;j++)
-               if (textures[j])
-                       for (i = 0;i < MAX_TEXTUREUNITS;i++)
-                               if (gl_state.units[i].texture == textures[j])
-                                       R_Mesh_TexBind(i, NULL);
        // set up framebuffer object or render targets for the active rendering API
        switch (vid.renderpath)
        {
@@ -1605,7 +1594,7 @@ void GL_CaptureVideo_VideoFrame(int newframestepframenum)
                oldestPBOindex = 0;
 
        // Ensure we'll read from the default FB
-       R_Mesh_SetRenderTargets(0, NULL, NULL, NULL, NULL, NULL);
+       R_Mesh_SetRenderTargets(0);
 
        // If necessary, scale the newest frame with linear filtering
        if (cls.capturevideo.FBO)
@@ -1657,7 +1646,7 @@ void GL_CaptureVideo_EndVideo(void)
 void R_Mesh_Start(void)
 {
        BACKENDACTIVECHECK
-       R_Mesh_SetRenderTargets(0, NULL, NULL, NULL, NULL, NULL);
+       R_Mesh_SetRenderTargets(0);
 #ifdef DEBUGGL // gl_printcheckerror isn't registered in normal builds
        if (gl_printcheckerror.integer && !gl_paranoid.integer)
        {
@@ -1867,7 +1856,7 @@ void R_Mesh_Draw(int firstvertex, int numvertices, int firsttriangle, int numtri
 // restores backend state, used when done with 3D rendering
 void R_Mesh_Finish(void)
 {
-       R_Mesh_SetRenderTargets(0, NULL, NULL, NULL, NULL, NULL);
+       R_Mesh_SetRenderTargets(0);
 }
 
 r_meshbuffer_t *R_Mesh_CreateMeshBuffer(const void *data, size_t size, const char *name, qbool isindexbuffer, qbool isuniformbuffer, qbool isdynamic, qbool isindex16)
index 252e3f34b43ff65706c28954521aa70e14bd37a2..d0d23148957a377dd00a4eaa25f087505632c3d0 100644 (file)
@@ -53,7 +53,7 @@ void GL_CaptureVideo_VideoFrame(int newframestepframenum);
 void GL_CaptureVideo_EndVideo(void);
 int R_Mesh_CreateFramebufferObject(rtexture_t *depthtexture, rtexture_t *colortexture, rtexture_t *colortexture2, rtexture_t *colortexture3, rtexture_t *colortexture4);
 void R_Mesh_DestroyFramebufferObject(int fbo);
-void R_Mesh_SetRenderTargets(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, rtexture_t *colortexture2, rtexture_t *colortexture3, rtexture_t *colortexture4);
+void R_Mesh_SetRenderTargets(int fbo);
 
 unsigned int GL_Backend_CompileProgram(int vertexstrings_count, const char **vertexstrings_list, int geometrystrings_count, const char **geometrystrings_list, int fragmentstrings_count, const char **fragmentstrings_list);
 void GL_Backend_FreeProgram(unsigned int prog);
index b14db60e7aab7f7402d57c59a9b496ba77077bc0..a1afc55b3c8ecc24d884b2355be98456ca858f68 100644 (file)
@@ -4410,7 +4410,7 @@ void R_SetupView(qbool allowwaterclippingplane, int viewfbo, rtexture_t *viewdep
                R_Viewport_InitPerspectiveInfinite(&r_refdef.view.viewport, &r_refdef.view.matrix, viewx, viewy_adjusted, viewwidth, viewheight, r_refdef.view.frustum_x, r_refdef.view.frustum_y, r_refdef.nearclip, customclipplane);
        else
                R_Viewport_InitPerspective(&r_refdef.view.viewport, &r_refdef.view.matrix, viewx, viewy_adjusted, viewwidth, viewheight, r_refdef.view.frustum_x, r_refdef.view.frustum_y, r_refdef.nearclip, r_refdef.farclip, customclipplane);
-       R_Mesh_SetRenderTargets(viewfbo, viewdepthtexture, viewcolortexture, NULL, NULL, NULL);
+       R_Mesh_SetRenderTargets(viewfbo);
        R_SetViewport(&r_refdef.view.viewport);
 }
 
@@ -4448,7 +4448,7 @@ void R_ResetViewRendering2D_Common(int viewfbo, rtexture_t *viewdepthtexture, rt
        viewy_adjusted = viewfbo ? viewy : vid.mode.height - viewheight - viewy;
 
        R_Viewport_InitOrtho(&viewport, &identitymatrix, viewx, viewy_adjusted, viewwidth, viewheight, 0, 0, x2, y2, -10, 100, NULL);
-       R_Mesh_SetRenderTargets(viewfbo, viewdepthtexture, viewcolortexture, NULL, NULL, NULL);
+       R_Mesh_SetRenderTargets(viewfbo);
        R_SetViewport(&viewport);
        GL_Scissor(viewport.x, viewport.y, viewport.width, viewport.height);
        GL_Color(1, 1, 1, 1);
@@ -5127,7 +5127,7 @@ static void R_Bloom_MakeTexture(void)
        CHECKGLERROR
        prev = r_fb.rt_screen;
        cur = R_RenderTarget_Get(r_fb.bloomwidth, r_fb.bloomheight, TEXTYPE_UNUSED, false, textype, TEXTYPE_UNUSED, TEXTYPE_UNUSED, TEXTYPE_UNUSED);
-       R_Mesh_SetRenderTargets(cur->fbo, NULL, cur->colortexture[0], NULL, NULL, NULL);
+       R_Mesh_SetRenderTargets(cur->fbo);
        R_SetViewport(&bloomviewport);
        GL_CullFace(GL_NONE);
        GL_DepthTest(false);
@@ -5146,7 +5146,7 @@ static void R_Bloom_MakeTexture(void)
        {
                prev = cur;
                cur = R_RenderTarget_Get(r_fb.bloomwidth, r_fb.bloomheight, TEXTYPE_UNUSED, false, textype, TEXTYPE_UNUSED, TEXTYPE_UNUSED, TEXTYPE_UNUSED);
-               R_Mesh_SetRenderTargets(cur->fbo, NULL, cur->colortexture[0], NULL, NULL, NULL);
+               R_Mesh_SetRenderTargets(cur->fbo);
                x *= 2;
                r = bound(0, r_bloom_colorexponent.value / x, 1); // always 0.5 to 1
                if(x <= 2)
@@ -5170,7 +5170,7 @@ static void R_Bloom_MakeTexture(void)
        {
                prev = cur;
                cur = R_RenderTarget_Get(r_fb.bloomwidth, r_fb.bloomheight, TEXTYPE_UNUSED, false, textype, TEXTYPE_UNUSED, TEXTYPE_UNUSED, TEXTYPE_UNUSED);
-               R_Mesh_SetRenderTargets(cur->fbo, NULL, cur->colortexture[0], NULL, NULL, NULL);
+               R_Mesh_SetRenderTargets(cur->fbo);
                // blend on at multiple vertical offsets to achieve a vertical blur
                // TODO: do offset blends using GLSL
                // TODO instead of changing the texcoords, change the target positions to prevent artifacts at edges
@@ -5671,7 +5671,7 @@ void R_RenderView(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, i
        if (r_refdef.view.isoverlay)
        {
                // TODO: FIXME: move this into its own backend function maybe? [2/5/2008 Andreas]
-               R_Mesh_SetRenderTargets(0, NULL, NULL, NULL, NULL, NULL);
+               R_Mesh_SetRenderTargets(0);
                GL_Clear(GL_DEPTH_BUFFER_BIT, NULL, 1.0f, 0);
                R_TimeReport("depthclear");
 
index e90cb1b749b3abe49fc584f92b10e603eb10a8b6..136927fdae26212e1706449563ecf6ae72a6181a 100644 (file)
@@ -1409,7 +1409,7 @@ void R_Shadow_RenderMode_ActiveLight(const rtlight_t *rtlight)
 void R_Shadow_RenderMode_Reset(void)
 {
        R_Mesh_ResetTextureState();
-       R_Mesh_SetRenderTargets(r_shadow_viewfbo, r_shadow_viewdepthtexture, r_shadow_viewcolortexture, NULL, NULL, NULL);
+       R_Mesh_SetRenderTargets(r_shadow_viewfbo);
        R_SetViewport(&r_refdef.view.viewport);
        GL_Scissor(r_shadow_lightscissor[0], r_shadow_lightscissor[1], r_shadow_lightscissor[2], r_shadow_lightscissor[3]);
        GL_DepthRange(0, 1);
@@ -1494,9 +1494,9 @@ void R_Shadow_ClearShadowMapTexture(void)
        R_Mesh_ResetTextureState();
        R_Shadow_RenderMode_Reset();
        if (r_shadow_shadowmap2ddepthbuffer)
-               R_Mesh_SetRenderTargets(r_shadow_fbo2d, r_shadow_shadowmap2ddepthbuffer, r_shadow_shadowmap2ddepthtexture, NULL, NULL, NULL);
+               R_Mesh_SetRenderTargets(r_shadow_fbo2d);
        else
-               R_Mesh_SetRenderTargets(r_shadow_fbo2d, r_shadow_shadowmap2ddepthtexture, NULL, NULL, NULL, NULL);
+               R_Mesh_SetRenderTargets(r_shadow_fbo2d);
        R_SetupShader_DepthOrShadow(true, r_shadow_shadowmap2ddepthbuffer != NULL, false); // FIXME test if we have a skeletal model?
        GL_PolygonOffset(r_shadow_shadowmapping_polygonfactor.value, r_shadow_shadowmapping_polygonoffset.value);
        GL_DepthMask(true);
@@ -1559,9 +1559,9 @@ static void R_Shadow_RenderMode_ShadowMap(int side, int size, int x, int y)
                R_Mesh_ResetTextureState();
                R_Shadow_RenderMode_Reset();
                if (r_shadow_shadowmap2ddepthbuffer)
-                       R_Mesh_SetRenderTargets(r_shadow_fbo2d, r_shadow_shadowmap2ddepthbuffer, r_shadow_shadowmap2ddepthtexture, NULL, NULL, NULL);
+                       R_Mesh_SetRenderTargets(r_shadow_fbo2d);
                else
-                       R_Mesh_SetRenderTargets(r_shadow_fbo2d, r_shadow_shadowmap2ddepthtexture, NULL, NULL, NULL, NULL);
+                       R_Mesh_SetRenderTargets(r_shadow_fbo2d);
                R_SetupShader_DepthOrShadow(true, r_shadow_shadowmap2ddepthbuffer != NULL, false); // FIXME test if we have a skeletal model?
                GL_PolygonOffset(r_shadow_shadowmapping_polygonfactor.value, r_shadow_shadowmapping_polygonoffset.value);
                GL_DepthMask(true);
@@ -1650,9 +1650,9 @@ void R_Shadow_RenderMode_DrawDeferredLight(qbool shadowmapping)
        R_EntityMatrix(&identitymatrix);
        GL_BlendFunc(GL_SRC_ALPHA, GL_ONE);
        if (rsurface.rtlight->specularscale > 0 && r_shadow_gloss.integer > 0)
-               R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusespecularfbo, r_shadow_prepassgeometrydepthbuffer, r_shadow_prepasslightingdiffusetexture, r_shadow_prepasslightingspeculartexture, NULL, NULL);
+               R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusespecularfbo);
        else
-               R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusefbo, r_shadow_prepassgeometrydepthbuffer, r_shadow_prepasslightingdiffusetexture, NULL, NULL, NULL);
+               R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusefbo);
 
        r_shadow_usingshadowmap2d = shadowmapping;
 
@@ -3968,7 +3968,7 @@ void R_Shadow_DrawPrepass(void)
        GL_BlendFunc(GL_ONE, GL_ZERO);
        GL_Color(1,1,1,1);
        GL_DepthTest(true);
-       R_Mesh_SetRenderTargets(r_shadow_prepassgeometryfbo, r_shadow_prepassgeometrydepthbuffer, r_shadow_prepassgeometrynormalmaptexture, NULL, NULL, NULL);
+       R_Mesh_SetRenderTargets(r_shadow_prepassgeometryfbo);
        Vector4Set(clearcolor, 0.5f,0.5f,0.5f,1.0f);
        GL_Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, clearcolor, 1.0f, 0);
        if (r_timereport_active)
@@ -3995,7 +3995,7 @@ void R_Shadow_DrawPrepass(void)
        GL_ColorMask(1,1,1,1);
        GL_Color(1,1,1,1);
        GL_DepthTest(true);
-       R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusespecularfbo, r_shadow_prepassgeometrydepthbuffer, r_shadow_prepasslightingdiffusetexture, r_shadow_prepasslightingspeculartexture, NULL, NULL);
+       R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusespecularfbo);
        Vector4Set(clearcolor, 0, 0, 0, 0);
        GL_Clear(GL_COLOR_BUFFER_BIT, clearcolor, 1.0f, 0);
        if (r_timereport_active)
@@ -4082,19 +4082,19 @@ void R_Shadow_PrepareLights(void)
 
                        // set up the geometry pass fbo (depth + normalmap)
                        r_shadow_prepassgeometryfbo = R_Mesh_CreateFramebufferObject(r_shadow_prepassgeometrydepthbuffer, r_shadow_prepassgeometrynormalmaptexture, NULL, NULL, NULL);
-                       R_Mesh_SetRenderTargets(r_shadow_prepassgeometryfbo, r_shadow_prepassgeometrydepthbuffer, r_shadow_prepassgeometrynormalmaptexture, NULL, NULL, NULL);
+                       R_Mesh_SetRenderTargets(r_shadow_prepassgeometryfbo);
                        // render depth into a renderbuffer and other important properties into the normalmap texture
 
                        // set up the lighting pass fbo (diffuse + specular)
                        r_shadow_prepasslightingdiffusespecularfbo = R_Mesh_CreateFramebufferObject(r_shadow_prepassgeometrydepthbuffer, r_shadow_prepasslightingdiffusetexture, r_shadow_prepasslightingspeculartexture, NULL, NULL);
-                       R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusespecularfbo, r_shadow_prepassgeometrydepthbuffer, r_shadow_prepasslightingdiffusetexture, r_shadow_prepasslightingspeculartexture, NULL, NULL);
+                       R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusespecularfbo);
                        // render diffuse into one texture and specular into another,
                        // with depth and normalmap bound as textures,
                        // with depth bound as attachment as well
 
                        // set up the lighting pass fbo (diffuse)
                        r_shadow_prepasslightingdiffusefbo = R_Mesh_CreateFramebufferObject(r_shadow_prepassgeometrydepthbuffer, r_shadow_prepasslightingdiffusetexture, NULL, NULL, NULL);
-                       R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusefbo, r_shadow_prepassgeometrydepthbuffer, r_shadow_prepasslightingdiffusetexture, NULL, NULL, NULL);
+                       R_Mesh_SetRenderTargets(r_shadow_prepasslightingdiffusefbo);
                        // render diffuse into one texture,
                        // with depth and normalmap bound as textures,
                        // with depth bound as attachment as well