Changeset View
Changeset View
Standalone View
Standalone View
source/blender/gpu/intern/gpu_texture_private.hh
| Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | public: | ||||
| virtual void *read(int mip, eGPUDataFormat format) = 0; | virtual void *read(int mip, eGPUDataFormat format) = 0; | ||||
| void attach_to(FrameBuffer *fb, GPUAttachmentType type); | void attach_to(FrameBuffer *fb, GPUAttachmentType type); | ||||
| void detach_from(FrameBuffer *fb); | void detach_from(FrameBuffer *fb); | ||||
| void update(eGPUDataFormat format, const void *data); | void update(eGPUDataFormat format, const void *data); | ||||
| virtual void update_sub( | virtual void update_sub( | ||||
| int mip, int offset[3], int extent[3], eGPUDataFormat format, const void *data) = 0; | int mip, int offset[3], int extent[3], eGPUDataFormat format, const void *data) = 0; | ||||
| virtual void update_sub(int offset[3], | |||||
| int extent[3], | |||||
| eGPUDataFormat format, | |||||
| GPUPixelBuffer *pixbuf) = 0; | |||||
| /* TODO(fclem): Legacy. Should be removed at some point. */ | /* TODO(fclem): Legacy. Should be removed at some point. */ | ||||
| virtual uint gl_bindcode_get() const = 0; | virtual uint gl_bindcode_get() const = 0; | ||||
| int width_get() const | int width_get() const | ||||
| { | { | ||||
| return w_; | return w_; | ||||
| } | } | ||||
| int height_get() const | int height_get() const | ||||
| ▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| return reinterpret_cast<Texture *>(vert); | return reinterpret_cast<Texture *>(vert); | ||||
| } | } | ||||
| static inline const Texture *unwrap(const GPUTexture *vert) | static inline const Texture *unwrap(const GPUTexture *vert) | ||||
| { | { | ||||
| return reinterpret_cast<const Texture *>(vert); | return reinterpret_cast<const Texture *>(vert); | ||||
| } | } | ||||
| /* GPU pixel Buffer. */ | |||||
| class PixelBuffer { | |||||
| protected: | |||||
| uint size_ = 0; | |||||
| public: | |||||
| PixelBuffer(uint size) : size_(size){}; | |||||
| virtual ~PixelBuffer(){}; | |||||
| virtual void *map() = 0; | |||||
| virtual void unmap() = 0; | |||||
| virtual int64_t get_native_handle() = 0; | |||||
| virtual uint get_size() = 0; | |||||
| }; | |||||
| /* Syntactic sugar. */ | |||||
| static inline GPUPixelBuffer *wrap(PixelBuffer *pixbuf) | |||||
| { | |||||
| return reinterpret_cast<GPUPixelBuffer *>(pixbuf); | |||||
| } | |||||
| static inline PixelBuffer *unwrap(GPUPixelBuffer *pixbuf) | |||||
| { | |||||
| return reinterpret_cast<PixelBuffer *>(pixbuf); | |||||
| } | |||||
| static inline const PixelBuffer *unwrap(const GPUPixelBuffer *pixbuf) | |||||
| { | |||||
| return reinterpret_cast<const PixelBuffer *>(pixbuf); | |||||
| } | |||||
| #undef DEBUG_NAME_LEN | #undef DEBUG_NAME_LEN | ||||
| inline size_t to_bytesize(eGPUTextureFormat format) | inline size_t to_bytesize(eGPUTextureFormat format) | ||||
| { | { | ||||
| switch (format) { | switch (format) { | ||||
| case GPU_RGBA32F: | case GPU_RGBA32F: | ||||
| return 32; | return 32; | ||||
| case GPU_RG32F: | case GPU_RG32F: | ||||
| ▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | inline int to_component_len(eGPUTextureFormat format) | ||||
| } | } | ||||
| } | } | ||||
| inline size_t to_bytesize(eGPUDataFormat data_format) | inline size_t to_bytesize(eGPUDataFormat data_format) | ||||
| { | { | ||||
| switch (data_format) { | switch (data_format) { | ||||
| case GPU_DATA_UBYTE: | case GPU_DATA_UBYTE: | ||||
| return 1; | return 1; | ||||
| case GPU_DATA_HALF_FLOAT: | |||||
| return 2; | |||||
| case GPU_DATA_FLOAT: | case GPU_DATA_FLOAT: | ||||
| case GPU_DATA_INT: | case GPU_DATA_INT: | ||||
| case GPU_DATA_UINT: | case GPU_DATA_UINT: | ||||
| return 4; | return 4; | ||||
| case GPU_DATA_UINT_24_8: | case GPU_DATA_UINT_24_8: | ||||
| case GPU_DATA_10_11_11_REV: | case GPU_DATA_10_11_11_REV: | ||||
| case GPU_DATA_2_10_10_10_REV: | case GPU_DATA_2_10_10_10_REV: | ||||
| return 4; | return 4; | ||||
| ▲ Show 20 Lines • Show All 263 Lines • Show Last 20 Lines | |||||