Git Product home page Git Product logo

shadertrap's Introduction

ShaderTrap

An OpenGL shader runner that runs self-contained .shadertrap files.

This is not an officially supported Google product.

Build

# Clone the repo.
git clone [email protected]:google/shadertrap.git
# Or:
git clone https://github.com/google/shadertrap.git

# Navigate to the root of the repo.
cd shadertrap

# Update and init submodules.
git submodule update --init

# Build using a recent version of CMake. Ensure `ninja` is on your PATH.
mkdir build
cd build

cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Debug
cmake --build . --config Debug
cmake -DCMAKE_INSTALL_PREFIX=./install -P cmake_install.cmake --config Debug

shadertrap's People

Contributors

aaronghost avatar afd avatar asuonpaa avatar emiljanogj avatar mostafa-ashraf19 avatar sethvargo avatar sliu-uiuc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

shadertrap's Issues

Add support for more primitive types

In RUN_GRAPHICS, only TRIANGLES can currently be used as the TOPOLOGY argument.

It should be easy to support other kinds of triangle primitive, and likely further primitives would be straightforward too.

For each primitive, a new end-to-end test case in examples should be added.

Update cppcheck next time it is released

To work around a cppcheck bug, the ShaderTrap CI will feature applying a custom patch. This should be gotten rid of next time there is a cppcheck release, as the problem doesn't persist in cppcheck's main branch.

Add a type field to the data provided for a vertex attribute

Right now all vertex attributes are assumed to have 32-bit floating point type, but it would be good (and easy) to be more general here. We should add a TYPE or ELEMENT_TYPE field to the data provided for a vertex buffer. Right now there could be just one option - float. But this would pave the way for more options without having to make float the default.

Display OpenGL version information

When using ShaderTrap with alternative renderers, such as llvmpipe or SwiftShader, it can be reassuring to know that one is indeed using the desired renderer.

Add an option, --show-gl-info, that will cause this information to be printed to stdout before script execution begins.

Add CI support for failing tests

At the moment, the CI expects all the examples to be executed successfully. However, it may be useful to have some failing examples to ensure that shadertrap behaves as it should even in these cases.

Unnecessary glMemoryBarrier call

There's a glMemoryBarrier call at the beginning of VisitRunGraphics. This seems unnecessary and also doesn't function with ES3.0 or below.

add a DUMP_BUFFER command

Buffers can already be compared in a single run using the ASSERT_EQUAL command but it does not permit to save buffer results to compare them across different runs.

While the binary representation could already be useful, a human-readable version would be best for debugging. As the type of the underlying data is bound at buffer creation (and by the underlying interface block in the shader), it could use the format provided at creation to recognize uint, int, etc.. when dumping to the file.

Add optional FORMAT parameter to ASSERT_EQUAL, for buffers

When comparing two buffers, it can be convenient to compare them on the assumption that their element are interpreted as having particular types. It also may be useful to skip certain parts of the buffers.

The ASSERT_EQUAL command should be adapted to have an optional FORMAT parameter, following what is used in DUMP_BUFFER_TEXT.

Support more texture/sampler parameters

Only TEXTURE_MAG_FILTER and TEXTURE_MIN_FILTER are supported at present. More parameters should be supported as they are needed. Because some parameters take simple enum value and others take multiple values, some parser work will be required.

Write a series of histogram examples

Write ShaderTrap scripts that use compute shaders to compute a histogram of values.

The purpose of these examples are to provide an interesting set of compute shaders. They do not necessarily need to represent good practice from a performance perspective.

Top-level spec for all examples:

  • input: a shader storage buffer object containing 256 unsigned integers, each in the range 0-15

  • output: a shader storage buffer object containing 16 unsigned integers. Position i of this buffer should reflect the number of occurrences of integer i in the input buffer.

  • Version 1:

  • use a single invocation
  • initialise all elements of the output buffer to 0
  • scan the input buffer, incrementing each position of the output buffer according to each element found
  • Version 2:
  • use a single invocation
  • loop through the values 0-15
  • for each value, loop through the whole input buffer, counting up the number of times you see the current value being considered
  • set the output buffer to that value
  • Version 3:
  • The same as version 2, except that instead of looping through the values 0-15 in steps of size 1, loop through in steps of size 4. Use a uvec4 - i.e., a 4D vector of unsigned integers, to track the number of occurrences of 4 different values at a time. To achieve this you may want to treat the output as an array of 4 uvec4s, rather than of 16 uints.
  • Version 4:
  • The same as version 3, except use 4 parallel invocations in different groups. Have invocation 0 take care of values [0, 1, 2, 3] using a single uvec4, have invocation 1 take care of [4, 5, 6, 7] using a single uvec4, etc.
  • Version 5:
  • Like version 1, but use 16 parallel invocations, in different groups, having each invocation take a separate chunk of the range [0-255] of the input array. Use atomicAdd instructions to update the output array
  • Version 6:
  • Use 16 groups, with 16 invocations per group
  • Each group uses shared memory to compute a mini histogram, using atomic operations
  • A group then synchronizes using a barrier
  • A representative from each group then atomically adds the results of the group's mini histogram to the output buffer

Write a series of matrix multiplication examples

Write ShaderTrap scripts that use compute shaders to perform matrix multiplication.

The purpose of these examples is to provide an interesting set of compute shaders. They do not necessarily need to represent good practice from a performance perspective.

Top-level spec for all examples:

  • Inputs: 2 arrays of floating-point data representing the contents of a pair of 16x16 matrices

  • Output: 1 array of floating-point data that will represent the 16x16 matrix that results from multiplying these matrices together

  • Version 1:

  • Write a sequential matrix multiplication routine, executed by a single invocation
  • Version 2:
  • Write a version of 1 where the matrix input data is interpreted as a block-partitioned matrix: four 4x4 matrices rather than a 16x16 array of floats. A single invocation can then compute the product of the matrices using operations on the mat4x4 datatype to multiply sub-matrices.
  • Version 3:
  • The same as version 2, but consider the input as a block-partitioned matrix made up of 2x2 matrices instead of 3x3 matrices
  • Version 4:
  • Version 5:
  • Use parallelism, and also block-partitioned matrices (i.e., combine version 4 with either version 2 or version 3)
  • Version 6:
  • Implement matrix multiplication using shared memory within a group. There are many articles online about how to do this in CUDA. It should be reasonably straightforward to port them to OpenGL compute shaders.

Change ASSERT_EQUAL to take BUFFERS or RENDERBUFFERS as a parameter

Right now ASSERT_EQUAL takes BUFFER1 and BUFFER2 as parameters. This is misleading as they can be renderbuffers (and we'd like to make the language clear by avoiding blurring the terms "buffer" and "renderbuffer", and also cumbersome since both buffers/renderbuffers could fall under a single parameter.

Write a series of reduction examples

Write ShaderTrap scripts that use compute shaders to perform reductions.

The purpose of these examples is to provide an interesting set of compute shaders. They do not necessarily need to represent good practice from a performance perspective.

Top-level spec for all examples:

Input: an array of 256 uint or int data elements

Output: a uint or an int, representing the result of combining together the contents of the array using a reduction operation. Allowed reduction operations are: add, min, max, bitwise and, bitwise or and bitwise xor

  • Version 1:
  • Have a single invocation do a sequential reduction.
  • Version 2:
  • Have 16 distinct invocations
  • Each invocation reduces 16 elements of the array (each invocation gets a disjoint part of the array)
  • An invocation uses an atomic operation to update the overall result with its partial result
  • Version 3:
  • Have one group of 256 invocations
  • The group collectively reduce the array by doing a tree reduction on global memory. You can read about tree reductions online; here is one such source (though it's more technical than we need)
  • Version 4:
  • Like version 3, except that the tree reduction is performed on shared memory, not global memory
  • Version 5:
  • Instead of having 1 group of size 256, have 4 groups of size 64. Each group does a tree reduction on 1/4 of the data. A representative from the group then performs an atomic operation to combine its group's result with the final result.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.