diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-02-01 20:32:47 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-02-01 21:05:22 +0300 |
commit | f39ade9e00fc24be6f45b33b391b3d6bfa6fee9f (patch) | |
tree | e7b2b0e3a9f5639e7f9872749ebdae454639228f /source | |
parent | 9505af72d4be79cb0c1ce1678db2e392ba74804d (diff) |
GPUShader: Rename createInfo storage Qualifiers
Using opt-in instead of opt-out to make code easier to read.
Add combined flag enum.
Making restrict an inverse flag option because it is so rare to
use it.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/draw/intern/shaders/draw_hair_refine_info.hh | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_shader_create_info.hh | 11 | ||||
-rw-r--r-- | source/blender/gpu/opengl/gl_shader.cc | 10 |
3 files changed, 13 insertions, 10 deletions
diff --git a/source/blender/draw/intern/shaders/draw_hair_refine_info.hh b/source/blender/draw/intern/shaders/draw_hair_refine_info.hh index b41be7d8605..bdfc26b7dcd 100644 --- a/source/blender/draw/intern/shaders/draw_hair_refine_info.hh +++ b/source/blender/draw/intern/shaders/draw_hair_refine_info.hh @@ -25,7 +25,7 @@ GPU_SHADER_CREATE_INFO(draw_hair_refine_compute) .local_group_size(1, 1) - .storage_buf(0, Qualifier::WRITE_ONLY, "vec4", "posTime[]") + .storage_buf(0, Qualifier::WRITE, "vec4", "posTime[]") .sampler(0, ImageType::FLOAT_BUFFER, "hairPointBuffer") .sampler(1, ImageType::UINT_BUFFER, "hairStrandBuffer") .sampler(2, ImageType::UINT_BUFFER, "hairStrandSegBuffer") diff --git a/source/blender/gpu/intern/gpu_shader_create_info.hh b/source/blender/gpu/intern/gpu_shader_create_info.hh index e68f9929591..736a8ed0590 100644 --- a/source/blender/gpu/intern/gpu_shader_create_info.hh +++ b/source/blender/gpu/intern/gpu_shader_create_info.hh @@ -130,10 +130,13 @@ enum class ImageType { /* Storage qualifiers. */ enum class Qualifier { - RESTRICT = (1 << 0), - READ_ONLY = (1 << 1), - WRITE_ONLY = (1 << 2), - QUALIFIER_MAX = (WRITE_ONLY << 1) - 1, + /** Restrict flag is set by default. Unless specified otherwise. */ + NO_RESTRICT = (1 << 0), + READ = (1 << 1), + WRITE = (1 << 2), + /** Shorthand version of combined flags. */ + READ_WRITE = READ | WRITE, + QUALIFIER_MAX = (WRITE << 1) - 1, }; ENUM_OPERATORS(Qualifier, Qualifier::QUALIFIER_MAX); diff --git a/source/blender/gpu/opengl/gl_shader.cc b/source/blender/gpu/opengl/gl_shader.cc index 815c488cf8b..3a212eb165c 100644 --- a/source/blender/gpu/opengl/gl_shader.cc +++ b/source/blender/gpu/opengl/gl_shader.cc @@ -277,15 +277,15 @@ static void print_image_type(std::ostream &os, static std::ostream &print_qualifier(std::ostream &os, const Qualifier &qualifiers) { - if ((qualifiers & Qualifier::RESTRICT) == Qualifier::RESTRICT) { + if (bool(qualifiers & Qualifier::NO_RESTRICT) == false) { os << "restrict "; } - if ((qualifiers & Qualifier::READ_ONLY) == Qualifier::READ_ONLY) { - os << "readonly "; - } - if ((qualifiers & Qualifier::WRITE_ONLY) == Qualifier::WRITE_ONLY) { + if (bool(qualifiers & Qualifier::READ) == false) { os << "writeonly "; } + if (bool(qualifiers & Qualifier::WRITE) == false) { + os << "readonly "; + } return os; } |