aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/host_shaders/StringShaderHeader.cmake
diff options
context:
space:
mode:
authorRodrigo Locatti <reinuseslisp@airmail.cc>2021-03-30 19:31:52 -0300
committerGitHub <noreply@github.com>2021-03-30 19:31:52 -0300
commit5ee669466fcebd2258229ed6bfe6b5e5529e0200 (patch)
tree6dbf84fb5c2c9656f1d1ef6c46b2527ea1a205ff /src/video_core/host_shaders/StringShaderHeader.cmake
parenteeea426c745e26f20f1cf6c6929c377897ef3e68 (diff)
parent2f83d9a61bca42d9ef24074beb2b11b19bd4cecd (diff)
Merge pull request #5927 from ameerj/astc-compute
video_core: Accelerate ASTC texture decoding using compute shaders
Diffstat (limited to 'src/video_core/host_shaders/StringShaderHeader.cmake')
-rw-r--r--src/video_core/host_shaders/StringShaderHeader.cmake22
1 files changed, 21 insertions, 1 deletions
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)
string(REPLACE "." "_" CONTENTS_NAME ${CONTENTS_NAME})
string(TOUPPER ${CONTENTS_NAME} CONTENTS_NAME)
-file(READ ${SOURCE_FILE} CONTENTS)
+FILE(READ ${SOURCE_FILE} line_contents)
+
+# Replace double quotes with single quotes,
+# as double quotes will be used to wrap the lines
+STRING(REGEX REPLACE "\"" "'" line_contents "${line_contents}")
+
+# CMake separates list elements with semicolons, but semicolons
+# are used extensively in the shader code.
+# Replace with a temporary marker, to be reverted later.
+STRING(REGEX REPLACE ";" "{{SEMICOLON}}" line_contents "${line_contents}")
+
+# Make every line an individual element in the CMake list.
+STRING(REGEX REPLACE "\n" ";" line_contents "${line_contents}")
+
+# Build the shader string, wrapping each line in double quotes.
+foreach(line IN LISTS line_contents)
+ string(CONCAT CONTENTS "${CONTENTS}" \"${line}\\n\"\n)
+endforeach()
+
+# Revert the original semicolons in the source.
+STRING(REGEX REPLACE "{{SEMICOLON}}" ";" CONTENTS "${CONTENTS}")
get_filename_component(OUTPUT_DIR ${HEADER_FILE} DIRECTORY)
make_directory(${OUTPUT_DIR})