Page MenuHome

Basic engine shaders test
ClosedPublic

Authored by Jarrett Johnson (jarrett.johnson) on Nov 2 2021, 8:58 AM.

Details

Summary

This patch adds shader compilation tests for the basic engine in shaders_test.cc

Addresses T92701

Diff Detail

Repository
rB Blender
Branch
basic_shaders_test (branched from master)
Build Status
Buildable 18380
Build 18380: arc lint + arc unit

Event Timeline

Jarrett Johnson (jarrett.johnson) requested review of this revision.Nov 2 2021, 8:58 AM
Jarrett Johnson (jarrett.johnson) created this revision.
Jarrett Johnson (jarrett.johnson) retitled this revision from Basic shaders test to Basic engine shaders test.Nov 2 2021, 9:16 AM
Jarrett Johnson (jarrett.johnson) edited the summary of this revision. (Show Details)
Jeroen Bakker (jbakker) requested changes to this revision.Nov 2 2021, 9:53 AM
Jeroen Bakker (jbakker) added inline comments.
source/blender/draw/CMakeLists.txt
217

basic_private.h should be added here.

source/blender/draw/engines/basic/basic_private.h
30

Is a private struct for basic_shaders.c no need to add it to a header file.

source/blender/draw/engines/basic/basic_shader.c
41

The interface of the *initialize* functions are a bit confusing.
It creates,compiles the shader, update the sh_data and returns the newly created instance.

Would rather use BASIC_shader_create_depth_sh that only creates, compiles and returns the newly shader.
The caller would be responsible to update the sh_data.

118

BasicEngine doesn't use a library yet (see image_shader.cc as example)
The *library_ensure functions is used to initialize a DRWShaderLibrary. Where the libs (here view_lib&pointcloud_lib) is added.
The shaders can then be constructed using DRW_shader_create_with_shaderlib

Perhaps it is better to remove the library_ensure function or implement this in a separate patch (only one change per patch).

122

We use a lazy initialization of shaders as done in the BASIC_shader_*_sh_get functions. no need to do this at this point.

183

Can use something like:

GPUShader **sh_data_as_array = (GPUShader **)sh_data;
for (int i = 0; i < (sizeof(BASIC_Shaders) / sizeof(GPUShader *)); i++) {
    DRW_SHADER_FREE_SAFE(sh_data_as_array[i]);
}
source/blender/draw/tests/shaders_test.cc
400

would call the int i and use static_cast to cast to the enum. Seems like this could also be done for test_overlay_glsl_shaders in a separate patch.

This revision now requires changes to proceed.Nov 2 2021, 9:53 AM
Jarrett Johnson (jarrett.johnson) marked 7 inline comments as done.
Jarrett Johnson (jarrett.johnson) edited the summary of this revision. (Show Details)
  • merge master
  • addressed comments
This revision is now accepted and ready to land.Nov 5 2021, 2:12 PM
This revision was automatically updated to reflect the committed changes.