Sunday, 21 June 2015

CMake and HLSL Shader Compilation

This post demonstrates how to use CMake 3.2 to configure the compilation of HLSL shaders, including setting shader types, models, and entry points.

CMake 3.2 introduces support for compiling HLSL shaders directly. This allows developers to easily integrate shader compilation into their build process.

set_source_files_properties( ${PS_SHADER_SOURCES}
    PROPERTIES VS_SHADER_TYPE Pixel
              VS_SHADER_MODEL 5.0
              VS_SHADER_ENTRYPOINT main )

set_source_files_properties( ${VS_SHADER_SOURCES}
    PROPERTIES VS_SHADER_TYPE Vertex
              VS_SHADER_MODEL 5.0
              VS_SHADER_ENTRYPOINT main )

In this example, we demonstrate how to configure two sets of shader sources: pixel shaders (`PS_SHADER_SOURCES`) and vertex shaders (`VS_SHADER_SOURCES`).

For each set, we use set_source_files_properties to define the following properties:

  • VS_SHADER_TYPE: Specifies the shader type (Pixel or Vertex).
  • VS_SHADER_MODEL: Sets the shader model version (in this case, 5.0).
  • VS_SHADER_ENTRYPOINT: Defines the entry point function for the shader (here, `main`).

This CMake snippet allows you to seamlessly manage HLSL shader compilation within your build system, streamlining your workflow and ensuring proper shader configuration.

Transmission tips

To get peers at every five minutes just add to cron ($ crontab -e):

*/5 * * * * LD_LIBRARY_PATH=/i-data/md0/.system/zy-pkgs/lib /i-data/md0/.system/zy-pkgs/bin/transmission-remote -tall --reannounce

Restart Transmission at 1 am:
0 1 * * * LD_LIBRARY_PATH=/usr/local/zy-pkgs/lib /usr/local/zy-pkgs/etc/init.d/Transmission disable
5 1 * * * LD_LIBRARY_PATH=/usr/local/zy-pkgs/lib /usr/local/zy-pkgs/etc/init.d/Transmission enable

Now reboot:
/etc/init.d/crond.sh restart