From a9463ea515029d8f8099d8358639a46173202901 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Mon, 13 May 2024 15:39:09 +0200 Subject: [PATCH] add RSF_2D and make RegisterShaderFlags_t cummulative --- src/engine/client/cg_api.h | 2 +- src/engine/client/cl_cgame.cpp | 2 +- src/engine/null/null_renderer.cpp | 2 +- src/engine/renderer/tr_local.h | 5 ++--- src/engine/renderer/tr_public.h | 3 +-- src/engine/renderer/tr_shader.cpp | 9 +++------ src/engine/renderer/tr_types.h | 11 ++++++----- src/shared/client/cg_api.cpp | 2 +- 8 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/engine/client/cg_api.h b/src/engine/client/cg_api.h index 58d371dc24..0e7beb25cb 100644 --- a/src/engine/client/cg_api.h +++ b/src/engine/client/cg_api.h @@ -106,7 +106,7 @@ void trap_S_StartBackgroundTrack( const char *intro, const char *loop void trap_R_LoadWorldMap( const char *mapname ); qhandle_t trap_R_RegisterModel( const char *name ); qhandle_t trap_R_RegisterSkin( const char *name ); -qhandle_t trap_R_RegisterShader( const char *name, RegisterShaderFlags_t flags ); +qhandle_t trap_R_RegisterShader( const char *name, int flags ); void trap_R_ClearScene(); void trap_R_AddRefEntityToScene( const refEntity_t *re ); diff --git a/src/engine/client/cl_cgame.cpp b/src/engine/client/cl_cgame.cpp index f2d88670b5..7a09f32c22 100644 --- a/src/engine/client/cl_cgame.cpp +++ b/src/engine/client/cl_cgame.cpp @@ -1210,7 +1210,7 @@ void CGameVM::QVMSyscall(int syscallNum, Util::Reader& reader, IPC::Channel& cha case CG_R_REGISTERSHADER: IPC::HandleMsg(channel, std::move(reader), [this] (const std::string& name, int flags, int& handle) { - handle = re.RegisterShader(name.c_str(), (RegisterShaderFlags_t) flags); + handle = re.RegisterShader(name.c_str(), flags); }); break; diff --git a/src/engine/null/null_renderer.cpp b/src/engine/null/null_renderer.cpp index 9c1876d2f3..ca96c51d3d 100644 --- a/src/engine/null/null_renderer.cpp +++ b/src/engine/null/null_renderer.cpp @@ -46,7 +46,7 @@ qhandle_t RE_RegisterSkin( const char *name ) { return FS_FOpenFileRead( name, nullptr ); } -qhandle_t RE_RegisterShader( const char *, RegisterShaderFlags_t ) +qhandle_t RE_RegisterShader( const char *, int ) { return 1; } diff --git a/src/engine/renderer/tr_local.h b/src/engine/renderer/tr_local.h index e1603bc91a..598229140a 100644 --- a/src/engine/renderer/tr_local.h +++ b/src/engine/renderer/tr_local.h @@ -3266,12 +3266,11 @@ inline bool checkGLErrors() ==================================================================== */ - qhandle_t RE_RegisterShader( const char *name, RegisterShaderFlags_t flags ); + qhandle_t RE_RegisterShader( const char *name, int flags ); qhandle_t RE_RegisterShaderFromImage( const char *name, image_t *image ); bool RE_LoadDynamicShader( const char *shadername, const char *shadertext ); - shader_t *R_FindShader( const char *name, shaderType_t type, - RegisterShaderFlags_t flags ); + shader_t *R_FindShader( const char *name, shaderType_t type, int flags ); shader_t *R_GetShaderByHandle( qhandle_t hShader ); shader_t *R_FindShaderByName( const char *name ); const char *RE_GetShaderNameFromHandle( qhandle_t shader ); diff --git a/src/engine/renderer/tr_public.h b/src/engine/renderer/tr_public.h index 530d064b9b..92e8c7b9ff 100644 --- a/src/engine/renderer/tr_public.h +++ b/src/engine/renderer/tr_public.h @@ -128,8 +128,7 @@ struct refexport_t qhandle_t ( *RegisterModel )( const char *name ); //qhandle_t (*RegisterModelAllLODs) (const char *name); qhandle_t ( *RegisterSkin )( const char *name ); - qhandle_t ( *RegisterShader )( const char *name, - RegisterShaderFlags_t flags ); + qhandle_t ( *RegisterShader )( const char *name, int flags ); fontInfo_t* ( *RegisterFont )( const char *fontName, int pointSize ); void ( *UnregisterFont )( fontInfo_t *font ); void ( *Glyph )( fontInfo_t *font, const char *str, glyphInfo_t *glyph ); diff --git a/src/engine/renderer/tr_shader.cpp b/src/engine/renderer/tr_shader.cpp index e187c16deb..1a73a8e654 100644 --- a/src/engine/renderer/tr_shader.cpp +++ b/src/engine/renderer/tr_shader.cpp @@ -6237,8 +6237,7 @@ the vertex rgba modulate values, as appropriate for misc_model pre-lit surfaces. =============== */ -shader_t *R_FindShader( const char *name, shaderType_t type, - RegisterShaderFlags_t flags ) +shader_t *R_FindShader( const char *name, shaderType_t type, int flags ) { char strippedName[ MAX_QPATH ]; char fileName[ MAX_QPATH ]; @@ -6366,9 +6365,7 @@ shader_t *R_FindShader( const char *name, shaderType_t type, Log::Debug( "loading '%s' image as shader", fileName ); - // choosing filter based on the NOMIP flag seems strange, - // we better introduce RSF_2D. - if( ( bits & RSF_NOMIP ) || ( bits & RSF_FITSCREEN ) ) + if( bits & RSF_2D ) { imageParams_t imageParams = {}; imageParams.bits = bits; @@ -6524,7 +6521,7 @@ This should really only be used for explicit shaders, because there is no way to ask for different implicit lighting modes (vertex, lightmap, etc) ==================== */ -qhandle_t RE_RegisterShader( const char *name, RegisterShaderFlags_t flags ) +qhandle_t RE_RegisterShader( const char *name, int flags ) { shader_t *sh; diff --git a/src/engine/renderer/tr_types.h b/src/engine/renderer/tr_types.h index 66b37dbe55..81e31fd313 100644 --- a/src/engine/renderer/tr_types.h +++ b/src/engine/renderer/tr_types.h @@ -95,11 +95,12 @@ using glIndex_t = unsigned int; enum RegisterShaderFlags_t { RSF_DEFAULT = BIT( 0 ), - RSF_NOMIP = BIT( 1 ), - RSF_FITSCREEN = BIT( 2 ), - RSF_LIGHT_ATTENUATION = BIT( 3 ), - RSF_NOLIGHTSCALE = BIT( 4 ), - RSF_SPRITE = BIT( 5 ), + RSF_2D = BIT( 1 ), + RSF_NOMIP = BIT( 2 ), + RSF_FITSCREEN = BIT( 3 ), + RSF_LIGHT_ATTENUATION = BIT( 4 ), + RSF_NOLIGHTSCALE = BIT( 5 ), + RSF_SPRITE = BIT( 6 ), }; struct polyVert_t diff --git a/src/shared/client/cg_api.cpp b/src/shared/client/cg_api.cpp index 6bf574eaf6..be7e836d2c 100644 --- a/src/shared/client/cg_api.cpp +++ b/src/shared/client/cg_api.cpp @@ -300,7 +300,7 @@ qhandle_t trap_R_RegisterSkin( const char *name ) return handle; } -qhandle_t trap_R_RegisterShader( const char *name, RegisterShaderFlags_t flags ) +qhandle_t trap_R_RegisterShader( const char *name, int flags ) { int handle; VM::SendMsg(name, flags, handle);