Files
renderdoc/renderdoc/data/glsl/debug_math.comp
T

80 lines
3.3 KiB
Plaintext

/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2025 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
#if defined(OPENGL_CORE)
#extension GL_ARB_compute_shader : require
#extension GL_ARB_shader_storage_buffer_object : require
// safe to assume this extension in compute shaders as it pre-dates compute shaders
#extension GL_ARB_shading_language_420pack : require
#endif
#include "glsl_ubos.h"
uniform vec4 a;
uniform vec4 b;
uniform vec4 c;
uniform int op;
layout(binding = 0, std430) buffer Output
{
vec4 result;
}
outputs;
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void main()
{
switch(op)
{
case SPV_OpSin: outputs.result = sin(a); break;
case SPV_OpCos: outputs.result = cos(a); break;
case SPV_OpTan: outputs.result = tan(a); break;
case SPV_OpAsin: outputs.result = asin(a); break;
case SPV_OpAcos: outputs.result = acos(a); break;
case SPV_OpAtan: outputs.result = atan(a); break;
case SPV_OpSinh: outputs.result = sinh(a); break;
case SPV_OpCosh: outputs.result = cosh(a); break;
case SPV_OpTanh: outputs.result = tanh(a); break;
case SPV_OpAsinh: outputs.result = asinh(a); break;
case SPV_OpAcosh: outputs.result = acosh(a); break;
case SPV_OpAtanh: outputs.result = atanh(a); break;
case SPV_OpExp: outputs.result = exp(a); break;
case SPV_OpLog: outputs.result = log(a); break;
case SPV_OpExp2: outputs.result = exp2(a); break;
case SPV_OpLog2: outputs.result = log2(a); break;
case SPV_OpSqrt: outputs.result = sqrt(a); break;
case SPV_OpInverseSqrt: outputs.result = inversesqrt(a); break;
case SPV_OpNormalize: outputs.result = normalize(a); break;
case SPV_OpAtan2: outputs.result = atan(a, b); break;
case SPV_OpPow: outputs.result = pow(a, b); break;
case SPV_OpFma: outputs.result = fma(a, b, c); break;
case SPV_OpLength: outputs.result = vec4(length(a), 0, 0, 0); break;
case SPV_OpDistance: outputs.result = vec4(distance(a, b), 0, 0, 0); break;
case SPV_OpRefract: outputs.result = refract(a, b, c.x); break;
default: outputs.result = vec4(0, 0, 0, 0); break;
}
}