diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/host_shaders/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/video_core/host_shaders/StringShaderHeader.cmake | 22 | ||||
| -rw-r--r-- | src/video_core/host_shaders/source_shader.h.in | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/util_shaders.cpp | 8 |
4 files changed, 27 insertions, 8 deletions
diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txt index 3494318ca..2208e1922 100644 --- a/src/video_core/host_shaders/CMakeLists.txt +++ b/src/video_core/host_shaders/CMakeLists.txt | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | set(SHADER_FILES | 1 | set(SHADER_FILES |
| 2 | astc_decoder.comp | ||
| 2 | block_linear_unswizzle_2d.comp | 3 | block_linear_unswizzle_2d.comp |
| 3 | block_linear_unswizzle_3d.comp | 4 | block_linear_unswizzle_3d.comp |
| 4 | convert_depth_to_float.frag | 5 | convert_depth_to_float.frag |
diff --git a/src/video_core/host_shaders/StringShaderHeader.cmake b/src/video_core/host_shaders/StringShaderHeader.cmake index c0fc49768..1b4bc6103 100644 --- a/src/video_core/host_shaders/StringShaderHeader.cmake +++ b/src/video_core/host_shaders/StringShaderHeader.cmake | |||
| @@ -6,7 +6,27 @@ get_filename_component(CONTENTS_NAME ${SOURCE_FILE} NAME) | |||
| 6 | string(REPLACE "." "_" CONTENTS_NAME ${CONTENTS_NAME}) | 6 | string(REPLACE "." "_" CONTENTS_NAME ${CONTENTS_NAME}) |
| 7 | string(TOUPPER ${CONTENTS_NAME} CONTENTS_NAME) | 7 | string(TOUPPER ${CONTENTS_NAME} CONTENTS_NAME) |
| 8 | 8 | ||
| 9 | file(READ ${SOURCE_FILE} CONTENTS) | 9 | FILE(READ ${SOURCE_FILE} line_contents) |
| 10 | |||
| 11 | # Replace double quotes with single quotes, | ||
| 12 | # as double quotes will be used to wrap the lines | ||
| 13 | STRING(REGEX REPLACE "\"" "'" line_contents "${line_contents}") | ||
| 14 | |||
| 15 | # CMake separates list elements with semicolons, but semicolons | ||
| 16 | # are used extensively in the shader code. | ||
| 17 | # Replace with a temporary marker, to be reverted later. | ||
| 18 | STRING(REGEX REPLACE ";" "{{SEMICOLON}}" line_contents "${line_contents}") | ||
| 19 | |||
| 20 | # Make every line an individual element in the CMake list. | ||
| 21 | STRING(REGEX REPLACE "\n" ";" line_contents "${line_contents}") | ||
| 22 | |||
| 23 | # Build the shader string, wrapping each line in double quotes. | ||
| 24 | foreach(line IN LISTS line_contents) | ||
| 25 | string(CONCAT CONTENTS "${CONTENTS}" \"${line}\\n\"\n) | ||
| 26 | endforeach() | ||
| 27 | |||
| 28 | # Revert the original semicolons in the source. | ||
| 29 | STRING(REGEX REPLACE "{{SEMICOLON}}" ";" CONTENTS "${CONTENTS}") | ||
| 10 | 30 | ||
| 11 | get_filename_component(OUTPUT_DIR ${HEADER_FILE} DIRECTORY) | 31 | get_filename_component(OUTPUT_DIR ${HEADER_FILE} DIRECTORY) |
| 12 | make_directory(${OUTPUT_DIR}) | 32 | make_directory(${OUTPUT_DIR}) |
diff --git a/src/video_core/host_shaders/source_shader.h.in b/src/video_core/host_shaders/source_shader.h.in index ccdb0d2a9..929dec39b 100644 --- a/src/video_core/host_shaders/source_shader.h.in +++ b/src/video_core/host_shaders/source_shader.h.in | |||
| @@ -4,6 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | namespace HostShaders { | 5 | namespace HostShaders { |
| 6 | 6 | ||
| 7 | constexpr std::string_view @CONTENTS_NAME@ = R"(@CONTENTS@)"; | 7 | constexpr std::string_view @CONTENTS_NAME@ = { |
| 8 | @CONTENTS@ | ||
| 9 | }; | ||
| 8 | 10 | ||
| 9 | } // namespace HostShaders | 11 | } // namespace HostShaders |
diff --git a/src/video_core/renderer_opengl/util_shaders.cpp b/src/video_core/renderer_opengl/util_shaders.cpp index 2a4220661..d0979dab1 100644 --- a/src/video_core/renderer_opengl/util_shaders.cpp +++ b/src/video_core/renderer_opengl/util_shaders.cpp | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include "common/assert.h" | 14 | #include "common/assert.h" |
| 15 | #include "common/common_types.h" | 15 | #include "common/common_types.h" |
| 16 | #include "common/div_ceil.h" | 16 | #include "common/div_ceil.h" |
| 17 | #include "video_core/host_shaders/astc_decoder_comp.h" | ||
| 17 | #include "video_core/host_shaders/block_linear_unswizzle_2d_comp.h" | 18 | #include "video_core/host_shaders/block_linear_unswizzle_2d_comp.h" |
| 18 | #include "video_core/host_shaders/block_linear_unswizzle_3d_comp.h" | 19 | #include "video_core/host_shaders/block_linear_unswizzle_3d_comp.h" |
| 19 | #include "video_core/host_shaders/opengl_copy_bc4_comp.h" | 20 | #include "video_core/host_shaders/opengl_copy_bc4_comp.h" |
| @@ -62,17 +63,12 @@ size_t NumPixelsInCopy(const VideoCommon::ImageCopy& copy) { | |||
| 62 | } // Anonymous namespace | 63 | } // Anonymous namespace |
| 63 | 64 | ||
| 64 | UtilShaders::UtilShaders(ProgramManager& program_manager_) | 65 | UtilShaders::UtilShaders(ProgramManager& program_manager_) |
| 65 | : program_manager{program_manager_}, | 66 | : program_manager{program_manager_}, astc_decoder_program(MakeProgram(ASTC_DECODER_COMP)), |
| 66 | block_linear_unswizzle_2d_program(MakeProgram(BLOCK_LINEAR_UNSWIZZLE_2D_COMP)), | 67 | block_linear_unswizzle_2d_program(MakeProgram(BLOCK_LINEAR_UNSWIZZLE_2D_COMP)), |
| 67 | block_linear_unswizzle_3d_program(MakeProgram(BLOCK_LINEAR_UNSWIZZLE_3D_COMP)), | 68 | block_linear_unswizzle_3d_program(MakeProgram(BLOCK_LINEAR_UNSWIZZLE_3D_COMP)), |
| 68 | pitch_unswizzle_program(MakeProgram(PITCH_UNSWIZZLE_COMP)), | 69 | pitch_unswizzle_program(MakeProgram(PITCH_UNSWIZZLE_COMP)), |
| 69 | copy_bgra_program(MakeProgram(OPENGL_COPY_BGRA_COMP)), | 70 | copy_bgra_program(MakeProgram(OPENGL_COPY_BGRA_COMP)), |
| 70 | copy_bc4_program(MakeProgram(OPENGL_COPY_BC4_COMP)) { | 71 | copy_bc4_program(MakeProgram(OPENGL_COPY_BC4_COMP)) { |
| 71 | // TODO: Load shader string as a header | ||
| 72 | std::string astc_path = "astc_decoder.comp"; | ||
| 73 | std::ifstream t(astc_path); | ||
| 74 | std::string str((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>()); | ||
| 75 | astc_decoder_program = MakeProgram(str); | ||
| 76 | MakeBuffers(); | 72 | MakeBuffers(); |
| 77 | } | 73 | } |
| 78 | 74 | ||