From f8b4b709e62c0fe25e4483925bac4abea5d8cafe Mon Sep 17 00:00:00 2001 From: jussi Date: Tue, 31 Oct 2023 11:52:36 +0200 Subject: Compute shader management and Buffer management. --- src/lua_core.c | 5 +++++ src/rlgl.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) (limited to 'src') diff --git a/src/lua_core.c b/src/lua_core.c index 7c447f6..cd53c83 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -2296,6 +2296,11 @@ void luaRegister() { assingGlobalFunction( "rlSetUniformMatrix", lrlglSetUniformMatrix ); assingGlobalFunction( "rlSetUniformSampler", lrlglSetUniformSampler ); assingGlobalFunction( "rlSetShader", lrlglSetShader ); + /* Compute shader management */ + assingGlobalFunction( "rlLoadComputeShaderProgram", lrlglLoadComputeShaderProgram ); + assingGlobalFunction( "rlComputeShaderDispatch", lrlglComputeShaderDispatch ); + /* Buffer management */ + assingGlobalFunction( "rlBindImageTexture", lrlglBindImageTexture ); /* Matrix state management. */ assingGlobalFunction( "rlGetMatrixModelview", lrlglGetMatrixModelview ); assingGlobalFunction( "rlGetMatrixProjection", lrlglGetMatrixProjection ); diff --git a/src/rlgl.c b/src/rlgl.c index 4a13c81..5855f60 100644 --- a/src/rlgl.c +++ b/src/rlgl.c @@ -1393,6 +1393,60 @@ int lrlglSetShader( lua_State *L ) { return 0; } +/* +## RLGL - Compute shader management +*/ + +/* +> programId = RL.rlLoadComputeShaderProgram( int shaderId ) + +Load compute shader program + +- Success return int +*/ +int lrlglLoadComputeShaderProgram( lua_State *L ) { + unsigned int shaderId = (unsigned int)luaL_checkinteger( L, 1 ); + + lua_pushinteger( L, rlLoadComputeShaderProgram( shaderId ) ); + + return 1; +} + +/* +> RL.rlComputeShaderDispatch( int groupX, int groupY, int groupZ ) + +Dispatch compute shader (equivalent to *draw* for graphics pipeline) +*/ +int lrlglComputeShaderDispatch( lua_State *L ) { + unsigned int groupX = (unsigned int)luaL_checkinteger( L, 1 ); + unsigned int groupY = (unsigned int)luaL_checkinteger( L, 2 ); + unsigned int groupZ = (unsigned int)luaL_checkinteger( L, 3 ); + + rlComputeShaderDispatch( groupX, groupY, groupZ ); + + return 0; +} + +/* +## RLGL - Buffer management +*/ + +/* +> RL.rlBindImageTexture( int id, int index, int format, bool readonly ) + +Bind image texture +*/ +int lrlglBindImageTexture( lua_State *L ) { + unsigned int id = (unsigned int)luaL_checkinteger( L, 1 ); + unsigned int index = (unsigned int)luaL_checkinteger( L, 2 ); + int format = luaL_checkinteger( L, 3 ); + bool readonly = uluaGetBoolean( L, 4 ); + + rlBindImageTexture( id, index, format, readonly ); + + return 0; +} + /* ## RLGL - Matrix state management */ -- cgit v1.2.3