< 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: 63

  1. gh_gpu_program.add_shader_from_buffer ()
  2. gh_gpu_program.bind ()
  3. gh_gpu_program.create ()
  4. gh_gpu_program.create_empty ()
  5. gh_gpu_program.create_from_file ()
  6. gh_gpu_program.create_from_file_v3 ()
  7. gh_gpu_program.create_from_shader_files ()
  8. gh_gpu_program.create_mesh_task_from_shader_files ()
  9. gh_gpu_program.create_from_zip_file ()
  10. gh_gpu_program.create_v2 ()
  11. gh_gpu_program.get_interface_block_index ()
  12. gh_gpu_program.get_uniform_array_stride ()
  13. gh_gpu_program.get_uniform_block_size ()
  14. gh_gpu_program.get_uniform_size_and_offset ()
  15. gh_gpu_program.get_vertex_attrib_name ()
  16. gh_gpu_program.run_compute ()
  17. gh_gpu_program.run_compute_group_size ()
  18. gh_gpu_program.set_livecoding_state ()
  19. gh_gpu_program.set_shader_storage_block_binding ()
  20. gh_gpu_program.set_uniform_block_binding ()
  21. gh_gpu_program.set_vertex_attrib_name ()
  22. gh_gpu_program.uniform1d ()
  23. gh_gpu_program.uniform1f ()
  24. gh_gpu_program.uniform1fv ()
  25. gh_gpu_program.uniform1i ()
  26. gh_gpu_program.uniform1iv ()
  27. gh_gpu_program.uniform1ui64 ()
  28. gh_gpu_program.uniform1ui64v ()
  29. gh_gpu_program.uniform2d ()
  30. gh_gpu_program.uniform2f ()
  31. gh_gpu_program.uniform2fv ()
  32. gh_gpu_program.uniform2i ()
  33. gh_gpu_program.uniform3d ()
  34. gh_gpu_program.uniform3f ()
  35. gh_gpu_program.uniform3fv ()
  36. gh_gpu_program.uniform3i ()
  37. gh_gpu_program.uniform4d ()
  38. gh_gpu_program.uniform4f ()
  39. gh_gpu_program.uniform4f_array ()
  40. gh_gpu_program.uniform4fv ()
  41. gh_gpu_program.uniform4i ()
  42. gh_gpu_program.uniform4i_array ()
  43. gh_gpu_program.uniform_3x3f ()
  44. gh_gpu_program.uniform_4x4f ()
  45. gh_gpu_program.uniform_camera_matrices ()
  46. gh_gpu_program.uniform_camera_matrices_v2 ()
  47. gh_gpu_program.uniform_modelviewproj_matrices ()
  48. gh_gpu_program.uniform_object_matrix ()
  49. gh_gpu_program.uniform_transform_matrix_v1 ()
  50. gh_gpu_program.uniform_transform_matrix_v2 ()
  51. gh_gpu_program.uniform_subroutine ()
  52. gh_gpu_program.vk_create_from_spirv_module_file ()
  53. gh_gpu_program.vk_create_from_spirv_module_zip ()
  54. gh_gpu_program.vk_create_mesh_task_from_spirv_module_file ()
  55. gh_gpu_program.vk_create_mesh_task_from_spirv_module_zip ()
  56. gh_gpu_program.vk_create_from_smolv_module_file ()
  57. gh_gpu_program.create_gl_spirv ()
  58. gh_gpu_program.create_from_shader_files_gl_spirv ()
  59. gh_gpu_program.create_mesh_task_from_shader_files_gl_spirv ()
  60. gh_gpu_program.create_from_shader_files_gl_smolv ()
  61. gh_gpu_program.create_from_zip_file_gl_spirv ()
  62. gh_gpu_program.update_shader_from_file ()
  63. gh_gpu_program.update_shader_from_memory ()



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


Return Values


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


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


Return Values


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


Return Values


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


Return Values


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


Return Values


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


Return Values


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


Return Values


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


Return Values


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


Return Values


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


Return Values


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


Return Values


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


Return Values


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


Return Values


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


Return Values


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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_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


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


Return Values


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


Return Values


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


Return Values


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


Return Values


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


Return Values


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


Return Values


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


Return Values


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


Return Values


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


Return Values


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


Return Values


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


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


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")
			






GeeXLab Rootard Guide | Downloads | Contact | Newsletter