[Scummvm-git-logs] scummvm master -> 16c0c1ee12c71ec41af568486b289b787a4ec628

grisenti noreply at scummvm.org
Tue Mar 28 20:31:34 UTC 2023


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
16c0c1ee12 HPL1: cleanup RenderState setGpuProgMode


Commit: 16c0c1ee12c71ec41af568486b289b787a4ec628
    https://github.com/scummvm/scummvm/commit/16c0c1ee12c71ec41af568486b289b787a4ec628
Author: grisenti (emanuele at grisenti.net)
Date: 2023-03-28T22:31:11+02:00

Commit Message:
HPL1: cleanup RenderState setGpuProgMode

remove traces of the old shader system and replace logging

Changed paths:
    engines/hpl1/engine/graphics/RenderState.cpp
    engines/hpl1/engine/graphics/RenderState.h


diff --git a/engines/hpl1/engine/graphics/RenderState.cpp b/engines/hpl1/engine/graphics/RenderState.cpp
index 7ccf4d5020f..75859f959bc 100644
--- a/engines/hpl1/engine/graphics/RenderState.cpp
+++ b/engines/hpl1/engine/graphics/RenderState.cpp
@@ -28,6 +28,7 @@
 #include "hpl1/engine/graphics/RenderState.h"
 #include "hpl1/engine/graphics/Renderer3D.h"
 
+#include "hpl1/debug.h"
 #include "hpl1/engine/graphics/GPUProgram.h"
 #include "hpl1/engine/graphics/LowLevelGraphics.h"
 #include "hpl1/engine/graphics/Material.h"
@@ -111,12 +112,6 @@ void iRenderState::SetMode(cRenderSettings *apSettings) {
 	case eRenderStateType_BlendMode:
 		SetBlendMode(apSettings);
 		break;
-	case eRenderStateType_VertexProgram:
-		SetVtxProgMode(apSettings);
-		break;
-	case eRenderStateType_FragmentProgram:
-		SetFragProgMode(apSettings);
-		break;
 	case eRenderStateType_Texture:
 		SetTextureMode(apSettings);
 		break;
@@ -373,104 +368,40 @@ void iRenderState::SetBlendMode(cRenderSettings *apSettings) {
 
 //-----------------------------------------------------------------------
 
-void iRenderState::SetVtxProgMode(cRenderSettings *apSettings) {
-	if (gpuProgram != apSettings->gpuProgram) {
-		if (apSettings->mbLog) {
-			if (gpuProgram)
-				Log("Setting vertex program: '%s'/%d ", gpuProgram->GetName().c_str(),
-					(size_t)gpuProgram);
-			else
-				Log("Setting vertex program: NULL");
-		}
-
-		if (gpuProgram == NULL && apSettings->gpuProgram) {
-			apSettings->gpuProgram->UnBind();
-			if (apSettings->mbLog)
-				Log("Unbinding old");
-		}
-		apSettings->gpuProgram = gpuProgram;
-
-		if (gpuProgram) {
-			if (apSettings->mbLog)
-				Log("Binding new");
-			gpuProgram->Bind();
-
-			if (gpuProgramSetup) {
-				if (apSettings->mbLog)
-					Log("Custom setup %d ", gpuProgram);
-				gpuProgramSetup->Setup(gpuProgram, apSettings);
-			}
-			apSettings->gpuProgramSetup = gpuProgramSetup;
-
-			// reset this so all matrix setting are set to vertex program.
-			apSettings->mbMatrixWasNULL = false;
-
-			if (mbUsesLight) {
-				if (apSettings->mbLog)
-					Log("Setting light properites");
-
-				// gpuProgram->SetFloat("LightRadius",mpLight->GetFarAttenuation());
-				gpuProgram->SetColor4f("LightColor", mpLight->GetDiffuseColor());
-
-				apSettings->mpLight = mpLight;
+void iRenderState::setGpuProgMode(cRenderSettings *settings) {
+	if (gpuProgram != settings->gpuProgram) {
+		if (gpuProgram != settings->gpuProgram) {
+			if (gpuProgram) {
+				Hpl1::logInfo(Hpl1::kDebugRenderer, "binding shader: '%s'\n", gpuProgram->GetName().c_str());
+				gpuProgram->Bind();
+
+				if (gpuProgramSetup) {
+					gpuProgramSetup->Setup(gpuProgram, settings);
+				}
+				settings->gpuProgramSetup = gpuProgramSetup;
+
+				// reset this so all matrix setting are set to vertex program.
+				settings->mbMatrixWasNULL = false;
+				if (mbUsesLight) {
+					gpuProgram->SetColor4f("LightColor", mpLight->GetDiffuseColor());
+					settings->mpLight = mpLight;
+				} else {
+					settings->mpLight = nullptr;
+				}
+				settings->mbUsesLight = mbUsesLight;
+				settings->mbUsesEye = mbUsesEye;
 			} else {
-				apSettings->mpLight = NULL;
+				Hpl1::logInfo(Hpl1::kDebugRenderer, "unbinding current shader: '%s'\n", settings->gpuProgram->GetName().c_str());
+				settings->gpuProgram->UnBind();
 			}
-
-			apSettings->mbUsesLight = mbUsesLight;
-			apSettings->mbUsesEye = mbUsesEye;
-		}
-		if (apSettings->mbLog)
-			Log("\n");
-	} else {
-		if (apSettings->gpuProgram && mbUsesLight && mpLight != apSettings->mpLight) {
-			if (apSettings->mbLog)
-				Log("Setting new light properites\n");
-			// gpuProgram->SetFloat("LightRadius",mpLight->GetFarAttenuation());
+			settings->gpuProgram = gpuProgram;
+		} else if (settings->gpuProgram && mbUsesLight && mpLight != settings->mpLight) {
 			gpuProgram->SetColor4f("LightColor", mpLight->GetDiffuseColor());
-
-			apSettings->mpLight = mpLight;
+			settings->mpLight = mpLight;
 		}
 	}
 }
 
-void iRenderState::setGpuProgMode(cRenderSettings *settings) {
-	SetVtxProgMode(settings);
-	SetFragProgMode(settings);
-}
-
-//-----------------------------------------------------------------------
-
-void iRenderState::SetFragProgMode(cRenderSettings *apSettings) {
-	if (gpuProgram != apSettings->gpuProgram) {
-		if (apSettings->mbLog) {
-			if (gpuProgram)
-				Log("Setting fragment program: '%s' /%d ", gpuProgram->GetName().c_str(),
-					(size_t)gpuProgram);
-			else
-				Log("Setting fragment program: NULL");
-		}
-
-		// if(gpuProgram==NULL && apSettings->mpFragmentProgram) apSettings->mpFragmentProgram->UnBind();
-		if (apSettings->gpuProgram)
-			apSettings->gpuProgram->UnBind();
-
-		apSettings->gpuProgram = gpuProgram;
-
-		if (gpuProgram) {
-			if (apSettings->mbLog)
-				Log("Binding new ");
-			gpuProgram->Bind();
-
-			if (gpuProgramSetup)
-				gpuProgramSetup->Setup(gpuProgram, apSettings);
-		}
-
-		if (apSettings->mbLog)
-			Log("\n");
-	}
-}
-
 //-----------------------------------------------------------------------
 
 void iRenderState::SetTextureMode(cRenderSettings *apSettings) {
diff --git a/engines/hpl1/engine/graphics/RenderState.h b/engines/hpl1/engine/graphics/RenderState.h
index cdc8eba81da..3eeee16b4ed 100644
--- a/engines/hpl1/engine/graphics/RenderState.h
+++ b/engines/hpl1/engine/graphics/RenderState.h
@@ -143,8 +143,6 @@ private:
 	void SetDepthMode(cRenderSettings *apSettings);
 	void SetBlendMode(cRenderSettings *apSettings);
 	void SetAlphaMode(cRenderSettings *apSettings);
-	void SetVtxProgMode(cRenderSettings *apSettings);
-	void SetFragProgMode(cRenderSettings *apSettings);
 	void setGpuProgMode(cRenderSettings *settings);
 	void SetTextureMode(cRenderSettings *apSettings);
 	void SetVtxBuffMode(cRenderSettings *apSettings);




More information about the Scummvm-git-logs mailing list