summaryrefslogtreecommitdiff
path: root/src/video_core/host_shaders
diff options
context:
space:
mode:
authorGravatar ameerj2021-02-13 15:52:21 -0500
committerGravatar ameerj2021-03-13 12:16:03 -0500
commitf6566338ebd6559b0fbe61e1557ee735bf58dcdd (patch)
tree6c4163d0dc21dbc5225ac99733de45504ee53e12 /src/video_core/host_shaders
parentrenderer_opengl: Accelerate ASTC texture decoding with a compute shader (diff)
downloadyuzu-f6566338ebd6559b0fbe61e1557ee735bf58dcdd.tar.gz
yuzu-f6566338ebd6559b0fbe61e1557ee735bf58dcdd.tar.xz
yuzu-f6566338ebd6559b0fbe61e1557ee735bf58dcdd.zip
host_shaders: Modify shader cmake integration to allow for larger shaders
using a raw string to encapsulate the entire shader code limits us to shaders of size less than 2KB. This change overcomes this limitation.
Diffstat (limited to 'src/video_core/host_shaders')
-rw-r--r--src/video_core/host_shaders/CMakeLists.txt1
-rw-r--r--src/video_core/host_shaders/StringShaderHeader.cmake22
-rw-r--r--src/video_core/host_shaders/source_shader.h.in4
3 files changed, 25 insertions, 2 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 @@
1set(SHADER_FILES 1set(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)
6string(REPLACE "." "_" CONTENTS_NAME ${CONTENTS_NAME}) 6string(REPLACE "." "_" CONTENTS_NAME ${CONTENTS_NAME})
7string(TOUPPER ${CONTENTS_NAME} CONTENTS_NAME) 7string(TOUPPER ${CONTENTS_NAME} CONTENTS_NAME)
8 8
9file(READ ${SOURCE_FILE} CONTENTS) 9FILE(READ ${SOURCE_FILE} line_contents)
10
11# Replace double quotes with single quotes,
12# as double quotes will be used to wrap the lines
13STRING(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.
18STRING(REGEX REPLACE ";" "{{SEMICOLON}}" line_contents "${line_contents}")
19
20# Make every line an individual element in the CMake list.
21STRING(REGEX REPLACE "\n" ";" line_contents "${line_contents}")
22
23# Build the shader string, wrapping each line in double quotes.
24foreach(line IN LISTS line_contents)
25 string(CONCAT CONTENTS "${CONTENTS}" \"${line}\\n\"\n)
26endforeach()
27
28# Revert the original semicolons in the source.
29STRING(REGEX REPLACE "{{SEMICOLON}}" ";" CONTENTS "${CONTENTS}")
10 30
11get_filename_component(OUTPUT_DIR ${HEADER_FILE} DIRECTORY) 31get_filename_component(OUTPUT_DIR ${HEADER_FILE} DIRECTORY)
12make_directory(${OUTPUT_DIR}) 32make_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
5namespace HostShaders { 5namespace HostShaders {
6 6
7constexpr std::string_view @CONTENTS_NAME@ = R"(@CONTENTS@)"; 7constexpr std::string_view @CONTENTS_NAME@ = {
8@CONTENTS@
9};
8 10
9} // namespace HostShaders 11} // namespace HostShaders