Skip to content

Conversation

@TJnotJT
Copy link
Contributor

@TJnotJT TJnotJT commented Dec 2, 2025

Description of Changes

Adds a Python script and build settings to allow baking some GS shaders into the PCSX2 executable.

Affects the following shaders:

bin/resources/shaders/common/fxaa.cpp
bin/resources/shaders/vulkan/convert.cpp
bin/resources/shaders/vulkan/imgui.cpp
bin/resources/shaders/vulkan/interlace.cpp
bin/resources/shaders/vulkan/merge.cpp
bin/resources/shaders/vulkan/present.cpp
bin/resources/shaders/vulkan/shadeboost.cpp
bin/resources/shaders/vulkan/tfx.cpp
bin/resources/shaders/opengl/convert.cpp
bin/resources/shaders/opengl/imgui.cpp
bin/resources/shaders/opengl/interlace.cpp
bin/resources/shaders/opengl/merge.cpp
bin/resources/shaders/opengl/present.cpp
bin/resources/shaders/opengl/shadeboost.cpp
bin/resources/shaders/opengl/tfx_fs.cpp
bin/resources/shaders/opengl/tfx_vgs.cpp
bin/resources/shaders/dx11/convert.cpp
bin/resources/shaders/dx11/imgui.cpp
bin/resources/shaders/dx11/interlace.cpp
bin/resources/shaders/dx11/merge.cpp
bin/resources/shaders/dx11/present.cpp
bin/resources/shaders/dx11/shadeboost.cpp
bin/resources/shaders/dx11/tfx.cpp

Rationale behind Changes

This allows different shaders to be more easily tested. For example, we can test multiple executables with different shaders without having to make sure the shaders on disk don't change.

Suggested Testing Steps

VS (manual): In the file common/vsprops/ShaderToCpp.props, change the line <BakeShadersInCpp>false</BakeShadersInCpp> to <BakeShadersInCpp>true</BakeShadersInCpp>.

VS (UI): In Property Manger window go under the pcsx2 project, select any configuration (e.g., Debug | x64), double click on ShaderToCpp. In the Common Properties > User Macros section, change the value of BakeShadersInCpp to true.

CMake: Build with the config variable BAKE_SHADERS_IN_CPP=true.

When building, you should see messages in the build log that indicate that the shaders are being converted to CPP files. The resulting executable should have the shaders baked at compile time so any changes made to the files in bin/resources/shaders should have no effect.

Did you use AI to help find, test, or implement this issue or feature?

I used AI to generate the Python files for converting text -> CPP. Also, to get help with the build file setup.

@TJnotJT TJnotJT force-pushed the gs-shader-bake branch 3 times, most recently from eebee0f to b82e497 Compare December 3, 2025 00:55
@TJnotJT
Copy link
Contributor Author

TJnotJT commented Dec 3, 2025

Small addition so that this can be enabled in the VS UI without having to edit project files manually.

@JordanTheToaster JordanTheToaster added this to the Release 2.8 milestone Dec 5, 2025
@TellowKrinkle
Copy link
Member

TellowKrinkle commented Dec 9, 2025

Please put generated files into the build directory in cmake (CMAKE_CURRENT_BINARY_DIR), then you don't have to worry about gitignoring them, and there won't be any fights if you make multiple builds from the same source dir.

If you look at the vs files for e.g. handling qt translations, you can probably find a similar binary dir for use with vs.

@TJnotJT TJnotJT force-pushed the gs-shader-bake branch 2 times, most recently from 2bab384 to e068f08 Compare December 9, 2025 04:32
@TJnotJT
Copy link
Contributor Author

TJnotJT commented Dec 9, 2025

Please put generated files into the build directory in cmake (CMAKE_CURRENT_BINARY_DIR), then you don't have to worry about gitignoring them, and there won't be any fights if you make multiple builds from the same source dir.

If you look at the vs files for e.g. handling qt translations, you can probably find a similar binary dir for use with vs.

Good point, I modified it so that the generated files are now output in "${CMAKE_CURRENT_BINARY_DIR}/shaders_cpp" for CMake and "$(OutDir)/shaders_cpp" for VS, and the directory is added to the includes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants