MCPcopy Create free account
hub / github.com/defold/defold / DispatchCompute

Function DispatchCompute

engine/render/src/render/render.cpp:1099–1163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1097 }
1098
1099 void DispatchCompute(HRenderContext render_context, uint32_t group_count_x, uint32_t group_count_y, uint32_t group_count_z, HNamedConstantBuffer constant_buffer)
1100 {
1101 HComputeProgram compute_program = render_context->m_ComputeProgram;
1102
1103 if (compute_program == 0)
1104 {
1105 return;
1106 }
1107
1108 dmGraphics::HContext context = dmRender::GetGraphicsContext(render_context);
1109 dmGraphics::HTexture render_context_textures[RenderObject::MAX_TEXTURE_COUNT] = {};
1110
1111 dmGraphics::EnableProgram(context, compute_program->m_Program);
1112
1113 ApplyComputeProgramConstants(render_context, compute_program);
1114
1115 if (constant_buffer)
1116 {
1117 ApplyNamedConstantBuffer(render_context, compute_program, constant_buffer);
1118 }
1119
1120 GetRenderContextTextures(render_context, compute_program->m_Samplers, render_context_textures);
1121
1122 uint8_t next_texture_unit = 0;
1123 for (uint32_t i = 0; i < RenderObject::MAX_TEXTURE_COUNT; ++i)
1124 {
1125 if (render_context_textures[i])
1126 {
1127 dmGraphics::HTexture texture = render_context_textures[i];
1128
1129 uint32_t num_texture_handles = dmGraphics::GetNumTextureHandles(context, texture);
1130 for (int sub_handle = 0; sub_handle < num_texture_handles; ++sub_handle)
1131 {
1132 dmGraphics::EnableTexture(context, next_texture_unit, sub_handle, texture);
1133
1134 HSampler sampler = GetProgramSampler(compute_program->m_Samplers, next_texture_unit);
1135 ApplyProgramSampler(render_context, sampler, next_texture_unit, texture);
1136
1137 next_texture_unit++;
1138 }
1139 }
1140 }
1141
1142 ApplyComputeProgramLightBuffers(render_context, compute_program);
1143
1144 dmGraphics::DispatchCompute(context, group_count_x, group_count_y, group_count_z);
1145
1146 next_texture_unit = 0;
1147 for (uint32_t i = 0; i < RenderObject::MAX_TEXTURE_COUNT; ++i)
1148 {
1149 if (render_context_textures[i])
1150 {
1151 dmGraphics::HTexture texture = render_context_textures[i];
1152 uint32_t num_texture_handles = dmGraphics::GetNumTextureHandles(context, texture);
1153 for (int sub_handle = 0; sub_handle < num_texture_handles; ++sub_handle)
1154 {
1155 dmGraphics::DisableTexture(context, next_texture_unit, texture);
1156 next_texture_unit++;

Callers 1

ParseCommandsFunction · 0.70

Calls 13

GetGraphicsContextFunction · 0.85
EnableProgramFunction · 0.85
ApplyNamedConstantBufferFunction · 0.85
GetRenderContextTexturesFunction · 0.85
GetNumTextureHandlesFunction · 0.85
EnableTextureFunction · 0.85
GetProgramSamplerFunction · 0.85
ApplyProgramSamplerFunction · 0.85
DisableTextureFunction · 0.85
DisableProgramFunction · 0.85

Tested by

no test coverage detected