PeriDyno 1.0.0
Loading...
Searching...
No Matches
GPUTexture.h
Go to the documentation of this file.
1
16
17#pragma once
18
19#include "Texture.h"
20#include <Vector.h>
21#include <Array/Array2D.h>
22
23#ifdef CUDA_BACKEND
24struct cudaGraphicsResource;
25#endif
26
27#ifdef VK_BACKEND
28#include <VkDeviceArray.h>
29#endif
30
31namespace dyno {
32
33 // texture for loading data from cuda/vulkan api
34 template<typename T>
35 class XTexture2D : public Texture2D
36 {
37 public:
40
41 virtual void create() override;
42 bool isValid() const;
43
44 // update OpenGL texture within GL context
45 void updateGL();
46
47 // load data to into an intermediate buffer
48 void load(dyno::DArray2D<T> data);
49
50 private:
51 int width = -1;
52 int height = -1;
53
54#ifdef CUDA_BACKEND
55 dyno::DArray2D<T> buffer;
56 cudaGraphicsResource* resource = 0;
57#endif
58
59#ifdef VK_BACKEND
61
62 VkBuffer buffer = VK_NULL_HANDLE;
63 VkDeviceMemory memory = VK_NULL_HANDLE;
64 bool resized = false;
65#ifdef WIN32
66 HANDLE handle = nullptr; // The Win32 handle
67#else
68 int fd = -1;
69#endif
70 // command for copy buffer
71 VkCommandBuffer copyCmd = VK_NULL_HANDLE;
72 // OpenGL memory object
73 unsigned int memoryObject = 0;
74#endif
75 };
76
77 template class XTexture2D<dyno::Vec4f>;
78 template class XTexture2D<dyno::Vec3f>;
79 template class XTexture2D<dyno::Vec3u>;
80}
bool isValid() const
virtual void create() override
void load(dyno::DArray2D< T > data)
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25
Array2D< T, DeviceType::CPU > CArray2D
Definition Array2D.h:131
Array2D< T, DeviceType::GPU > DArray2D
Definition Array2D.inl:90