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

CAD emulated float64 #114

Open
wants to merge 84 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
eaff54a
Added tests for emulated_float64_t
Przemog1 May 10, 2024
1abd122
Implemented emulated float64 type
Przemog1 May 13, 2024
0307779
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla-…
Przemog1 May 15, 2024
2e00f20
Added emulated float64 test
Przemog1 May 15, 2024
2ad6a6c
Fixed GPU values test
Przemog1 May 16, 2024
ea4fbbf
Saving work
Przemog1 May 23, 2024
2a878a0
Created emulated_float64_t tests
Przemog1 May 27, 2024
1169a13
Implemented add sub i mul operators
Przemog1 May 31, 2024
2d5d301
Adjusted tests
Przemog1 Jun 5, 2024
f17208a
Saving work
Przemog1 Jun 18, 2024
85babd0
Added more tests
Przemog1 Jul 8, 2024
5aaabfd
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla-…
Przemog1 Jul 9, 2024
25dfb67
Saving work
Przemog1 Jul 24, 2024
c53f5c8
Updated tests
Przemog1 Jul 30, 2024
822446f
Refactorization
Przemog1 Jul 31, 2024
deaa9f2
Fixes
Przemog1 Jul 31, 2024
f99b039
Revived GPU tests
Przemog1 Aug 1, 2024
54cf5e9
Saving work
Przemog1 Aug 6, 2024
10605e9
Resolved conflicts, merged master
Przemog1 Aug 6, 2024
aefcde9
Saving work
Przemog1 Aug 7, 2024
9b1edf6
Saving work
Przemog1 Aug 13, 2024
8e853f5
No Float64 cap
Przemog1 Aug 20, 2024
0bfc208
Refactor
Przemog1 Aug 22, 2024
293ec73
Saving work
Przemog1 Aug 23, 2024
b6b11ae
Saving work
Przemog1 Aug 24, 2024
dc10103
Implemented casting functions for emulated_float64_t
Przemog1 Aug 26, 2024
912f012
Updated tests
Przemog1 Aug 27, 2024
da25126
Fixes
Przemog1 Aug 28, 2024
70ee941
Fixed shaders so they compile even if portable_float64_t is not emulated
Przemog1 Aug 28, 2024
c08cd35
Saving work
Przemog1 Aug 29, 2024
a6b14da
Updated examples
Przemog1 Aug 30, 2024
f8f2c23
Fixed a bug
Przemog1 Sep 3, 2024
a9e1007
Reduced branches in operator+
Przemog1 Sep 3, 2024
1750aef
Enhanced more tests, more fixes
Przemog1 Sep 6, 2024
5e47cf3
Added example 64
Przemog1 Sep 6, 2024
48b4a40
Removed emulated float tests from example 22
Przemog1 Sep 6, 2024
904da40
64 bit float type is now determined by device capabilities
Przemog1 Sep 13, 2024
d6f0c58
Refactor
Przemog1 Sep 13, 2024
7f7b485
More refactor
Przemog1 Sep 13, 2024
cdafbbc
Fixes
Przemog1 Sep 21, 2024
aebab4a
More fixes
Przemog1 Sep 23, 2024
62f8a54
Even more fixes
Przemog1 Sep 25, 2024
8c873fa
Added more tests
Przemog1 Sep 28, 2024
af5ae27
Minor tests improvement
Przemog1 Sep 28, 2024
846e7aa
Resolved conflicts, merged master
Przemog1 Sep 28, 2024
a4fe41d
Added ef64_benchmark
Przemog1 Sep 28, 2024
ca02166
Tests works
Przemog1 Oct 1, 2024
843ee6a
Saving work
Przemog1 Oct 2, 2024
7422248
Saving work
Przemog1 Oct 2, 2024
6915664
Benchmark works
Przemog1 Oct 4, 2024
582f002
Saving work
Przemog1 Oct 4, 2024
8c37152
Improved benchmark
Przemog1 Oct 5, 2024
3912137
Added more benchmarks
Przemog1 Oct 7, 2024
031b1bc
Saving old version
Przemog1 Oct 7, 2024
239b3b0
Refactored example 64
Przemog1 Oct 7, 2024
0b39d2d
Saving work
Przemog1 Oct 8, 2024
879860a
Resolved conflicts, merged emulated_float64_t
Przemog1 Oct 9, 2024
3c063f8
Fixed benchmarks
Przemog1 Oct 9, 2024
ac97c37
Corrections
Przemog1 Oct 9, 2024
38282a3
Fix
Przemog1 Oct 10, 2024
b5cb225
Merge pull request #150 from Devsh-Graphics-Programming/ef64_benchmark
Przemog1 Oct 10, 2024
fa5a77b
Updated example 64
Przemog1 Oct 10, 2024
6dbde45
Fixed benchmark
Przemog1 Oct 11, 2024
5bd5c02
Fixed _static_cast
Przemog1 Oct 15, 2024
e4a42f4
Updated example
Przemog1 Oct 15, 2024
a80dcf8
Merge branch 'master' of https://github.com/Devsh-Graphics-Programmin…
Przemog1 Oct 21, 2024
44aec1e
Merge branch 'master' into emulated_float64_t
Erfan-Ahmadi Oct 25, 2024
aff6223
Fixes after Resolving Shader Conflicts
Erfan-Ahmadi Oct 25, 2024
b4ad0b6
Resolved conflicts, merged master
Przemog1 Nov 20, 2024
ad0e24f
Implemented nbl::hlsl::mul
Przemog1 Nov 26, 2024
d62f779
Fixed array_get and array_set
Przemog1 Nov 26, 2024
ce7e866
Saving work
Przemog1 Dec 1, 2024
cee85d1
Refactor
Przemog1 Dec 4, 2024
a8a7802
Saving work
Przemog1 Dec 6, 2024
68d9ea0
Improvements
Przemog1 Dec 7, 2024
84906bb
Refactor
Przemog1 Dec 9, 2024
a7d1600
Fixes
Przemog1 Dec 11, 2024
6fec756
Merge branch 'cpp_compat_intrinsics_refactor' of github.com:Devsh-Gra…
Przemog1 Dec 12, 2024
4c58e03
Saving work
Przemog1 Dec 13, 2024
73ac5c8
Merge branch 'master' of github.com:Devsh-Graphics-Programming/Nabla-…
Przemog1 Dec 16, 2024
01b05ce
Merge branch 'cpp_compat_intrinsics_refactor' of github.com:Devsh-Gra…
Przemog1 Dec 17, 2024
1d133bb
Saving work
Przemog1 Dec 18, 2024
9649fda
Fixes
Przemog1 Dec 19, 2024
383fb3c
Merge branch 'ef64_t' into emulated_float64_t
Przemog1 Dec 19, 2024
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
4 changes: 2 additions & 2 deletions 02_HelloCompute/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ class HelloComputeApp final : public nbl::application_templates::MonoSystemMonoL
.binding=0,
.type=nbl::asset::IDescriptor::E_TYPE::ET_STORAGE_BUFFER,
.createFlags=IGPUDescriptorSetLayout::SBinding::E_CREATE_FLAGS::ECF_NONE, // not is not the time for descriptor indexing
.stageFlags=IGPUShader::E_SHADER_STAGE::ESS_COMPUTE,
.count=1,
.stageFlags=nbl::hlsl::ShaderStage::ESS_COMPUTE,
.count=1
}
};
smart_refctd_ptr<IGPUDescriptorSetLayout> dsLayout = device->createDescriptorSetLayout(bindings);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma wave shader_stage(compute)
#include "common.hlsl"
#include <nbl/builtin/hlsl/emulated_float64_t.hlsl>

[numthreads(256,1,1)]
void main()
{
const emulated::float64_t a = _static_cast<emulated::float64_t>(6.9f);
const emulated::float64_t b = _static_cast<emulated::float64_t>(4.5f);

vk::RawBufferStore<emulated::float64_t::storage_t>(0,(a*b).data);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

umm this is unsafe, you're writing to gpu virtual address of 0u, you might crash. you create a buffer and pass the address via push constant

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it kinda looks like a file someone forgot to remove (no chanes in 03 main.cpp)


const float asdf = 1.0f;
const float asdff = 1.0f;
}
2 changes: 1 addition & 1 deletion 62_CAD/shaders/geotexture/common.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ NBL_CONSTEXPR uint32_t MaxGeoTextures = 256;
// GeoTexture Oriented Bounding Box
struct GeoTextureOBB
{
float64_t2 topLeft; // 2 * 8 = 16 bytes
pfloat64_t2 topLeft; // 2 * 8 = 16 bytes
float32_t2 dirU; // 2 * 4 = 8 bytes (24)
float32_t aspectRatio; // 4 bytes (32)
};
Expand Down
6 changes: 3 additions & 3 deletions 62_CAD/shaders/geotexture/vertex_shader.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ PSInput main(uint vertexID : SV_VertexID)
outV.position.z = 0.0;

const float32_t2 dirV = float32_t2(geoTextureOBB.dirU.y, -geoTextureOBB.dirU.x) * geoTextureOBB.aspectRatio;
const float2 screenTopLeft = (float2) transformPointNdc(clipProjectionData.projectionToNDC, geoTextureOBB.topLeft);
const float2 screenDirU = (float2) transformVectorNdc(clipProjectionData.projectionToNDC, geoTextureOBB.dirU);
const float2 screenDirV = (float2) transformVectorNdc(clipProjectionData.projectionToNDC, dirV);
const float2 screenTopLeft = _static_cast<float2>(transformPointNdc(clipProjectionData.projectionToNDC, geoTextureOBB.topLeft));
const float2 screenDirU = _static_cast<float2>(transformVectorNdc(clipProjectionData.projectionToNDC, _static_cast<pfloat64_t2>(geoTextureOBB.dirU)));
const float2 screenDirV = _static_cast<float2>(transformVectorNdc(clipProjectionData.projectionToNDC, _static_cast<pfloat64_t2>(dirV)));

const float2 corner = float2(bool2(vertexIdx & 0x1u, vertexIdx >> 1)); // corners of square from (0, 0) to (1, 1)

Expand Down
63 changes: 56 additions & 7 deletions 62_CAD/shaders/globals.hlsl
Original file line number Diff line number Diff line change
@@ -1,15 +1,38 @@
#ifndef _CAD_EXAMPLE_GLOBALS_HLSL_INCLUDED_
#define _CAD_EXAMPLE_GLOBALS_HLSL_INCLUDED_

#include <nbl/builtin/hlsl/portable/float64_t.hlsl>
#include <nbl/builtin/hlsl/portable/vector_t.hlsl>
#include <nbl/builtin/hlsl/portable/matrix_t.hlsl>
#include <nbl/builtin/hlsl/cpp_compat/basic.h>
#include <nbl/builtin/hlsl/cpp_compat/matrix.hlsl>

#ifdef __HLSL_VERSION
#include <nbl/builtin/hlsl/math/equations/quadratic.hlsl>
#include <nbl/builtin/hlsl/jit/device_capabilities.hlsl>
#endif

using namespace nbl::hlsl;

// because we can't use jit/device_capabilities.hlsl in c++ code
#ifdef __HLSL_VERSION
using pfloat64_t = portable_float64_t<jit::device_capabilities>;
using pfloat64_t2 = portable_float64_t2<jit::device_capabilities>;
using pfloat64_t3 = portable_float64_t3<jit::device_capabilities>;
using pfloat64_t3x3 = portable_float64_t3x3<jit::device_capabilities>;
#else
using pfloat64_t = float64_t;
using pfloat64_t2 = nbl::hlsl::vector<float64_t, 2>;
using pfloat64_t3 = nbl::hlsl::vector<float64_t, 3>;
using pfloat64_t3x3 = portable_float64_t3x3<>;
#endif

// TODO: Compute this in a compute shader from the world counterparts
// because this struct includes NDC coordinates, the values will change based camera zoom and move
// of course we could have the clip values to be in world units and also the matrix to transform to world instead of ndc but that requires extra computations(matrix multiplications) per vertex
struct ClipProjectionData
{
float64_t3x3 projectionToNDC; // 72 -> because we use scalar_layout
pfloat64_t3x3 projectionToNDC; // 72 -> because we use scalar_layout
float32_t2 minClipNDC; // 80
float32_t2 maxClipNDC; // 88
};
Expand All @@ -23,8 +46,8 @@ static_assert(offsetof(ClipProjectionData, maxClipNDC) == 80u);
struct Globals
{
ClipProjectionData defaultClipProjection; // 88
double screenToWorldRatio; // 96
double worldToScreenRatio; // 100
pfloat64_t screenToWorldRatio; // 96
pfloat64_t worldToScreenRatio; // 100
uint32_t2 resolution; // 108
float antiAliasingFactor; // 112
float miterLimit; // 116
Expand All @@ -40,13 +63,39 @@ static_assert(offsetof(Globals, antiAliasingFactor) == 112u);
static_assert(offsetof(Globals, miterLimit) == 116u);
#endif

inline float64_t2 transformPointNdc(float64_t3x3 transformation, float64_t2 point2d)
// TODO[Przemek]: remove `#ifdef __HLSL_VERSION` and mul shouldn't use jit::device_caps, preferably do this with nbl::hlsl::mul instead of portableMul64
#ifdef __HLSL_VERSION
pfloat64_t2 transformPointNdc(pfloat64_t3x3 transformation, pfloat64_t2 point2d)
{
return mul(transformation, float64_t3(point2d, 1)).xy;
pfloat64_t3 point3d;
point3d.x = point2d.x;
point3d.y = point2d.y;
point3d.z = _static_cast < pfloat64_t > (1.0f);

pfloat64_t3 transformationResult = portableMul64 < pfloat64_t3x3, pfloat64_t3, jit::
device_capabilities > (transformation, point3d);
pfloat64_t2 output;
output.x = transformationResult.x;
output.y = transformationResult.y;

return output;
}
inline float64_t2 transformVectorNdc(float64_t3x3 transformation, float64_t2 vector2d)
pfloat64_t2 transformVectorNdc(pfloat64_t3x3 transformation, pfloat64_t2 vector2d)
{
return mul(transformation, float64_t3(vector2d, 0)).xy;
pfloat64_t3 vector3d;
vector3d.x = vector2d.x;
vector3d.y = vector2d.y;
vector3d.z = _static_cast < pfloat64_t > (0.0f);

pfloat64_t3 transformationResult = portableMul64 < pfloat64_t3x3, pfloat64_t3, jit::
device_capabilities > (transformation, vector3d);
pfloat64_t2 output;
output.x = transformationResult.x;
output.y = transformationResult.y;

return output;
}
#endif


#endif
81 changes: 39 additions & 42 deletions 62_CAD/shaders/main_pipeline/common.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
#include <nbl/builtin/hlsl/limits.hlsl>
#include <nbl/builtin/hlsl/glsl_compat/core.hlsl>
#include <nbl/builtin/hlsl/shapes/beziers.hlsl>
#ifdef __HLSL_VERSION
#include <nbl/builtin/hlsl/math/equations/quadratic.hlsl>
#endif

enum class ObjectType : uint32_t
{
Expand Down Expand Up @@ -42,14 +39,14 @@ struct DrawObject

struct LinePointInfo
{
float64_t2 p;
pfloat64_t2 p;
float32_t phaseShift;
float32_t stretchValue;
};

struct QuadraticBezierInfo
{
nbl::hlsl::shapes::QuadraticBezier<float64_t> shape; // 48bytes = 3 (control points) x 16 (float64_t2)
shapes::QuadraticBezier<pfloat64_t> shape; // 48bytes = 3 (control points) x 16 (emulated_float64_t)
float32_t phaseShift;
float32_t stretchValue;
};
Expand All @@ -59,7 +56,7 @@ static_assert(offsetof(QuadraticBezierInfo, phaseShift) == 48u);

struct GlyphInfo
{
float64_t2 topLeft; // 2 * 8 = 16 bytes
pfloat64_t2 topLeft; // 2 * 8 = 16 bytes
float32_t2 dirU; // 2 * 4 = 8 bytes (24)
float32_t aspectRatio; // 4 bytes (32)
// unorm8 minU;
Expand All @@ -68,12 +65,12 @@ struct GlyphInfo
uint32_t minUV_textureID_packed; // 4 bytes (36)

#ifndef __HLSL_VERSION
GlyphInfo(float64_t2 topLeft, float32_t2 dirU, float32_t aspectRatio, uint16_t textureId, float32_t2 minUV) :
GlyphInfo(pfloat64_t2 topLeft, float32_t2 dirU, float32_t aspectRatio, uint16_t textureId, float32_t2 minUV) :
topLeft(topLeft),
dirU(dirU),
aspectRatio(aspectRatio)
{
assert(textureId < nbl::hlsl::numeric_limits<uint16_t>::max);
assert(textureId < numeric_limits<uint16_t>::max);
packMinUV_TextureID(minUV, textureId);
}
#endif
Expand All @@ -90,20 +87,20 @@ struct GlyphInfo
float32_t2 getMinUV()
{
return float32_t2(
float32_t(nbl::hlsl::glsl::bitfieldExtract<uint32_t>(minUV_textureID_packed, 16, 8)) / 255.0,
float32_t(nbl::hlsl::glsl::bitfieldExtract<uint32_t>(minUV_textureID_packed, 24, 8)) / 255.0
float32_t(glsl::bitfieldExtract<uint32_t>(minUV_textureID_packed, 16, 8)) / 255.0,
float32_t(glsl::bitfieldExtract<uint32_t>(minUV_textureID_packed, 24, 8)) / 255.0
);
}

uint16_t getTextureID()
{
return uint16_t(nbl::hlsl::glsl::bitfieldExtract<uint32_t>(minUV_textureID_packed, 0, 16));
return uint16_t(glsl::bitfieldExtract<uint32_t>(minUV_textureID_packed, 0, 16));
}
};

struct ImageObjectInfo
{
float64_t2 topLeft; // 2 * 8 = 16 bytes (16)
pfloat64_t2 topLeft; // 2 * 8 = 16 bytes (16)
float32_t2 dirU; // 2 * 4 = 8 bytes (24)
float32_t aspectRatio; // 4 bytes (28)
uint32_t textureID; // 4 bytes (32)
Expand Down Expand Up @@ -143,7 +140,7 @@ static float32_t3 unpackR11G11B10_UNORM(uint32_t packed)

struct PolylineConnector
{
float64_t2 circleCenter;
pfloat64_t2 circleCenter;
float32_t2 v;
float32_t cosAngleDifferenceHalf;
float32_t _reserved_pad;
Expand All @@ -153,8 +150,8 @@ struct PolylineConnector
struct CurveBox
{
// will get transformed in the vertex shader, and will be calculated on the cpu when generating these boxes
float64_t2 aabbMin; // 16
float64_t2 aabbMax; // 32 , TODO: we know it's a square/box -> we save 8 bytes if we needed to store extra data
pfloat64_t2 aabbMin; // 16
pfloat64_t2 aabbMax; // 32 , TODO: we know it's a square/box -> we save 8 bytes if we needed to store extra data
float32_t2 curveMin[3]; // 56
float32_t2 curveMax[3]; // 80
};
Expand All @@ -168,7 +165,7 @@ static_assert(sizeof(CurveBox) == 80u);
#endif

NBL_CONSTEXPR uint32_t InvalidRigidSegmentIndex = 0xffffffff;
NBL_CONSTEXPR float InvalidStyleStretchValue = nbl::hlsl::numeric_limits<float>::infinity;
NBL_CONSTEXPR float InvalidStyleStretchValue = numeric_limits<float>::infinity;

// The color parameter is also used for styling non-curve objects such as text glyphs and hatches with solid color
struct LineStyle
Expand Down Expand Up @@ -250,8 +247,8 @@ NBL_CONSTEXPR uint32_t AlphaBits = 32u - MainObjectIdxBits;
NBL_CONSTEXPR uint32_t MaxIndexableMainObjects = (1u << MainObjectIdxBits) - 1u;
NBL_CONSTEXPR uint32_t InvalidStyleIdx = nbl::hlsl::numeric_limits<uint32_t>::max;
NBL_CONSTEXPR uint32_t InvalidMainObjectIdx = MaxIndexableMainObjects;
NBL_CONSTEXPR uint64_t InvalidClipProjectionAddress = nbl::hlsl::numeric_limits<uint64_t>::max;
NBL_CONSTEXPR uint32_t InvalidTextureIdx = nbl::hlsl::numeric_limits<uint32_t>::max;
NBL_CONSTEXPR uint64_t InvalidClipProjectionAddress = numeric_limits<uint64_t>::max;
NBL_CONSTEXPR uint32_t InvalidTextureIdx = numeric_limits<uint32_t>::max;
NBL_CONSTEXPR MajorAxis SelectedMajorAxis = MajorAxis::MAJOR_Y;
// TODO: get automatic version working on HLSL
NBL_CONSTEXPR MajorAxis SelectedMinorAxis = MajorAxis::MAJOR_X; //(MajorAxis) (1 - (uint32_t) SelectedMajorAxis);
Expand All @@ -263,26 +260,26 @@ NBL_CONSTEXPR float HatchFillMSDFSceenSpaceSize = 8.0;

#ifdef __HLSL_VERSION

// TODO: Use these in C++ as well once nbl::hlsl::numeric_limits<uint32_t> compiles on C++
// TODO: Use these in C++ as well once numeric_limits<uint32_t> compiles on C++
float32_t2 unpackCurveBoxUnorm(uint32_t2 value)
{
return float32_t2(value) / float32_t(nbl::hlsl::numeric_limits<uint32_t>::max);
return float32_t2(value) / float32_t(numeric_limits<uint32_t>::max);
}

float32_t2 unpackCurveBoxSnorm(int32_t2 value)
{
return float32_t2(value) / float32_t(nbl::hlsl::numeric_limits<int32_t>::max);
return float32_t2(value) / float32_t(numeric_limits<int32_t>::max);
}


uint32_t2 packCurveBoxUnorm(float32_t2 value)
{
return value * float32_t(nbl::hlsl::numeric_limits<uint32_t>::max);
return value * float32_t(numeric_limits<uint32_t>::max);
}

int32_t2 packCurveBoxSnorm(float32_t2 value)
{
return value * float32_t(nbl::hlsl::numeric_limits<int32_t>::max);
return value * float32_t(numeric_limits<int32_t>::max);
}

// TODO: Remove these two when we include our builtin shaders
Expand Down Expand Up @@ -317,7 +314,7 @@ struct PrecomputedRootFinder
return result;
}

static PrecomputedRootFinder construct(nbl::hlsl::math::equations::Quadratic<float_t> quadratic)
static PrecomputedRootFinder construct(math::equations::Quadratic<float_t> quadratic)
{
PrecomputedRootFinder result;
result.C2 = quadratic.c * 2.0;
Expand Down Expand Up @@ -369,25 +366,25 @@ struct PSInput
void setLineEnd(float2 lineEnd) { data2.zw = lineEnd; }

/* QUAD_BEZIER */
nbl::hlsl::shapes::Quadratic<float> getQuadratic()
shapes::Quadratic<float> getQuadratic()
{
return nbl::hlsl::shapes::Quadratic<float>::construct(data2.xy, data2.zw, data3.xy);
return shapes::Quadratic<float>::construct(data2.xy, data2.zw, data3.xy);
}
void setQuadratic(nbl::hlsl::shapes::Quadratic<float> quadratic)
void setQuadratic(shapes::Quadratic<float> quadratic)
{
data2.xy = quadratic.A;
data2.zw = quadratic.B;
data3.xy = quadratic.C;
}

void setQuadraticPrecomputedArcLenData(nbl::hlsl::shapes::Quadratic<float>::ArcLengthCalculator preCompData)
void setQuadraticPrecomputedArcLenData(shapes::Quadratic<float>::ArcLengthCalculator preCompData)
{
data3.zw = float2(preCompData.lenA2, preCompData.AdotB);
data4 = float4(preCompData.a, preCompData.b, preCompData.c, preCompData.b_over_4a);
}
nbl::hlsl::shapes::Quadratic<float>::ArcLengthCalculator getQuadraticArcLengthCalculator()
shapes::Quadratic<float>::ArcLengthCalculator getQuadraticArcLengthCalculator()
{
return nbl::hlsl::shapes::Quadratic<float>::ArcLengthCalculator::construct(data3.z, data3.w, data4.x, data4.y, data4.z, data4.w);
return shapes::Quadratic<float>::ArcLengthCalculator::construct(data3.z, data3.w, data4.x, data4.y, data4.z, data4.w);
}

/* CURVE_BOX */
Expand All @@ -397,38 +394,38 @@ struct PSInput
// TODO: possible optimization: passing precomputed values for solving the quadratic equation instead

// data2, data3, data4
nbl::hlsl::math::equations::Quadratic<float> getCurveMinMinor() {
return nbl::hlsl::math::equations::Quadratic<float>::construct(data2.x, data2.y, data2.z);
math::equations::Quadratic<float> getCurveMinMinor() {
return math::equations::Quadratic<float>::construct(data2.x, data2.y, data2.z);
}
nbl::hlsl::math::equations::Quadratic<float> getCurveMaxMinor() {
return nbl::hlsl::math::equations::Quadratic<float>::construct(data2.w, data3.x, data3.y);
math::equations::Quadratic<float> getCurveMaxMinor() {
return math::equations::Quadratic<float>::construct(data2.w, data3.x, data3.y);
}

void setCurveMinMinor(nbl::hlsl::math::equations::Quadratic<float> bezier) {
void setCurveMinMinor(math::equations::Quadratic<float> bezier) {
data2.x = bezier.a;
data2.y = bezier.b;
data2.z = bezier.c;
}
void setCurveMaxMinor(nbl::hlsl::math::equations::Quadratic<float> bezier) {
void setCurveMaxMinor(math::equations::Quadratic<float> bezier) {
data2.w = bezier.a;
data3.x = bezier.b;
data3.y = bezier.c;
}

// data4
nbl::hlsl::math::equations::Quadratic<float> getCurveMinMajor() {
return nbl::hlsl::math::equations::Quadratic<float>::construct(data4.x, data4.y, data3.z);
math::equations::Quadratic<float> getCurveMinMajor() {
return math::equations::Quadratic<float>::construct(data4.x, data4.y, data3.z);
}
nbl::hlsl::math::equations::Quadratic<float> getCurveMaxMajor() {
return nbl::hlsl::math::equations::Quadratic<float>::construct(data4.z, data4.w, data3.w);
math::equations::Quadratic<float> getCurveMaxMajor() {
return math::equations::Quadratic<float>::construct(data4.z, data4.w, data3.w);
}

void setCurveMinMajor(nbl::hlsl::math::equations::Quadratic<float> bezier) {
void setCurveMinMajor(math::equations::Quadratic<float> bezier) {
data4.x = bezier.a;
data4.y = bezier.b;
data3.z = bezier.c;
}
void setCurveMaxMajor(nbl::hlsl::math::equations::Quadratic<float> bezier) {
void setCurveMaxMajor(math::equations::Quadratic<float> bezier) {
data4.z = bezier.a;
data4.w = bezier.b;
data3.w = bezier.c;
Expand Down
Loading