< GeeXLab Reference Guide />
> Back to Reference Guide Index
gh_gpu_program library
Description
gh_gpu_program is the module that manages GPU programs based on the GLSL language: creation, destruction, binding, uniforms settings.
Number of functions: 66
- gh_gpu_program.add_shader_from_buffer ()
- gh_gpu_program.bind ()
- gh_gpu_program.create ()
- gh_gpu_program.create_empty ()
- gh_gpu_program.create_from_file ()
- gh_gpu_program.create_from_file_v3 ()
- gh_gpu_program.create_from_shader_files ()
- gh_gpu_program.create_mesh_task_from_shader_files ()
- gh_gpu_program.create_from_zip_file ()
- gh_gpu_program.create_v2 ()
- gh_gpu_program.get_interface_block_index ()
- gh_gpu_program.get_uniform_array_stride ()
- gh_gpu_program.get_uniform_block_size ()
- gh_gpu_program.get_uniform_size_and_offset ()
- gh_gpu_program.get_vertex_attrib_name ()
- gh_gpu_program.run_compute ()
- gh_gpu_program.run_compute_group_size ()
- gh_gpu_program.set_livecoding_state ()
- gh_gpu_program.set_shader_storage_block_binding ()
- gh_gpu_program.set_uniform_block_binding ()
- gh_gpu_program.set_vertex_attrib_name ()
- gh_gpu_program.uniform1d ()
- gh_gpu_program.uniform1f ()
- gh_gpu_program.uniform1fv ()
- gh_gpu_program.uniform1i ()
- gh_gpu_program.uniform1iv ()
- gh_gpu_program.uniform1ui64 ()
- gh_gpu_program.uniform1ui64v ()
- gh_gpu_program.uniform2d ()
- gh_gpu_program.uniform2f ()
- gh_gpu_program.uniform2fv ()
- gh_gpu_program.uniform2i ()
- gh_gpu_program.uniform3d ()
- gh_gpu_program.uniform3f ()
- gh_gpu_program.uniform3fv ()
- gh_gpu_program.uniform3i ()
- gh_gpu_program.uniform4d ()
- gh_gpu_program.uniform4f ()
- gh_gpu_program.uniform4f_array ()
- gh_gpu_program.uniform4fv ()
- gh_gpu_program.uniform4i ()
- gh_gpu_program.uniform4i_array ()
- gh_gpu_program.uniform_3x3f ()
- gh_gpu_program.uniform_4x4f ()
- gh_gpu_program.uniform_camera_matrices ()
- gh_gpu_program.uniform_camera_matrices_v2 ()
- gh_gpu_program.uniform_modelviewproj_matrices ()
- gh_gpu_program.uniform_object_matrix ()
- gh_gpu_program.uniform_transform_matrix_v1 ()
- gh_gpu_program.uniform_transform_matrix_v2 ()
- gh_gpu_program.uniform_matrix ()
- gh_gpu_program.uniform_subroutine ()
- gh_gpu_program.vk_create_from_spirv_module_file ()
- gh_gpu_program.vk_create_from_spirv_module_zip ()
- gh_gpu_program.vk_create_mesh_task_from_spirv_module_file ()
- gh_gpu_program.vk_create_mesh_task_from_spirv_module_zip ()
- gh_gpu_program.vk_create_from_smolv_module_file ()
- gh_gpu_program.create_gl_spirv ()
- gh_gpu_program.create_from_shader_files_gl_spirv ()
- gh_gpu_program.create_mesh_task_from_shader_files_gl_spirv ()
- gh_gpu_program.create_from_shader_files_gl_smolv ()
- gh_gpu_program.create_from_zip_file_gl_spirv ()
- gh_gpu_program.update_shader_from_file ()
- gh_gpu_program.update_shader_from_memory ()
- gh_gpu_program.vk_add_spirv_module_file ()
- gh_gpu_program.vk_add_spirv_module_zip ()
add_shader_from_buffer
Description
Adds a shader, specified by a memory buffer, to an existing GPU program, created by create_empty().
Syntax
ret = gh_gpu_program.add_shader_from_buffer(
gpuprog_id,
buff_ptr,
buff_size,
shader_type
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- buff_ptr [POINTER]: pointer to the buffer
- buff_size [INTEGER]: size of the buffer in bytes
- shader_type [ENUM]: type of shader (vertex, pixel, etc.)
Return Values
- ret [BOOLEAN]: return code: 1 (success) or 0 (error)
Code sample
-- shader types:
GPU_SHADER_VERTEX = 0
GPU_SHADER_PIXEL = 1
GPU_SHADER_GEOMETRY = 2
GPU_SHADER_TESS_CONTROL = 3
GPU_SHADER_TESS_EVAL = 4
GPU_SHADER_COMPUTE = 5
gpuprog_id = gh_gpu_program.create_empty("GPUProg01")
filename = demo_dir .. "assets/vertex_shader.txt"
buffer, buffer_size = gh_utils.file_buffer_create(filename)
gh_gpu_program.add_shader_from_buffer(gpuprog_id, buffer, buffer_size, GPU_SHADER_VERTEX)
gh_utils.file_buffer_kill(buffer)
filename = demo_dir .. "assets/pixel_shader.txt"
buffer, buffer_size = gh_utils.file_buffer_create(filename)
gh_gpu_program.add_shader_from_buffer(gpuprog_id, buffer, buffer_size, GPU_SHADER_PIXEL)
gh_utils.file_buffer_kill(buffer)
bind
Description
Binds (makes it active) the GPU program to the renderer. To unbind a GPU program, just pass 0 as gpu program identifier.
Syntax
gh_gpu_program.bind(
gpuprog_id
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.bind(gpuprog_id) -- Binding
...
gh_gpu_program.bind(0) -- Unbinding
create
Description
Creates a GLSL program from vertex (vs), pixel (ps), geometry (gs), tessellation control and evaluation (tcs and tes) or compute (cs) shaders.
Syntax
gpuprog_id = gh_gpu_program.create(
vs,
ps,
gs,
tcs,
tes,
cs
)
Languages
Parameters
- vs [STRING]: vertex shader source code string
- ps [STRING]: pixel shader source code string
- gs [STRING]: geometry shader source code string
- tcs [STRING]: tessellation control shader source code string
- tes [STRING]: tessellation eval shader source code string
- cs [STRING]: compute shader source code string
Return Values
- gpuprog_id [ID]: gpu program identifier
Code sample
vs = "......"
ps = "......"
gpuprog_id = gh_gpu_program.create(vs, ps, "", "", "", "")
create_empty
Description
Creates an empty GPU program.
Syntax
gpuprog_id = gh_gpu_program.create_empty(
program_name
)
Languages
Parameters
- program_name [STRING]: name of the GPU program
Return Values
- gpuprog_id [ID]: gpu program identifier
Code sample
gpuprog_id = gh_gpu_program.create_empty("GPUProg01")
create_from_file
Description
Loads a GLSL source code from file (the file contains all shaders) and creates a new GPU program node.
Syntax
gpuprog_id = gh_gpu_program.create_from_file(
filename,
absolute_path
)
Languages
Parameters
- filename [STRING]: GPU program source code filename
- absolute_path [BOOLEAN]: file path: 1 (absolute) or 0 (relative)
Return Values
- gpuprog_id [ID]: gpu program identifier
Code sample
abs_path = 0 -- relative path
gpuprog_id = gh_gpu_program.create_from_file("data/shader.glsl", abs_path)
create_from_file_v3
Description
Loads a GLSL source code from file (the file contains all shaders) and creates a new GPU program node.
Syntax
gpuprog_id = gh_gpu_program.create_from_file_v3(
program_name,
filename
)
Languages
Parameters
- program_name [STRING]: name of the GPU program
- filename [STRING]: absolute path of the GPU program source code file
Return Values
- gpuprog_id [ID]: gpu program identifier
Code sample
local demo_dir = gh_utils.get_demo_dir()
gpuprog_id = gh_gpu_program.create_from_file_v3("LightingProg", demo_dir .. "./data/lighting_prog.glsl")
create_from_shader_files
Description
Creates a GLSL program from separate shader files.
Syntax
gpuprog_id = gh_gpu_program.create_from_shader_files(
program_name,
vs_filename,
ps_filename,
gs_filename,
tcs_filename,
tes_filename,
cs_filename
)
Languages
Parameters
- program_name [STRING]: name of the GPU program
- vs_filename [STRING]: absolute path of the vertex shader file
- ps_filename [STRING]: absolute path of the pixel shader file
- gs_filename [STRING]: absolute path of the geometry shader file
- tcs_filename [STRING]: absolute path of the tessellation control shader file
- tes_filename [STRING]: absolute path of the tessellation eval shader file
- cs_filename [STRING]: absolute path of the compute shader file
Return Values
- gpuprog_id [ID]: gpu program identifier
Code sample
local demo_dir = gh_utils.get_demo_dir()
vs = demo_dir .. "./shaders/vs.txt"
ps = demo_dir .. "./shaders/ps.txt"
gpuprog_id = gh_gpu_program.create_from_shader_files("LightingProg", vs, ps, "", "", "", "")
create_mesh_task_from_shader_files
Description
Creates a GLSL mesh shader program from separate mesh/task shader files.
Syntax
gpuprog_id = gh_gpu_program.create_mesh_task_from_shader_files(
program_name,
ms_filename,
ts_filename,
ps_filename
)
Languages
Parameters
- program_name [STRING]: name of the GPU program
- ms_filename [STRING]: absolute path of the mesh shader file
- ts_filename [STRING]: absolute path of the task shader file
- ps_filename [STRING]: absolute path of the pixel shader file
Return Values
- gpuprog_id [ID]: gpu program identifier
Code sample
local demo_dir = gh_utils.get_demo_dir()
vs = demo_dir .. "./shaders/ms.txt"
ps = demo_dir .. "./shaders/ps.txt"
mesh_prog = gh_gpu_program.create_mesh_task_from_shader_files("MeshProg", ms, "", ps)
create_from_zip_file
Description
Creates a GLSL program from separate shader files stored in a zip file.
Syntax
gpuprog_id = gh_gpu_program.create_from_zip_file(
zip_filename,
program_name,
vs_filename,
ps_filename,
gs_filename,
tcs_filename,
tes_filename,
cs_filename
)
Languages
Parameters
- zip_filename [STRING]: absolute path of the zip file
- program_name [STRING]: name of the GPU program
- vs_filename [STRING]: absolute path of the vertex shader file
- ps_filename [STRING]: absolute path of the pixel shader file
- gs_filename [STRING]: absolute path of the geometry shader file
- tcs_filename [STRING]: absolute path of the tessellation control shader file
- tes_filename [STRING]: absolute path of the tessellation eval shader file
- cs_filename [STRING]: absolute path of the compute shader file
Return Values
- gpuprog_id [ID]: gpu program identifier
Code sample
local demo_dir = gh_utils.get_demo_dir()
local zip_filename = demo_dir .. "demo.zip"
vs = "shaders/vs.txt"
ps = "shaders/ps.txt"
gpuprog_id = gh_gpu_program.create_from_zip_file(zip_filename, "LightingProg", vs, ps, "", "", "", "")
create_v2
Description
Creates a GLSL program from vertex (vs), pixel (ps), geometry (gs), tessellation control (tcs), evaluation (tes) or compute (cs) shaders. All these shaders are memory buffers.
Syntax
gpuprog_id = gh_gpu_program.create_v2(
program_name,
vs,
ps,
gs,
tcs,
tes,
cs
)
Languages
Parameters
- program_name [STRING]: name of the GPU program
- vs [STRING]: vertex shader source code string
- ps [STRING]: pixel shader source code string
- gs [STRING]: geometry shader source code string
- tcs [STRING]: tessellation control shader source code string
- tes [STRING]: tessellation eval shader source code string
- cs [STRING]: compute shader source code string
Return Values
- gpuprog_id [ID]: gpu program identifier
Code sample
vs = "......"
ps = "......"
gpuprog_id = gh_gpu_program.create_v2("LightingProg", vs, ps, "", "", "", "")
get_interface_block_index
Description
Gets the index of an interface block.
Syntax
block_index = gh_gpu_program.get_interface_block_index(
gpuprog_id,
block_type,
block_name
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- block_type [ENUM]: type of the block: 'UNIFORM', 'SHADER_STORAGE'
- block_name [STRING]: name of the block
Return Values
- block_index [INTEGER]: block index
Code sample
index = gh_gpu_program.get_interface_block_index(gpuprog_id, "UNIFORM", "CameraMatrix")
get_uniform_array_stride
Description
Gets the stride in bytes of an array inside an uniform block.
Syntax
stride = gh_gpu_program.get_uniform_array_stride(
gpuprog_id,
variable_name
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- variable_name [STRING]: name of the variable
Return Values
- stride [INTEGER]: stride in bytes
Code sample
stride = gh_gpu_program.get_uniform_array_stride(gpuprog_id, "positions")
get_uniform_block_size
Description
Gets the size in bytes of an uniform block.
Syntax
block_size = gh_gpu_program.get_uniform_block_size(
gpuprog_id,
block_index
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- block_index [INTEGER]: block index
Return Values
- block_size [INTEGER]: block size in bytes
Code sample
index = gh_gpu_program.get_interface_block_index(gpuprog_id, "UNIFORM", "CameraMatrix")
size = gh_gpu_program.get_uniform_block_size(gpuprog_id, index)
get_uniform_size_and_offset
Description
Gets the size and offset in bytes of a variable inside an uniform block.
Syntax
size, offset = gh_gpu_program.get_uniform_size_and_offset(
gpuprog_id,
variable_name
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- variable_name [STRING]: name of the variable
Return Values
- size, offset [INTEGER]: size and offset in bytes
Code sample
size, offset = gh_gpu_program.get_uniform_size_and_offset(gpuprog_id, "positions")
get_vertex_attrib_name
Description
Gets the name of a vertex attribute.
Syntax
name = gh_gpu_program.get_vertex_attrib_name(
gpuprog_id,
vertex_index
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- vertex_index [INTEGER]: vertex attribute index
Return Values
- name [STRING]: vertex attrib name
Code sample
gh_gpu_program.bind(gpuprog_id)
name = gh_gpu_program.get_vertex_attrib_name(gpuprog_id, 0)
run_compute
Description
Runs a compute program (OpenGL 4.3+ feature). Based on GL_ARB_compute_shader.
Syntax
gh_gpu_program.run_compute(
gpuprog_id,
num_groups_x, num_groups_y, num_groups_z
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- num_groups_x, num_groups_y, num_groups_z [INTEGER]: specifies the number of local work groups that will be dispatched in the X, Y and Z dimensions
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.run_compute(gpuprog_id, 16, 16, 16)
run_compute_group_size
Description
Runs a compute program (OpenGL 4.3+ feature) and allows the specification of group size.
Syntax
gh_gpu_program.run_compute_group_size(
gpuprog_id,
num_groups_x, num_groups_y, num_groups_z,
work_group_size_x, work_group_size_y, work_group_size_z
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- num_groups_x, num_groups_y, num_groups_z [INTEGER]: specifies the number of local work groups that will be dispatched in the X, Y and Z dimensions
- work_group_size_x, work_group_size_y, work_group_size_z [INTEGER]: specifies the work group size in the X, Y and Z dimensions
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.run_compute_group_size(gpuprog_id, num_groups_x, num_groups_y, num_groups_z, work_group_size_x, work_group_size_y, work_group_size_z)
set_livecoding_state
Description
Sets the live coding from file state. If state is 1, you can edit the shader in any text editor and instantly see the effects in GeeXLab.
Syntax
gh_gpu_program.set_livecoding_state(
gpuprog_id,
shader_type,
state
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- shader_type [ENUM]: type of shader (vertex, pixel, etc.)
- state [BOOLEAN]: live coding: 1 (enabled) or 0 (disabled)
Return Values
This function has no return value(s).
Code sample
GPU_SHADER_VERTEX = 0
GPU_SHADER_PIXEL = 1
GPU_SHADER_GEOMETRY = 2
GPU_SHADER_TESS_CONTROL = 3
GPU_SHADER_TESS_EVAL = 4
GPU_SHADER_COMPUTE = 5
shader_type = GPU_SHADER_PIXEL
state = 1
gh_gpu_program.set_livecoding_state(gpuprog_id, shader_type, state)
set_shader_storage_block_binding
Description
Sets the buffer binding point of a shader storage block.
Syntax
gh_gpu_program.set_shader_storage_block_binding(
gpuprog_id,
block_index,
binding_point_index
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- block_index [INTEGER]: block index
- binding_point_index [INTEGER]: index of a GPU buffer binding point
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.set_shader_storage_block_binding(gpuprog_id, index, 3)
set_uniform_block_binding
Description
Sets the buffer binding point of an uniform block.
Syntax
gh_gpu_program.set_uniform_block_binding(
gpuprog_id,
block_index,
binding_point_index
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- block_index [INTEGER]: block index
- binding_point_index [INTEGER]: index of a GPU buffer binding point
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.set_uniform_block_binding(gpuprog_id, index, 2)
set_vertex_attrib_name
Description
Sets the name of a vertex attribute.
Syntax
gh_gpu_program.set_vertex_attrib_name(
gpuprog_id,
vertex_index,
name
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- vertex_index [INTEGER]: vertex attribute index
- name [STRING]: vertex attrib name
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.set_vertex_attrib_name(gpuprog_id, 0, "gxl3d_Position")
uniform1d
Description
Sets the value of an FP64 uniform variable.
Syntax
gh_gpu_program.uniform1d(
gpuprog_id,
uniform_name,
x
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- x [REAL]: uniform value
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1d(gpuprog_id, "r", 0.25)
uniform1f
Description
Sets the value of an uniform variable.
Syntax
gh_gpu_program.uniform1f(
gpuprog_id,
uniform_name,
x
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- x [REAL]: uniform value
Return Values
This function has no return value(s).
Code sample
elapsed_time = gh_utils.get_elapsed_time()
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1f(gpuprog_id, "time", elapsed_time)
uniform1fv
Description
Sets the value of an uniform array.
Syntax
gh_gpu_program.uniform1fv(
gpuprog_id,
uniform_name,
array_count,
array
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- array_count [INTEGER]: number of entries of the uniform array
- array [TABLE]: uniform array
Return Values
This function has no return value(s).
Code sample
temperatures = {}
temperatures[1] = 20.0
temperatures[2] = 21.0
temperatures[3] = 24.0
temperatures[4] = 29.0
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1fv(gpuprog_id, "temperatures", 4, temperatures)
uniform1i
Description
Sets the value of an uniform variable.
Syntax
gh_gpu_program.uniform1i(
gpuprog_id,
uniform_name,
x
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- x [INTEGER]: uniform value
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1i(gpuprog_id, "index", 2)
uniform1iv
Description
Sets the value of an uniform array.
Syntax
gh_gpu_program.uniform1iv(
gpuprog_id,
uniform_name,
array_count,
array
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- array_count [INTEGER]: number of entries of the uniform array
- array [TABLE]: uniform array
Return Values
This function has no return value(s).
Code sample
material_ids = {}
InitMaterialIDs(material_ids)
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1iv(gpuprog_id, "material_ids", material_ids, 10)
uniform1ui64
Description
Sets the value of an uniform variable. Useful with bindless texture (OpenGL 4.4).
Syntax
gh_gpu_program.uniform1ui64(
gpuprog_id,
uniform_name,
x
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- x [INTEGER]: uniform value
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1ui64(gpuprog_id, "tex", bindless_texture_handle)
uniform1ui64v
Description
Sets the value of an uniform array. Useful with bindless texture (OpenGL 4.4).
Syntax
gh_gpu_program.uniform1ui64v(
gpuprog_id,
uniform_name,
array_count,
array
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- array_count [INTEGER]: number of entries of the uniform array
- array [TABLE]: uniform array
Return Values
This function has no return value(s).
Code sample
all_texture_handles = {}
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform1ui64v(gpuprog_id, "all_textures", 32, all_texture_handles)
uniform2d
Description
Sets the value of an FP64 uniform variable.
Syntax
gh_gpu_program.uniform2d(
gpuprog_id,
uniform_name,
x, y
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- x, y [REAL]: uniform value
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform2d(gpuprog_id, "rg", 0.25, 0.22)
uniform2f
Description
Sets the value of an uniform variable.
Syntax
gh_gpu_program.uniform2f(
gpuprog_id,
uniform_name,
x, y
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- x, y [REAL]: uniform value
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform2f(gpuprog_id, "uv", 0.1, 1.0)
uniform2fv
Description
Sets the value of an uniform array.
Syntax
gh_gpu_program.uniform2fv(
gpuprog_id,
uniform_name,
array_count,
array
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- array_count [INTEGER]: number of entries of the uniform array
- array [TABLE]: uniform array (lua: array - Python: list). In Lua, each element must be: {x=..., y=...}. In Python, each element is a tuple: (0.25, 0.59)
Return Values
This function has no return value(s).
Code sample
uv = {}
uv[1]={x=0, y=0}
uv[2]={x=0.2, y=0}
uv[3]={x=0.4, y=0.2}
uv[4]={x=0.6, y=0.25}
uv[5]={x=0.8, y=0.5}
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform2fv(gpuprog_id, "uv", 5, uv)
uniform2i
Description
Sets the value of an uniform variable.
Syntax
gh_gpu_program.uniform2i(
gpuprog_id,
uniform_name,
x, y
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- x, y [INTEGER]: uniform value
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform2i(gpuprog_id, "rg", 250, 25)
uniform3d
Description
Sets the value of an FP64 uniform variable.
Syntax
gh_gpu_program.uniform3d(
gpuprog_id,
uniform_name,
x, y, z
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- x, y, z [REAL]: uniform value
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform3d(gpuprog_id, "rgb", 0.25, 0.25, 0.45)
uniform3f
Description
Sets the value of an uniform variable.
Syntax
gh_gpu_program.uniform3f(
gpuprog_id,
uniform_name,
x, y, z
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- x, y, z [REAL]: uniform value
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform3f(gpuprog_id, "rgb", 0.25, 0.25, 0.45)
uniform3fv
Description
Sets the value of an uniform array.
Syntax
gh_gpu_program.uniform3fv(
gpuprog_id,
uniform_name,
array_count,
array
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- array_count [INTEGER]: number of entries of the uniform array
- array [TABLE]: uniform array (lua: array - Python: list). In Lua, each element must be: {x=..., y=..., z=...}. In Python, each element is a tuple: (0.25, 0.59, 0.0)
Return Values
This function has no return value(s).
Code sample
xyz = {} -- array element: {x=0, y=0, z=0}
InitXYZ(xyz)
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform3fv(gpuprog_id, "xyz", 10, xyz)
uniform3i
Description
Sets the value of an uniform variable.
Syntax
gh_gpu_program.uniform3i(
gpuprog_id,
uniform_name,
x, y, z
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- x, y, z [INTEGER]: uniform value
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform3i(gpuprog_id, "rgb", 250, 25, 45)
uniform4d
Description
Sets the value of an FP64 uniform variable.
Syntax
gh_gpu_program.uniform4d(
gpuprog_id,
uniform_name,
x, y, z, w
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- x, y, z, w [REAL]: uniform value
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform4d(gpuprog_id, "rgba", 0.25, 0.25, 0.45, 1.0)
uniform4f
Description
Sets the value of an uniform variable.
Syntax
gh_gpu_program.uniform4f(
gpuprog_id,
uniform_name,
x, y, z, w
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- x, y, z, w [REAL]: uniform value
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform4f(gpuprog_id, "rgba", 0.25, 0.25, 0.45, 1.0)
uniform4f_array
Description
Sets the value of an uniform array of vec4. Currently limited to one vec4.
Syntax
gh_gpu_program.uniform4f_array(
gpuprog_id,
uniform_name,
x, y, z, w
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- x, y, z, w [REAL]: Uniform value. The four elements of an uniform array: float xyzw[4]
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform4f_array(gpuprog_id, "all_params", 0.2, 10.4, 0.003, 0.001)
uniform4fv
Description
Sets the value of an uniform array.
Syntax
gh_gpu_program.uniform4fv(
gpuprog_id,
uniform_name,
array_count,
array
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- array_count [INTEGER]: number of entries of the uniform array
- array [TABLE]: uniform array (lua: array - Python: list). In Lua, each element must be: {x=..., y=..., z=..., w=...}. In Python, each element is a tuple: (0.25, 0.59, 0.0, 1.0)
Return Values
This function has no return value(s).
Code sample
xyzw = {} -- array element: {x=0, y=0, z=0, w=0}
InitXYZW(xyzw)
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform4fv(gpuprog_id, "xyzw", 10, xyzw)
uniform4i
Description
Sets the value of an uniform variable.
Syntax
gh_gpu_program.uniform4i(
gpuprog_id,
uniform_name,
x, y, z, w
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- x, y, z, w [INTEGER]: uniform value
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform4i(gpuprog_id, "rgba", 250, 25, 45, 100)
uniform4i_array
Description
Sets the value of an uniform array of vec4i. Currently limited to one vec4i.
Syntax
gh_gpu_program.uniform4i_array(
gpuprog_id,
uniform_name,
x, y, z, w
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- x, y, z, w [INTEGER]: Uniform value. The four elements of an uniform array: int xyzw[4]
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.bind(gpuprog_id)
gh_gpu_program.uniform4i_array(gpuprog_id, "all_textures", 0, 1, 2, 3)
uniform_3x3f
Description
Sets a 3x3 matrix uniform.
Syntax
gh_gpu_program.uniform_3x3f(
gpuprog_id,
uniform_name,
m0,m1,m2,m3,m4,m5,m6,m7,m8
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- m0,m1,m2,m3,m4,m5,m6,m7,m8 [REAL]: the 9 floats that make the 3x3 matrix
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.uniform_3x3f(gpuprog_id, "rotMatrix", m0,m1,m2,m3,m4,m5,m6,m7,m8)
uniform_4x4f
Description
Sets a 4x4 matrix uniform.
Syntax
gh_gpu_program.uniform_4x4f(
gpuprog_id,
uniform_name,
m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_name [STRING]: uniform name
- m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15 [REAL]: the 16 floats that make the 4x4 matrix
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.uniform_4x4f(gpuprog_id, "myMatrix", m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15)
uniform_camera_matrices
Description
Sets the matrices of a camera as uniforms.
Syntax
gh_gpu_program.uniform_camera_matrices(
gpuprog_id,
cam_id,
uniform_name_view_mat,
uniform_name_proj_mat
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- cam_id [ID]: camera identifier
- uniform_name_view_mat [STRING]: name of the view matrix
- uniform_name_proj_mat [STRING]: name of the projection matrix
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.uniform_camera_matrices(gpuprog_id, camera, "ViewMat", "ProjMat")
uniform_camera_matrices_v2
Description
Sets the matrices of a camera as uniforms.
Syntax
gh_gpu_program.uniform_camera_matrices_v2(
gpuprog_id,
cam_id,
uniform_name_view_mat,
uniform_name_proj_mat,
uniform_name_viewproj_mat
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- cam_id [ID]: camera identifier
- uniform_name_view_mat [STRING]: name of the view matrix
- uniform_name_proj_mat [STRING]: name of the projection matrix
- uniform_name_viewproj_mat [STRING]: name of the view projection matrix
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.uniform_camera_matrices_v2(gpuprog_id, camera, "ViewMat", "ProjMat", "ViewProjMat")
uniform_modelviewproj_matrices
Description
Sets the ModelViewProjection and ModelView matrices from a camera and an object.
Syntax
gh_gpu_program.uniform_modelviewproj_matrices(
gpuprog_id,
cam_id,
obj_id,
uniform_name_modelviewproj_mat,
uniform_name_modelview_mat
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- cam_id [ID]: camera identifier
- obj_id [ID]: object identifier
- uniform_name_modelviewproj_mat [STRING]: name of the model view projection matrix
- uniform_name_modelview_mat [STRING]: name of the model view matrix
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.uniform_modelviewproj_matrices(gpuprog_id, camera, mesh, "ModelViewProj", "ModelView")
uniform_object_matrix
Description
Sets the local matrix of an object as uniform.
Syntax
gh_gpu_program.uniform_object_matrix(
gpuprog_id,
obj_id,
uniform_name_mat
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- obj_id [ID]: object identifier
- uniform_name_mat [STRING]: name of the uniform variable
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.uniform_object_matrix(gpuprog_id, object, "ModelMat")
uniform_transform_matrix_v1
Description
Builds a matrix from position, rotation and scale and passes this matrix to the shader.
Syntax
gh_gpu_program.uniform_transform_matrix_v1(
gpuprog_id,
uniform_matrix_name,
posx, posy, posz,
pitch, yaw, roll,
sx, sy, sz,
transform_order
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_matrix_name [STRING]: name of the uniform variable
- posx, posy, posz [REAL]: 3D position
- pitch, yaw, roll [REAL]: Euler angles in degrees
- sx, sy, sz [REAL]: 3D scale
- transform_order [INTEGER]: order of transformation to build the matrix: 0 (ORDER_TRS - default), 1 (ORDER_RTS), 2 (ORDER_TSR) or 3 (ORDER_RST)
Return Values
This function has no return value(s).
Code sample
local transform_order = 0
gh_gpu_program.uniform_transform_matrix_v1(gpuprog_id, "ModelMatrix", posx, posy, posz, pitch, yaw, roll, sx, sy, sz, transform_order)
uniform_transform_matrix_v2
Description
Builds a matrix from position, rotation and scale and passes this matrix to the shader.
Syntax
gh_gpu_program.uniform_transform_matrix_v2(
gpuprog_id,
uniform_matrix_name,
posx, posy, posz,
qx, qy, qz, qw,
sx, sy, sz,
transform_order
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- uniform_matrix_name [STRING]: name of the uniform variable
- posx, posy, posz [REAL]: 3D position
- qx, qy, qz, qw [REAL]: Orientation quaternion
- sx, sy, sz [REAL]: 3D scale
- transform_order [INTEGER]: order of transformation to build the matrix: 0 (ORDER_TRS - default), 1 (ORDER_RTS), 2 (ORDER_TSR) or 3 (ORDER_RST)
Return Values
This function has no return value(s).
Code sample
local transform_order = 0
gh_gpu_program.uniform_transform_matrix_v1(gpuprog_id, "ModelMatrix", posx, posy, posz, qx, qy, qz, qw, sx, sy, sz, transform_order)
uniform_matrix
Description
Sets an uniform 4x4 matrix (mat4 in GLSL) built from the transformation matrix of an object (camera, mesh, etc.).
Syntax
gh_gpu_program.uniform_matrix(
gpuprog_id,
object_id,
uniform_name,
matrix_type,
upload_to_gpu
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- object_id [ID]: object identifier
- uniform_name [STRING]: name of the uniform 4x4 matrix
- matrix_type [INTEGER]: type of the matrix: 'camera_view_projection', 'camera_view', 'camera_inv_view', 'camera_projection', 'camera_inv_projection' 'object_local_tranform', 'object_global_tranform'
- upload_to_gpu [INTEGER]: If 1, the uniform value is immedialtly uploaded to the GPU. If 0, the value will be uploaded later during the rendering.
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.uniform_matrix(gpuprog_id, camera_id, "ViewMatrix", "camera_view")
gh_gpu_program.uniform_matrix(gpuprog_id, camera_id, "ProjMatrix", "camera_projection")
gh_gpu_program.uniform_matrix(gpuprog_id, object_id, "ModelMatrix", "object_global_tranform")
uniform_subroutine
Description
Sets the matrices of a camera as uniforms.
Syntax
gh_gpu_program.uniform_subroutine(
gpuprog_id,
shader_type,
subroutine_uniform_name,
subroutine_name
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- shader_type [ENUM]: type of shader (vertex, pixel, etc.)
- subroutine_uniform_name [STRING]: uniform name of the subroutine
- subroutine_name [STRING]: name of the real subroutine
Return Values
This function has no return value(s).
Code sample
GPU_SHADER_VERTEX = 0
GPU_SHADER_PIXEL = 1
GPU_SHADER_GEOMETRY = 2
GPU_SHADER_TESS_CONTROL = 3
GPU_SHADER_TESS_EVAL = 4
GPU_SHADER_COMPUTE = 5
gh_gpu_program.uniform_subroutine(gpuprog_id, GPU_SHADER_PIXEL, "Color", "ColorBlue")
vk_create_from_spirv_module_file
Description
Creates a Vulkan GPU program from SPIR-V modules.
Syntax
gpuprog_id = gh_gpu_program.vk_create_from_spirv_module_file(
program_name,
vs_fname, vs_entry_point,
ps_fname, ps_entry_point,
gs_fname, gs_entry_point,
tcs_fname, tcs_entry_point,
tes_fname, tes_entry_point,
cs_fname, cs_entry_point
)
Languages
Parameters
- program_name [STRING]: name of the GPU program
- vs_fname, vs_entry_point [STRING]: vertex shader: absolute path of the shader file, entry point name
- ps_fname, ps_entry_point [STRING]: pixel shader: ...
- gs_fname, gs_entry_point [STRING]: geometry shader: ...
- tcs_fname, tcs_entry_point [STRING]: tessellation control shader: ...
- tes_fname, tes_entry_point [STRING]: tessellation eval shader: ...
- cs_fname, cs_entry_point [STRING]: compute shader: ...
Return Values
- gpuprog_id [ID]: gpu program identifier
Code sample
local demo_dir = gh_utils.get_demo_dir()
vs = demo_dir .. "./shaders/vs.spv"
ps = demo_dir .. "./shaders/ps.spv"
gpuprog_id = gh_gpu_program.vk_create_from_spirv_module_file("LightingProg", vs,"main", ps,"main", "","", "","", "","", "","")
vk_create_from_spirv_module_zip
Description
Creates a Vulkan GPU program from SPIR-V modules stored in a zip archive.
Syntax
gpuprog_id = gh_gpu_program.vk_create_from_spirv_module_zip(
zip_filename,
program_name,
vs_fname, vs_entry_point,
ps_fname, ps_entry_point,
gs_fname, gs_entry_point,
tcs_fname, tcs_entry_point,
tes_fname, tes_entry_point,
cs_fname, cs_entry_point
)
Languages
Parameters
- zip_filename [STRING]: absolute path to the zip archive
- program_name [STRING]: name of the GPU program
- vs_fname, vs_entry_point [STRING]: vertex shader: absolute path of the shader file, entry point name
- ps_fname, ps_entry_point [STRING]: pixel shader: ...
- gs_fname, gs_entry_point [STRING]: geometry shader: ...
- tcs_fname, tcs_entry_point [STRING]: tessellation control shader: ...
- tes_fname, tes_entry_point [STRING]: tessellation eval shader: ...
- cs_fname, cs_entry_point [STRING]: compute shader: ...
Return Values
- gpuprog_id [ID]: gpu program identifier
Code sample
local demo_dir = gh_utils.get_demo_dir()
zipfile = demo_dir .. "data.zip"
vs = "shaders/vs.spv"
ps = "shaders/ps.spv"
gpuprog_id = gh_gpu_program.vk_create_from_spirv_module_zip(zipfile, "LightingProg", vs,"main", ps,"main", "","", "","", "","", "","")
vk_create_mesh_task_from_spirv_module_file
Description
Creates a Vulkan GPU mesh shader program from SPIR-V modules.
Syntax
gpuprog_id = gh_gpu_program.vk_create_mesh_task_from_spirv_module_file(
program_name,
ms_fname, ms_entry_point,
ts_fname, ts_entry_point,
ps_fname, ps_entry_point
)
Languages
Parameters
- program_name [STRING]: name of the GPU program
- ms_fname, ms_entry_point [STRING]: mesh shader: absolute path of the shader file, entry point name
- ts_fname, ts_entry_point [STRING]: task shader: ...
- ps_fname, ps_entry_point [STRING]: pixel shader: ...
Return Values
- gpuprog_id [ID]: gpu program identifier
Code sample
local demo_dir = gh_utils.get_demo_dir()
ms = demo_dir .. "./shaders/ms.spv"
ps = demo_dir .. "./shaders/ps.spv"
meshprog = gh_gpu_program.vk_create_mesh_task_from_spirv_module_file("MeshProg", ms,"main", "","", ps,"main")
vk_create_mesh_task_from_spirv_module_zip
Description
Creates a Vulkan GPU mesh shader program from SPIR-V modules stored in a zip archive.
Syntax
gpuprog_id = gh_gpu_program.vk_create_mesh_task_from_spirv_module_zip(
zip_filename,
program_name,
ms_fname, ms_entry_point,
ts_fname, ts_entry_point,
ps_fname, ps_entry_point
)
Languages
Parameters
- zip_filename [STRING]: absolute path to the zip archive
- program_name [STRING]: name of the GPU program
- ms_fname, ms_entry_point [STRING]: mesh shader: absolute path of the shader file, entry point name
- ts_fname, ts_entry_point [STRING]: task shader: ...
- ps_fname, ps_entry_point [STRING]: pixel shader: ...
Return Values
- gpuprog_id [ID]: gpu program identifier
Code sample
local demo_dir = gh_utils.get_demo_dir()
zipfile = demo_dir .. "data.zip"
ms = "shaders/ms.spv"
ps = "shaders/ps.spv"
meshprog = gh_gpu_program.vk_create_mesh_task_from_spirv_module_zip(zipfile, "MeshProg", ms,"main", "","", ps,"main")
vk_create_from_smolv_module_file
Description
Creates a Vulkan GPU program from SMOL-V (compressed SPIR-V) modules.
Syntax
gpuprog_id = gh_gpu_program.vk_create_from_smolv_module_file(
program_name,
vs_fname, vs_entry_point,
ps_fname, ps_entry_point,
gs_fname, gs_entry_point,
tcs_fname, tcs_entry_point,
tes_fname, tes_entry_point,
cs_fname, cs_entry_point
)
Languages
Parameters
- program_name [STRING]: name of the GPU program
- vs_fname, vs_entry_point [STRING]: vertex shader: absolute path of the shader file, entry point name
- ps_fname, ps_entry_point [STRING]: pixel shader: ...
- gs_fname, gs_entry_point [STRING]: geometry shader: ...
- tcs_fname, tcs_entry_point [STRING]: tessellation control shader: ...
- tes_fname, tes_entry_point [STRING]: tessellation eval shader: ...
- cs_fname, cs_entry_point [STRING]: compute shader: ...
Return Values
- gpuprog_id [ID]: gpu program identifier
Code sample
local demo_dir = gh_utils.get_demo_dir()
vs = demo_dir .. "./shaders/vs.spv"
ps = demo_dir .. "./shaders/ps.spv"
gpuprog_id = gh_gpu_program.vk_create_from_smolv_module_file("LightingProg", vs,"main", ps,"main", "","", "","", "","", "","")
create_gl_spirv
Description
Creates a GPU program for OpenGL from SPIR-V modules. The name of the entry point of SPIR-V modules must be 'main'.
Syntax
gpuprog_id = gh_gpu_program.create_gl_spirv(
program_name,
vs,
ps,
gs,
tcs,
tes,
cs
)
Languages
Parameters
- program_name [STRING]: name of the GPU program
- vs [STRING]: vertex shader source code
- ps [STRING]: pixel shader source code
- gs [STRING]: geometry shader source code
- tcs [STRING]: tessellation control shader source code
- tes [STRING]: tessellation eval shader source code
- cs [STRING]: compute shader source code
Return Values
- gpuprog_id [ID]: gpu program identifier
Code sample
local demo_dir = gh_utils.get_demo_dir()
vs = "void main(){ ... }"
ps = "void main(){ ... }"
gs = ""
tcs = ""
tes = ""
cs = ""
gpuprog_id = gh_gpu_program.create_gl_spirv("prog", vs, ps, gs, tcs, tes, cs)
create_from_shader_files_gl_spirv
Description
Creates a GPU program for OpenGL from SPIR-V module files. The name of the entry point of SPIR-V modules must be 'main'.
Syntax
gpuprog_id = gh_gpu_program.create_from_shader_files_gl_spirv(
program_name,
vs_fname,
ps_fname,
gs_fname,
tcs_fname,
tes_fname,
cs_fname
)
Languages
Parameters
- program_name [STRING]: name of the GPU program
- vs_fname [STRING]: vertex shader: absolute path of the SPIR-V file
- ps_fname [STRING]: pixel shader: absolute path of the SPIR-V file
- gs_fname [STRING]: geometry shader: absolute path of the SPIR-V file
- tcs_fname [STRING]: tessellation control shader: absolute path of the SPIR-V file
- tes_fname [STRING]: tessellation eval shader: absolute path of the SPIR-V file
- cs_fname [STRING]: compute shader: absolute path of the SPIR-V file
Return Values
- gpuprog_id [ID]: gpu program identifier
Code sample
local demo_dir = gh_utils.get_demo_dir()
vs = demo_dir .. "./shaders/vs.spv"
ps = demo_dir .. "./shaders/ps.spv"
gs = ""
tcs = ""
tes = ""
cs = ""
gpuprog_id = gh_gpu_program.create_from_shader_files_gl_spirv("prog", vs, ps, gs, tcs, tes, cs)
create_mesh_task_from_shader_files_gl_spirv
Description
Creates a GPU mesh shader program for OpenGL from SPIR-V module files. The name of the entry point of SPIR-V modules must be 'main'.
Syntax
gpuprog_id = gh_gpu_program.create_mesh_task_from_shader_files_gl_spirv(
program_name,
ms_fname,
ts_fname,
ps_fname
)
Languages
Parameters
- program_name [STRING]: name of the GPU program
- ms_fname [STRING]: mesh shader: absolute path of the SPIR-V file
- ts_fname [STRING]: task shader: absolute path of the SPIR-V file
- ps_fname [STRING]: pixel shader: absolute path of the SPIR-V file
Return Values
- gpuprog_id [ID]: gpu program identifier
Code sample
local demo_dir = gh_utils.get_demo_dir()
ms = demo_dir .. "./shaders/ms.spv"
ps = demo_dir .. "./shaders/ps.spv"
ts = ""
meshprog = gh_gpu_program.create_mesh_task_from_shader_files_gl_spirv("prog", ms, ts, ps)
create_from_shader_files_gl_smolv
Description
Creates a GPU program for OpenGL from SMOL-V (compressed SPIR-V) module files. The name of the entry point of SPIR-V modules must be 'main'.
Syntax
gpuprog_id = gh_gpu_program.create_from_shader_files_gl_smolv(
program_name,
vs_fname,
ps_fname,
gs_fname,
tcs_fname,
tes_fname,
cs_fname
)
Languages
Parameters
- program_name [STRING]: name of the GPU program
- vs_fname [STRING]: vertex shader: absolute path of the SMOL-V file
- ps_fname [STRING]: pixel shader: absolute path of the SMOL-V file
- gs_fname [STRING]: geometry shader: absolute path of the SMOL-V file
- tcs_fname [STRING]: tessellation control shader: absolute path of the SMOL-V file
- tes_fname [STRING]: tessellation eval shader: absolute path of the SMOL-V file
- cs_fname [STRING]: compute shader: absolute path of the SMOL-V file
Return Values
- gpuprog_id [ID]: gpu program identifier
Code sample
local demo_dir = gh_utils.get_demo_dir()
vs = demo_dir .. "./shaders/vs.spv"
ps = demo_dir .. "./shaders/ps.spv"
gs = ""
tcs = ""
tes = ""
cs = ""
gpuprog_id = gh_gpu_program.create_from_shader_files_gl_smolv("prog", vs, ps, gs, tcs, tes, cs)
create_from_zip_file_gl_spirv
Description
Creates a GPU program for OpenGL from SPIR-V module files in a zip archive. The name of the entry point of SPIR-V modules must be 'main'.
Syntax
gpuprog_id = gh_gpu_program.create_from_zip_file_gl_spirv(
zip_fname,
program_name,
vs_fname,
ps_fname,
gs_fname,
tcs_fname,
tes_fname,
cs_fname
)
Languages
Parameters
- zip_fname [STRING]: absolute path to the zip file
- program_name [STRING]: name of the GPU program
- vs_fname [STRING]: vertex shader: path of the SPIR-V file in the zip archive
- ps_fname [STRING]: pixel shader: path of the SPIR-V file in the zip archive
- gs_fname [STRING]: geometry shader: path of the SPIR-V file in the zip archive
- tcs_fname [STRING]: tessellation control shader: path of the SPIR-V file in the zip archive
- tes_fname [STRING]: tessellation eval shader: path of the SPIR-V file in the zip archive
- cs_fname [STRING]: compute shader: path of the SPIR-V file in the zip archive
Return Values
- gpuprog_id [ID]: gpu program identifier
Code sample
local demo_dir = gh_utils.get_demo_dir()
zip_fname = demo_dir .. "data.zip"
vs = demo_dir .. "./shaders/vs.spv"
ps = demo_dir .. "./shaders/ps.spv"
gs = ""
tcs = ""
tes = ""
cs = ""
gpuprog_id = gh_gpu_program.create_from_shader_files_gl_spirv(zip_fname, "prog", vs, ps, gs, tcs, tes, cs)
update_shader_from_file
Description
Updates an shader of an existing GPU program.
Syntax
gh_gpu_program.update_shader_from_file(
gpuprog_id,
filename,
is_abs_path,
shader_type
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- filename [STRING]: shader filename
- is_abs_path [INTEGER]: filename is specified with an absolute (1) or relative (0) path
- shader_type [STRING]: type of shader: vertex, pixel, geometry, tess_control, tess_eval, compute, mesh, task)
Return Values
This function has no return value(s).
Code sample
gh_gpu_program.update_shader_from_file(gpuprog_id, "data/ps.txt", 0, "pixel")
update_shader_from_memory
Description
Updates an shader of an existing GPU program.
Syntax
gh_gpu_program.update_shader_from_memory(
gpuprog_id,
shader_code,
shader_type
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- shader_code [STRING]: shader code (a string)
- shader_type [STRING]: type of shader: vertex, pixel, geometry, tess_control, tess_eval, compute, mesh, task)
Return Values
This function has no return value(s).
Code sample
pixel_shader = "....."
gh_gpu_program.update_shader_from_memory(gpuprog_id, pixel_shader, "pixel")
vk_add_spirv_module_file
Description
Adds a SPIR-V module from a regular file to an existing GPU program.
Syntax
gh_gpu_program.vk_add_spirv_module_file(
gpuprog_id,
filename,
entry_point,
shader_type
)
Languages
Parameters
- gpuprog_id [ID]: gpu program identifier
- filename [STRING]: filename of the SPIR-V module
- entry_point [STRING]: entry point of the SPIR-V module. Usually main.
- shader_type [INTEGER]: type of the shader: vertex, pixel, tessellation, geometry, raygen, etc.
Return Values
This function has no return value(s).
Code sample
demo_dir = gh_utils.get_demo_dir()
filename_vs = demo_dir .. "./spirv/vs.spv"
filename_ps = demo_dir .. "./spirv/ps.spv"
GPU_SHADER_VERTEX = 0
GPU_SHADER_PIXEL = 1
GPU_SHADER_GEOMETRY = 2
GPU_SHADER_TESS_CONTROL = 3
GPU_SHADER_TESS_EVAL = 4
GPU_SHADER_COMPUTE = 5
GPU_SHADER_MESH_NV = 6
GPU_SHADER_TASK_NV = 7
GPU_SHADER_RT_RAYGEN = 8
GPU_SHADER_RT_ANY_HIT = 9
GPU_SHADER_RT_CLOSEST_HIT = 10
GPU_SHADER_RT_MISS = 11
GPU_SHADER_RT_INTERSECTION = 12
prog = gh_gpu_program.create_empty("gpu_prog")
gh_gpu_program.vk_add_spirv_module_file(prog, filename_vs, "main", GPU_SHADER_VERTEX)
gh_gpu_program.vk_add_spirv_module_file(prog, filename_ps, "main", GPU_SHADER_PIXEL)
vk_add_spirv_module_zip
Description
Adds a SPIR-V module (from a zip file) to an existing GPU program.
Syntax
gh_gpu_program.vk_add_spirv_module_zip(
zip_filename,
gpuprog_id,
filename,
entry_point,
shader_type
)
Languages
Parameters
- zip_filename [STRING]: filename of the zip archive
- gpuprog_id [ID]: gpu program identifier
- filename [STRING]: filename of the SPIR-V module in the zip archive
- entry_point [STRING]: entry point of the SPIR-V module. Usually main.
- shader_type [INTEGER]: type of the shader: vertex, pixel, tessellation, geometry, raygen, etc.
Return Values
This function has no return value(s).
Code sample
demo_dir = gh_utils.get_demo_dir()
zip_filename = demo_dir .. "data.zip"
filename_vs = "spirv/vs.spv"
filename_ps = "spirv/ps.spv"
GPU_SHADER_VERTEX = 0
GPU_SHADER_PIXEL = 1
GPU_SHADER_GEOMETRY = 2
GPU_SHADER_TESS_CONTROL = 3
GPU_SHADER_TESS_EVAL = 4
GPU_SHADER_COMPUTE = 5
GPU_SHADER_MESH_NV = 6
GPU_SHADER_TASK_NV = 7
GPU_SHADER_RT_RAYGEN = 8
GPU_SHADER_RT_ANY_HIT = 9
GPU_SHADER_RT_CLOSEST_HIT = 10
GPU_SHADER_RT_MISS = 11
GPU_SHADER_RT_INTERSECTION = 12
prog = gh_gpu_program.create_empty("gpu_prog")
gh_gpu_program.vk_add_spirv_module_zip(zip_filename, prog, filename_vs, "main", GPU_SHADER_VERTEX)
gh_gpu_program.vk_add_spirv_module_zip(zip_filename, prog, filename_ps, "main", GPU_SHADER_PIXEL)
| |