Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows cmake builds #7

Merged
merged 10 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .github/workflows/cmake_multi_platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: CMake on multiple platforms

on:
push:
branches: [ "*" ]
pull_request:
branches: [ "*" ]

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false

# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest, windows-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl

steps:
- uses: actions/checkout@v4

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DBUILD_TESTS=ON
-S ${{ github.workspace }}

- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }} --verbose
38 changes: 0 additions & 38 deletions .github/workflows/cmake_single_platform.yml

This file was deleted.

42 changes: 13 additions & 29 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

/ComputeShaderSort11/Debug
/ComputeShaderSort11/.vs/ComputeShaderSort11_2017_Win10/v15
/ComputeShaderSort11/x64/Debug
/ComputeShaderSort11.hlsl
/Shaderator/ComputeShaderSort11.hlsl
/ComputeShaderSort11/x64/Release
/ComputeShaderSort11/Release/ComputeS.D3D1110B.tlog
/ComputeShaderSort11/Release
/ComputeShaderUnitTests/Debug
/ComputeShaderUnitTests/Release
/ComputeShaderUnitTests/x64
/x64/Debug
/Debug
/output
/intermediate
/Shaderator/Shaderator_old.lib
/Shaderator/Shaderator_d_old.lib
/.vs/Shaderator/v15
/ShaderatorUnitTests/x64/Debug
/packages
/.idea
/examples/OpenCL/IntelBitonicSort/BitonicSort/.vs/BitonicSort_2015/v15

# Linux
# Linux
build/

# VS Code
.vscode/
.vscode/

# VS
.vs/
intermediate/
output/
packages/
x64/
x86/

# Python
__pycache__/
75 changes: 44 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,22 @@ Shaderator is a productivity library intended to speed up complex Compute Shader
# What problem does it solve?
Due to the nature of GPUs shaders are hard to debug. Back in the day developer wrote one, executed a batch and hoped for the best that the result is correct. Kernel function is usually executed hundreds of thousand times writing data to output buffer which can only be looked up when the Dispatch finished. This tool compiles .hlsl shader code to C++ and enables developer to leverage full Visual Studio debugging functionality to quickly find problems in the code.

# Setup
# Linux

## Setup

If you use VS Code install recommended extensions from

```configs/recommended_extensions.json```

## Linux

Install compiler and build tools

```sudo apt-get install -y cmake build-essential gdb```

# Building
## Building

Shaderators uses CMake to setup and run the build process.

## Linux

Run the following commands to build:

```
Expand All @@ -35,46 +33,43 @@ make

CMake will download the neccessary dependencies like GoogleTests.

# Unit testing
## Unit testing

To execute unit tests run from command line run

```ctests --verbose```

When using VS Code and all the recommended extensions were installed, then tests should be visible in the 'Test Explorer UI'.

# Windows

# Examples

There are several examples in folder ```examples``` how to write a test for you shaders/kernels. The idea is not leave the production code as much untouched as possible, but it's not always possible. Sometimes variables or data types need to be wrapped in a ```Shaderator``` macros.
Two ways of working were tested:
- using Visual Studio Code
- using Visual Studio 2022

You also need to write an ```executor``` which will handle input and exectution of your specific kernel.
## VS Code

There are examples for:
- Direct Compute HLSL
- OpenGL GLSL
- OpenCL C
Just follow the IDE instructions to configure project with CMake.

Functionality for your specific kernel may be missing and would need to be added. If that is the case please submit an issue or feature request on github.
You can build using CMake extension, by just pressing build after the project was configured.

# FAQ
Run tests from eg. Test explorer UI.

## Will this work with any shader?
Not yet, the project is in it's early phase, however it should work with many shaders. If there is interest, support for more HLSL language features will be added.
At the moment matrices are not supported yet.
Place breakpoint anywhere in the shader code to break.

# Problems or feedback
NOTE: Hitting breakpoints require Debug build, so be sure to build this configuration.

Submit any issues on github. Feel free to contact the author directly with information available on github.
## Use Visual Studio

## Setup

# (old instructions) Windows - Getting started with debugging
Install VS with Google Test support.

NOTE: This instructions are from year 2018 and serve as reference. Running Shaderator on Windows has not been tried since then.
### Build and Debug

1. Open Shaderator.sln in VS 2017
1. Open Shaderator.sln in VS 2022
2. Build solution (better choose Debug configuration to see more variables under debugger)
3. Set ComputeShaderSort11 in examples folder as startup project (right click on the project in Visual Studio and select "Set as StartUp Project")
3. Set ```BitonicSort``` project in ```examples``` folder as startup project (right click on the project in Visual Studio and select "Set as StartUp Project")
4. Put breakpoint anywhere in ComputeShaderSort11.hlsl shader file
5. Press F5 to Debug

Expand All @@ -83,15 +78,33 @@ CPU shader is obviously very slow. The intention is to provide tools for faster

If you have Visual Assist X installed debugging experience may be reduced.

# Getting started with Unit Tests
### Unit Tests

1. Open Shaderator.sln in VS 2017
1. Open Shaderator.sln in VS 2022
2. Build solution
3. Set processor architecture for Unit Tests. In VS menu go to "Test -> Test Settings -> Default Processor Architecture" and select the platform for which you have built the solution (X86 or X64).
4. Open Test Explorer. In VS menu go to "Test -> Windows -> Test Explorer"
5. In Test Explorer right click on the Unit Test found and press "Run Selected Tests" or "Debug Selected Tests"

# Pre-requisites
# Examples

* Windows 10
* Visual Studio 2017
There are several examples in folder ```examples``` how to write a test for you shaders/kernels. The idea is not leave the production code as much untouched as possible, but it's not always possible. Sometimes variables or data types need to be wrapped in a ```Shaderator``` macros.

You also need to write an ```executor``` which will handle input and exectution of your specific kernel.

There are examples for:
- Direct Compute HLSL
- OpenGL GLSL
- OpenCL C

Functionality for your specific kernel may be missing and would need to be added. If that is the case please submit an issue or feature request on github.

# FAQ

## Will this work with any shader?
Not yet, the project is in it's early phase, however it should work with many shaders. If there is interest, support for more HLSL language features will be added.
At the moment matrices are not supported yet.

# Problems or feedback

Submit any issues on github. Feel free to contact the author directly with information available on github.
44 changes: 2 additions & 42 deletions Shaderator.sln
Original file line number Diff line number Diff line change
@@ -1,54 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.13
# Visual Studio Version 17
VisualStudioVersion = 17.11.35327.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Shaderator", "Shaderator\Shaderator.vcxproj", "{979D44BD-659C-4CF5-A974-51121BB3D14F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{9EF43AE3-914C-4137-9E5C-5E8F25EE95B1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "external", "external", "{E283841D-901F-4818-BBDD-9D8D131CA87F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gtest", "gtest", "{B9069897-A40C-44EF-B492-A4A57F02A66E}"
ProjectSection(SolutionItems) = preProject
external\gtest\gtest-death-test.h = external\gtest\gtest-death-test.h
external\gtest\gtest-message.h = external\gtest\gtest-message.h
external\gtest\gtest-param-test.h = external\gtest\gtest-param-test.h
external\gtest\gtest-param-test.h.pump = external\gtest\gtest-param-test.h.pump
external\gtest\gtest-printers.h = external\gtest\gtest-printers.h
external\gtest\gtest-spi.h = external\gtest\gtest-spi.h
external\gtest\gtest-test-part.h = external\gtest\gtest-test-part.h
external\gtest\gtest-typed-test.h = external\gtest\gtest-typed-test.h
external\gtest\gtest.h = external\gtest\gtest.h
external\gtest\gtest_pred_impl.h = external\gtest\gtest_pred_impl.h
external\gtest\gtest_prod.h = external\gtest\gtest_prod.h
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "internal", "internal", "{2ED28B74-D728-4617-9D13-D3282AC05E1D}"
ProjectSection(SolutionItems) = preProject
external\gtest\internal\gtest-death-test-internal.h = external\gtest\internal\gtest-death-test-internal.h
external\gtest\internal\gtest-filepath.h = external\gtest\internal\gtest-filepath.h
external\gtest\internal\gtest-internal.h = external\gtest\internal\gtest-internal.h
external\gtest\internal\gtest-linked_ptr.h = external\gtest\internal\gtest-linked_ptr.h
external\gtest\internal\gtest-param-util-generated.h = external\gtest\internal\gtest-param-util-generated.h
external\gtest\internal\gtest-param-util-generated.h.pump = external\gtest\internal\gtest-param-util-generated.h.pump
external\gtest\internal\gtest-param-util.h = external\gtest\internal\gtest-param-util.h
external\gtest\internal\gtest-port-arch.h = external\gtest\internal\gtest-port-arch.h
external\gtest\internal\gtest-port.h = external\gtest\internal\gtest-port.h
external\gtest\internal\gtest-string.h = external\gtest\internal\gtest-string.h
external\gtest\internal\gtest-tuple.h = external\gtest\internal\gtest-tuple.h
external\gtest\internal\gtest-tuple.h.pump = external\gtest\internal\gtest-tuple.h.pump
external\gtest\internal\gtest-type-util.h = external\gtest\internal\gtest-type-util.h
external\gtest\internal\gtest-type-util.h.pump = external\gtest\internal\gtest-type-util.h.pump
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "custom", "custom", "{7F199E13-EB62-4E49-B645-9C7B27A353A2}"
ProjectSection(SolutionItems) = preProject
external\gtest\internal\custom\gtest-port.h = external\gtest\internal\custom\gtest-port.h
external\gtest\internal\custom\gtest-printers.h = external\gtest\internal\custom\gtest-printers.h
external\gtest\internal\custom\gtest.h = external\gtest\internal\custom\gtest.h
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BasicCompute11", "examples\BasicCompute11\BasicCompute11_2017_Win10.vcxproj", "{D3D1110D-96D0-4629-88B8-122C0256058C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BitonicSort", "examples\BitonicSort\BitonicSort.vcxproj", "{D3D1110B-96D0-4629-88B8-122C0256058C}"
Expand Down
9 changes: 5 additions & 4 deletions Shaderator/Shaderator.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,32 @@
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{979D44BD-659C-4CF5-A974-51121BB3D14F}</ProjectGuid>
<RootNamespace>Shaderator</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion Shaderator/Shaderator.vcxproj.user
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>
Loading