From 7f7c614ecddbcb66de0bff1657366970dede99be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 17 Feb 2022 17:03:23 +0100 Subject: OCIO: Port shader creation logic to use GPUShaderCreateInfo This commit should suffice to make the shader API agnostic now (given that all users of it use the GPU API). This makes the shaders not trigger a false positive error anymore since the binding slots are now garanteed by the backend and not changed at after compilation. This also bundles all uniforms into UBOs. Making them extendable without limitations of push constants. The generated uniforms from OCIO are not densely packed in the UBO to avoid complexity. Another approach would be to use GPU_uniformbuf_create_from_list but this requires converting uniforms to GPUInputs which is too complex for what it is. Reviewed by: brecht, jbakker Differential Revision: https://developer.blender.org/D14123 --- intern/opencolorio/CMakeLists.txt | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'intern/opencolorio/CMakeLists.txt') diff --git a/intern/opencolorio/CMakeLists.txt b/intern/opencolorio/CMakeLists.txt index 0b46ae471d2..a2ef0d46a40 100644 --- a/intern/opencolorio/CMakeLists.txt +++ b/intern/opencolorio/CMakeLists.txt @@ -24,6 +24,7 @@ set(INC ../guardedalloc ../../source/blender/blenlib ../../source/blender/gpu + ../../source/blender/gpu/intern ../../source/blender/makesdna ) @@ -37,6 +38,7 @@ set(SRC ocio_capi.h ocio_impl.h + ocio_shader_shared.hh ) set(LIB @@ -73,8 +75,38 @@ if(WITH_OPENCOLORIO) ) endif() - data_to_c_simple(gpu_shader_display_transform.glsl SRC) - data_to_c_simple(gpu_shader_display_transform_vertex.glsl SRC) + set(GLSL_SRC + gpu_shader_display_transform_vert.glsl + gpu_shader_display_transform_frag.glsl + + ocio_shader_shared.hh + ) + + set(GLSL_C) + foreach(GLSL_FILE ${GLSL_SRC}) + data_to_c_simple(${GLSL_FILE} GLSL_C) + endforeach() + + blender_add_lib(bf_ocio_shaders "${GLSL_C}" "" "" "") + + list(APPEND LIB + bf_ocio_shaders + ) + + set(GLSL_SOURCE_CONTENT "") + foreach(GLSL_FILE ${GLSL_SRC}) + get_filename_component(GLSL_FILE_NAME ${GLSL_FILE} NAME) + string(REPLACE "." "_" GLSL_FILE_NAME_UNDERSCORES ${GLSL_FILE_NAME}) + string(APPEND GLSL_SOURCE_CONTENT "SHADER_SOURCE\(datatoc_${GLSL_FILE_NAME_UNDERSCORES}, \"${GLSL_FILE_NAME}\", \"${GLSL_FILE}\"\)\n") + endforeach() + + set(glsl_source_list_file "${CMAKE_CURRENT_BINARY_DIR}/glsl_ocio_source_list.h") + file(GENERATE OUTPUT ${glsl_source_list_file} CONTENT "${GLSL_SOURCE_CONTENT}") + list(APPEND SRC ${glsl_source_list_file}) + list(APPEND INC ${CMAKE_CURRENT_BINARY_DIR}) + + target_include_directories(bf_ocio_shaders PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) + endif() -- cgit v1.2.3