Page MenuHome

GPU: Push Constants.
AbandonedPublic

Authored by Jeroen Bakker (jbakker) on Jun 30 2021, 5:12 PM.

Details

Summary

Push constants have been introduced with vulkan and the main difference with uniform buffers are that they are transported inside the command buffer and not bound.
Push constants buffers are limited to 128 bytes.

This patch adds the ability to add push constants to shaders. On the OpenGL backend the GLSL is patched to use uniform buffers. It contains:

  • Changes to GPU API to set push constants for a shader GPU_shader_uniform_push_constants.
  • GL_Shader will create a ubo to store the data locally. The UBO is updated when the push constants are changed. This saves some data management and matches closer to the workings of vulkan.
  • Adds test cases for to validate syntax checks.
  • Adds a Draw manager command for push commands. DRW_shgroup_call_push_constants
  • Use the mechanism in draw_hair compute shader. This is just an example and can be removed before this patch lands.

The GLSL source patches is a template for how to patch GLSL source code. In the vulkan branch a similar structure is needed for parsing binding names.

Diff Detail

Repository
rB Blender
Branch
temp-gpu-push-constants
Build Status
Buildable 15560
Build 15560: arc lint + arc unit

Event Timeline

Jeroen Bakker (jbakker) requested review of this revision.Jun 30 2021, 5:12 PM
Jeroen Bakker (jbakker) created this revision.
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Jun 30 2021, 5:16 PM
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Jun 30 2021, 5:19 PM
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Jun 30 2021, 7:44 PM
  • Refactored GLSL patching for future extension.
  • Cleanup: Renamed converter to patcher.
  • GPU: Added push constants to shader interface
  • GPU: Binding uniformbuffer as push constant.
  • DrawManager: Add push constants command.
  • GPU: Sizecheck for push constants buffer.
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Jul 2 2021, 4:40 PM
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Jul 2 2021, 4:43 PM
source/blender/draw/intern/draw_manager_data.c
531 ↗(On Diff #39049)

Revert codestyle change

863 ↗(On Diff #39049)

Remove check

source/blender/gpu/GPU_shader.h
161 ↗(On Diff #39049)

Add newline

source/blender/gpu/intern/gpu_shader.cc
565 ↗(On Diff #39049)

Lte

source/blender/gpu/opengl/gl_shader_interface.cc
326

Name doen not sure exist anymore.

  • Merge branch 'master' into temp-gpu-push-constants
  • Refactored to use remove the use of an uniform buffer in the API.
  • Fix memory leak.
  • Use push constants for draw hair offsets in compute shader.
Jeroen Bakker (jbakker) retitled this revision from [WIP] GPU: Push Constants. to GPU: Push Constants..Jul 5 2021, 4:29 PM
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Jul 5 2021, 4:39 PM
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)

GPUShaderCreateInfo uses a different approach better matching how we want to support other backends