Blender V5.3
blender/display_driver.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#include "GPU_context.hh"
6#include "GPU_immediate.hh"
7#include "GPU_platform.hh"
9#include "GPU_shader.hh"
10#include "GPU_state.hh"
11#include "GPU_texture.hh"
12
13#include "RE_engine.h"
14
16
17#include "util/log.h"
18#include "util/math.h"
19#include "util/vector.h"
20
22
23/* --------------------------------------------------------------------
24 * BlenderDisplayShader.
25 */
26
28 blender::Scene &b_scene)
29{
30 /* See #engine_support_display_space_shader in rna_render.cc. */
31 return make_unique<BlenderDisplaySpaceShader>(b_engine, b_scene);
32}
33
43
53
54/* --------------------------------------------------------------------
55 * BlenderDisplaySpaceShader.
56 */
57
63
72
77
79{
80 if (!shader_program_) {
82 }
83 if (!shader_program_) {
84 LOG_ERROR << "Error retrieving shader program for display space shader.";
85 }
86
87 return shader_program_;
88}
89
90/* --------------------------------------------------------------------
91 * DrawTile.
92 */
93
94/* Higher level representation of a texture from the graphics library. */
96 public:
97 /* Global counter for all allocated GPUTextures used by instances of this class. */
98 static inline std::atomic<int> num_used = 0;
99
100 DisplayGPUTexture() = default;
101
103 {
104 assert(gpu_texture == nullptr);
105 }
106
107 DisplayGPUTexture(const DisplayGPUTexture &other) = delete;
109
111 : gpu_texture(other.gpu_texture), width(other.width), height(other.height)
112 {
113 other.reset();
114 }
115
117 {
118 if (this == &other) {
119 return *this;
120 }
121
122 gpu_texture = other.gpu_texture;
123 width = other.width;
124 height = other.height;
125
126 other.reset();
127
128 return *this;
129 }
130
131 bool gpu_resources_ensure(const uint texture_width, const uint texture_height)
132 {
133 if (width != texture_width || height != texture_height) {
135 }
136
137 if (gpu_texture) {
138 return true;
139 }
140
141 width = texture_width;
142 height = texture_height;
143
144 /* Texture must have a minimum size of 1x1. */
145 gpu_texture = blender::GPU_texture_create_2d("CyclesBlitTexture",
146 max(width, 1),
147 max(height, 1),
148 1,
149 blender::gpu::TextureFormat::SFLOAT_16_16_16_16,
151 nullptr);
152
153 if (!gpu_texture) {
154 LOG_ERROR << "Error creating texture.";
155 return false;
156 }
157
160
161 ++num_used;
162
163 return true;
164 }
165
167 {
168 if (gpu_texture == nullptr) {
169 return;
170 }
171
173
174 reset();
175
176 --num_used;
177 }
178
179 /* Texture resource allocated by the GPU module.
180 *
181 * NOTE: Allocated on the render engine's context. */
183
184 /* Dimensions of the texture in pixels. */
185 int width = 0;
186 int height = 0;
187
188 protected:
189 void reset()
190 {
191 gpu_texture = nullptr;
192 width = 0;
193 height = 0;
194 }
195};
196
197/* Higher level representation of a Pixel Buffer Object (PBO) from the graphics library. */
199 public:
200 /* Global counter for all allocated GPU module PBOs used by instances of this class. */
201 static inline std::atomic<int> num_used = 0;
202
204
206 {
207 assert(gpu_pixel_buffer == nullptr);
208 }
209
212
214 : gpu_pixel_buffer(other.gpu_pixel_buffer), width(other.width), height(other.height)
215 {
216 other.reset();
217 }
218
220 {
221 if (this == &other) {
222 return *this;
223 }
224
225 gpu_pixel_buffer = other.gpu_pixel_buffer;
226 width = other.width;
227 height = other.height;
228
229 other.reset();
230
231 return *this;
232 }
233
234 bool gpu_resources_ensure(const uint new_width, const uint new_height, bool &buffer_recreated)
235 {
236 buffer_recreated = false;
237
238 const size_t required_size = sizeof(half4) * new_width * new_height;
239
240 /* Try to re-use the existing PBO if it has usable size. */
241 if (gpu_pixel_buffer) {
242 if (new_width != width || new_height != height ||
244 {
245 buffer_recreated = true;
247 }
248 }
249
250 /* Update size. */
251 width = new_width;
252 height = new_height;
253
254 /* Create pixel buffer if not already created. */
255 if (!gpu_pixel_buffer) {
257 buffer_recreated = true;
258 }
259
260 if (gpu_pixel_buffer == nullptr) {
261 LOG_ERROR << "Error creating texture pixel buffer object.";
262 return false;
263 }
264
265 ++num_used;
266
267 return true;
268 }
269
271 {
272 if (!gpu_pixel_buffer) {
273 return;
274 }
275
277 gpu_pixel_buffer = nullptr;
278
279 reset();
280
281 --num_used;
282 }
283
284 /* Pixel Buffer Object allocated by the GPU module.
285 *
286 * NOTE: Allocated on the render engine's context. */
287 blender::GPUPixelBuffer *gpu_pixel_buffer = nullptr;
288
289 /* Dimensions of the PBO. */
290 int width = 0;
291 int height = 0;
292
293 protected:
294 void reset()
295 {
296 gpu_pixel_buffer = nullptr;
297 width = 0;
298 height = 0;
299 }
300};
301
302class DrawTile {
303 public:
304 DrawTile() = default;
305 ~DrawTile() = default;
306
307 DrawTile(const DrawTile &other) = delete;
308 DrawTile &operator=(const DrawTile &other) = delete;
309
310 DrawTile(DrawTile &&other) noexcept = default;
311
312 DrawTile &operator=(DrawTile &&other) = default;
313
318
319 bool ready_to_draw() const
320 {
321 return texture.gpu_texture != nullptr;
322 }
323
324 /* Texture which contains pixels of the tile. */
326
327 /* Display parameters the texture of this tile has been updated for. */
329};
330
343
344/* --------------------------------------------------------------------
345 * BlenderDisplayDriver.
346 */
347
349 /* Resources of a tile which is being currently rendered. */
351
352 /* All tiles which rendering is finished and which content will not be changed. */
353 struct {
355
356 void gl_resources_destroy_and_clear()
357 {
358 for (DrawTile &tile : tiles) {
359 tile.gpu_resources_destroy();
360 }
361
362 tiles.clear();
363 }
365};
366
368 blender::Scene &b_scene,
369 blender::RegionView3D *b_rv3d,
370 const bool background)
371 : b_engine_(b_engine),
372 b_rv3d_(b_rv3d),
373 background_(background),
374 display_shader_(BlenderDisplayShader::create(b_engine, b_scene)),
375 tiles_(make_unique<Tiles>())
376{
377 /* Create context while on the main thread. */
379}
380
385
386/* --------------------------------------------------------------------
387 * Update procedure.
388 */
389
395
397{
398 if (!tiles_->current_tile.tile.ready_to_draw()) {
400 << "Unexpectedly moving to the next tile without any data provided for current tile.";
401 return;
402 }
403
404 /* Moving to the next tile without giving render data for the current tile is not an expected
405 * situation. */
407 /* Texture should have been updated from the PBO at this point. */
408 DCHECK(!tiles_->current_tile.need_update_texture_pixels);
409
410 tiles_->finished_tiles.tiles.emplace_back(std::move(tiles_->current_tile.tile));
411}
412
414 const int texture_width,
415 const int texture_height)
416{
417 /* Note that it's the responsibility of BlenderDisplayDriver to ensure updating and drawing
418 * the texture does not happen at the same time. This is achieved indirectly.
419 *
420 * When enabling the OpenGL/GPU context, it uses an internal mutex lock DST.gpu_context_lock.
421 * This same lock is also held when do_draw() is called, which together ensure mutual
422 * exclusion.
423 *
424 * This locking is not performed on the Cycles side, because that would cause lock inversion. */
425 if (!gpu_context_enable()) {
426 return false;
427 }
428
429 /* Note: The render window might not draw between tiles. Wait for the previous
430 * PBO-to-texture copy before reusing the PBO for the next tile. */
433
434 DrawTile &current_tile = tiles_->current_tile.tile;
435 DisplayGPUPixelBuffer &current_tile_buffer_object = tiles_->current_tile.buffer_object;
436
437 /* Clear storage of all finished tiles when display clear is requested.
438 * Do it when new tile data is provided to handle the display clear flag in a single place.
439 * It also makes the logic reliable from the whether drawing did happen or not point of view. */
440 if (need_zero_) {
441 tiles_->finished_tiles.gl_resources_destroy_and_clear();
442 need_zero_ = false;
443 }
444
445 /* Update PBO dimensions if needed.
446 *
447 * NOTE: Allocate the PBO for the size which will fit the final render resolution (as in,
448 * at a resolution divider 1. This was we don't need to recreate graphics interoperability
449 * objects which are costly and which are tied to the specific underlying buffer size.
450 * The downside of this approach is that when graphics interoperability is not used we are
451 * sending too much data to GPU when resolution divider is not 1. */
452 /* TODO(sergey): Investigate whether keeping the PBO exact size of the texture makes non-interop
453 * mode faster. */
454 const int buffer_width = params.size.x;
455 const int buffer_height = params.size.y;
456 bool interop_recreated = false;
457
458 if (!current_tile_buffer_object.gpu_resources_ensure(
459 buffer_width, buffer_height, interop_recreated) ||
460 !current_tile.texture.gpu_resources_ensure(texture_width, texture_height))
461 {
463 tiles_->current_tile.gpu_resources_destroy();
465 return false;
466 }
467
468 if (interop_recreated) {
470 }
471
472 /* Store an updated parameters of the current tile.
473 * In theory it is only needed once per update of the tile, but doing it on every update is
474 * the easiest and is not expensive. */
475 tiles_->current_tile.tile.params = params;
476
477 return true;
478}
479
481{
482 const DisplayGPUTexture &texture = tile.tile.texture;
483
484 if (!DCHECK_NOTNULL(tile.buffer_object.gpu_pixel_buffer)) {
485 LOG_ERROR << "Display driver tile pixel buffer unavailable.";
486 return;
487 }
490 tile.buffer_object.gpu_pixel_buffer,
491 0,
492 0,
493 0,
494 texture.width,
495 texture.height,
496 0);
497}
498
500{
501 /* Unpack the PBO into the texture as soon as the new content is provided.
502 *
503 * This allows to ensure that the unpacking happens while resources like graphics interop (which
504 * lifetime is outside of control of the display driver) are still valid, as well as allows to
505 * move the tile from being current to finished immediately after this call.
506 *
507 * One concern with this approach is that if the update happens more often than drawing then
508 * doing the unpack here occupies GPU transfer for no good reason. However, the render scheduler
509 * takes care of ensuring updates don't happen that often. In regular applications redraw will
510 * happen much more often than this update.
511 *
512 * On some older GPUs on macOS, there is a driver crash when updating the texture for viewport
513 * renders while Blender is drawing. As a workaround update texture during draw, under assumption
514 * that there is no graphics interop on macOS and viewport render has a single tile. */
519 {
520 tiles_->current_tile.need_update_texture_pixels = true;
521 }
522 else {
523 update_tile_texture_pixels(tiles_->current_tile);
524 }
525
526 /* Ensure GPU fence exists to synchronize upload. */
528
530
532
533 {
535 update_pending_ = false;
536 }
537 has_update_cond_.notify_all();
538}
539
540/* --------------------------------------------------------------------
541 * Texture buffer mapping.
542 */
543
545{
546 /* With multi device rendering, Cycles can switch between using graphics interop
547 * and not. For the denoised image it may be able to use graphics interop as that
548 * buffer is written to by one device, while the noisy renders can not use it.
549 *
550 * We need to clear the graphics interop buffer on that switch, as GPU_pixel_buffer_map
551 * may recreate the buffer or handle. */
553
554 blender::GPUPixelBuffer *pix_buf = tiles_->current_tile.buffer_object.gpu_pixel_buffer;
555 if (!DCHECK_NOTNULL(pix_buf)) {
556 LOG_ERROR << "Display driver tile pixel buffer unavailable.";
557 return nullptr;
558 }
559 half4 *mapped_rgba_pixels = reinterpret_cast<half4 *>(blender::GPU_pixel_buffer_map(pix_buf));
560 if (!mapped_rgba_pixels) {
561 LOG_ERROR << "Error mapping BlenderDisplayDriver pixel buffer object.";
562 }
563 return mapped_rgba_pixels;
564}
565
567{
568 blender::GPUPixelBuffer *pix_buf = tiles_->current_tile.buffer_object.gpu_pixel_buffer;
569 if (!DCHECK_NOTNULL(pix_buf)) {
570 LOG_ERROR << "Display driver tile pixel buffer unavailable.";
571 return;
572 }
574}
575
576/* --------------------------------------------------------------------
577 * Graphics interoperability.
578 */
579
581{
582 GraphicsInteropDevice interop_device;
583
586 interop_device.type = GraphicsInteropDevice::OPENGL;
587 break;
589 interop_device.type = GraphicsInteropDevice::VULKAN;
590 break;
592 interop_device.type = GraphicsInteropDevice::METAL;
593 break;
596 interop_device.type = GraphicsInteropDevice::NONE;
597 break;
598 }
599
601 interop_device.uuid.resize(uuid.size());
602 std::copy_n(uuid.data(), uuid.size(), interop_device.uuid.data());
603
604 return interop_device;
605}
606
631
636
641
642/* --------------------------------------------------------------------
643 * Drawing.
644 */
645
647{
648 need_zero_ = true;
649}
650
651void BlenderDisplayDriver::set_zoom(const float zoom_x, const float zoom_y)
652{
653 zoom_ = make_float2(zoom_x, zoom_y);
654}
655
656/* Update vertex buffer with new coordinates of vertex positions and texture coordinates.
657 * This buffer is used to render texture in the viewport.
658 *
659 * NOTE: The buffer needs to be bound. */
660static void vertex_draw(const DisplayDriver::Params &params,
661 const int texcoord_attribute,
662 const int position_attribute)
663{
664 const int x = params.full_offset.x;
665 const int y = params.full_offset.y;
666
667 const int width = params.size.x;
668 const int height = params.size.y;
669
671
672 blender::immAttr2f(texcoord_attribute, 1.0f, 0.0f);
673 blender::immVertex2f(position_attribute, x + width, y);
674
675 blender::immAttr2f(texcoord_attribute, 1.0f, 1.0f);
676 blender::immVertex2f(position_attribute, x + width, y + height);
677
678 blender::immAttr2f(texcoord_attribute, 0.0f, 0.0f);
679 blender::immVertex2f(position_attribute, x, y);
680
681 blender::immAttr2f(texcoord_attribute, 0.0f, 1.0f);
682 blender::immVertex2f(position_attribute, x, y + height);
683
685}
686
687static void draw_tile(const float2 &zoom,
688 const int texcoord_attribute,
689 const int position_attribute,
690 const DrawTile &draw_tile)
691{
692 if (!draw_tile.ready_to_draw()) {
693 return;
694 }
695
696 const DisplayGPUTexture &texture = draw_tile.texture;
697
698 if (!DCHECK_NOTNULL(texture.gpu_texture)) {
699 LOG_ERROR << "Display driver tile GPU texture resource unavailable.";
700 return;
701 }
702
703 /* Trick to keep sharp rendering without jagged edges on all GPUs.
704 *
705 * The idea here is to enforce driver to use linear interpolation when the image is zoomed out.
706 * For the render result with a resolution divider in effect we always use nearest interpolation.
707 *
708 * Use explicit MIN assignment to make sure the driver does not have an undefined behavior at
709 * the zoom level 1. The MAG filter is always NEAREST. */
710 const float zoomed_width = draw_tile.params.size.x * zoom.x;
711 const float zoomed_height = draw_tile.params.size.y * zoom.y;
712 if (texture.width != draw_tile.params.size.x || texture.height != draw_tile.params.size.y) {
713 /* Resolution divider is different from 1, force nearest interpolation. */
716 }
717 else if (zoomed_width - draw_tile.params.size.x > -0.5f ||
718 zoomed_height - draw_tile.params.size.y > -0.5f)
719 {
722 }
723 else {
724 blender::GPU_texture_bind_ex(texture.gpu_texture, {blender::GPU_SAMPLER_FILTERING_LINEAR}, 0);
725 }
726
727 /* Draw at the parameters for which the texture has been updated for. This allows to always draw
728 * texture during bordered-rendered camera view without flickering. The validness of the display
729 * parameters for a texture is guaranteed by the initial "clear" state which makes drawing to
730 * have an early output.
731 *
732 * Such approach can cause some extra "jelly" effect during panning, but it is not more jelly
733 * than overlay of selected objects. Also, it's possible to redraw texture at an intersection of
734 * the texture draw parameters and the latest updated draw parameters (although, complexity of
735 * doing it might not worth it. */
736 vertex_draw(draw_tile.params, texcoord_attribute, position_attribute);
737}
738
740{
741 /* This is called from the render thread that also calls update_begin/end, right before ending
742 * the render loop. We wait for any queued PBO and render commands to be done, before destroying
743 * the render thread and activating the context in the main thread to destroy resources.
744 *
745 * If we don't do this, the NVIDIA driver hangs for a few seconds for when ending 3D viewport
746 * rendering, for unknown reasons. This was found with NVIDIA driver version 470.73 and a Quadro
747 * RTX 6000 on Linux. */
748 if (!gpu_context_enable()) {
749 return;
750 }
751
754
756}
757
759{
761 /* Before drawing, wait that an update to the texture has actually occurred, to synchronize
762 * rendering of Cycles with Blender. Only do this after a reset, e.g. due to the camera
763 * changing while navigating. Redraws that did not trigger a reset can reuse the current
764 * texture immediately to avoid stutters. Also use a timeout to prevent user interface in the
765 * main thread from becoming unresponsive when rendering is too heavy. */
767 has_update_cond_.wait_for(
768 lock, std::chrono::milliseconds(33), [this] { return !update_pending_; });
769 }
770
772
773 if (need_zero_) {
774 /* Texture is requested to be cleared and was not yet cleared.
775 *
776 * Do early return which should be equivalent of drawing all-zero texture.
777 * Watch out for the lock though so that the clear happening during update is properly
778 * synchronized here. */
780 return;
781 }
782
785
786 blender::gpu::Shader *active_shader = display_shader_->bind(params.full_size.x,
787 params.full_size.y);
788
790 const int texcoord_attribute = blender::GPU_vertformat_attr_add(
791 format,
792 ccl::BlenderDisplayShader::tex_coord_attribute_name,
793 blender::gpu::VertAttrType::SFLOAT_32_32);
794 const int position_attribute = blender::GPU_vertformat_attr_add(
795 format,
796 ccl::BlenderDisplayShader::position_attribute_name,
797 blender::gpu::VertAttrType::SFLOAT_32_32);
798
799 /* NOTE: Shader is bound again through IMM to register this shader with the IMM module
800 * and perform required setup for IMM rendering. This is required as the IMM module
801 * needs to be aware of which shader is bound, and the main display shader
802 * is bound externally. */
803 blender::immBindShader(active_shader);
804
805 if (tiles_->current_tile.need_update_texture_pixels) {
806 update_tile_texture_pixels(tiles_->current_tile);
807 tiles_->current_tile.need_update_texture_pixels = false;
808 }
809
810 draw_tile(zoom_, texcoord_attribute, position_attribute, tiles_->current_tile.tile);
811
812 for (const DrawTile &tile : tiles_->finished_tiles.tiles) {
813 draw_tile(zoom_, texcoord_attribute, position_attribute, tile);
814 }
815
816 /* Reset IMM shader bind state. */
818
819 display_shader_->unbind();
820
822
825
827
828 LOG_TRACE << "Display driver number of textures: " << DisplayGPUTexture::num_used;
829 LOG_TRACE << "Display driver number of PBOs: " << DisplayGPUPixelBuffer::num_used;
830}
831
833{
834 if (!RE_engine_gpu_context_create(&b_engine_)) {
835 LOG_ERROR << "Error creating GPU context.";
836 return;
837 }
838
839 /* Create global GPU resources for display driver. */
840 if (!gpu_resources_create()) {
841 LOG_ERROR << "Error creating GPU resources for Display Driver.";
842 return;
843 }
844}
845
847{
848 return RE_engine_gpu_context_enable(&b_engine_);
849}
850
852{
853 RE_engine_gpu_context_disable(&b_engine_);
854}
855
857{
858 RE_engine_gpu_context_destroy(&b_engine_);
859}
860
862{
863 RE_engine_gpu_context_lock(&b_engine_);
864}
865
867{
868 RE_engine_gpu_context_unlock(&b_engine_);
869}
870
872{
873 /* Ensure context is active for resource creation. */
874 if (!gpu_context_enable()) {
875 LOG_ERROR << "Error enabling GPU context.";
876 return false;
877 }
878
881
883 LOG_ERROR << "Error creating GPU synchronization primitives.";
884 assert(0);
885 return false;
886 }
887
889 return true;
890}
891
893{
895
896 display_shader_.reset();
897
899
900 tiles_->current_tile.gpu_resources_destroy();
901 tiles_->finished_tiles.gl_resources_destroy_and_clear();
902
903 /* Fences. */
904 if (gpu_render_sync_) {
906 gpu_render_sync_ = nullptr;
907 }
908 if (gpu_upload_sync_) {
910 gpu_upload_sync_ = nullptr;
911 }
912
914
916}
917
#define GPU_TEXTURE_FREE_SAFE(texture)
volatile int lock
static void update_tile_texture_pixels(const DrawTileAndPBO &tile)
static void vertex_draw(const DisplayDriver::Params &params, const int texcoord_attribute, const int position_attribute)
static void draw_tile(const float2 &zoom, const int texcoord_attribute, const int position_attribute, const DrawTile &draw_tile)
btScalar max
GraphicsInteropDevice graphics_interop_get_device() override
half4 * map_texture_buffer() override
blender::GPUFence * gpu_upload_sync_
thread_condition_variable has_update_cond_
blender::RegionView3D * b_rv3d_
void graphics_interop_activate() override
void draw(const Params &params) override
std::atomic< bool > need_zero_
unique_ptr< BlenderDisplayShader > display_shader_
void graphics_interop_deactivate() override
blender::GPUFence * gpu_render_sync_
void graphics_interop_update_buffer() override
blender::RenderEngine & b_engine_
bool update_begin(const Params &params, const int texture_width, const int texture_height) override
void set_zoom(const float zoom_x, const float zoom_y)
BlenderDisplayDriver(blender::RenderEngine &b_engine, blender::Scene &b_scene, blender::RegionView3D *b_rv3d, const bool background)
virtual int get_position_attrib_location()
static constexpr const char * tex_coord_attribute_name
static constexpr const char * position_attribute_name
static unique_ptr< BlenderDisplayShader > create(blender::RenderEngine &b_engine, blender::Scene &b_scene)
virtual blender::gpu::Shader * get_shader_program()=0
virtual int get_tex_coord_attrib_location()
blender::gpu::Shader * shader_program_
blender::gpu::Shader * bind(const int width, const int height) override
blender::gpu::Shader * get_shader_program() override
blender::RenderEngine & b_engine_
BlenderDisplaySpaceShader(blender::RenderEngine &b_engine, blender::Scene &b_scene)
GraphicsInteropBuffer graphics_interop_buffer_
bool gpu_resources_ensure(const uint new_width, const uint new_height, bool &buffer_recreated)
DisplayGPUPixelBuffer()=default
static std::atomic< int > num_used
DisplayGPUPixelBuffer(const DisplayGPUPixelBuffer &other)=delete
blender::GPUPixelBuffer * gpu_pixel_buffer
DisplayGPUPixelBuffer & operator=(DisplayGPUPixelBuffer &other)=delete
DisplayGPUPixelBuffer(DisplayGPUPixelBuffer &&other) noexcept
DisplayGPUPixelBuffer & operator=(DisplayGPUPixelBuffer &&other)
bool gpu_resources_ensure(const uint texture_width, const uint texture_height)
DisplayGPUTexture & operator=(DisplayGPUTexture &other)=delete
DisplayGPUTexture(DisplayGPUTexture &&other) noexcept
DisplayGPUTexture & operator=(DisplayGPUTexture &&other)
static std::atomic< int > num_used
blender::gpu::Texture * gpu_texture
DisplayGPUTexture()=default
DisplayGPUTexture(const DisplayGPUTexture &other)=delete
DisplayGPUPixelBuffer buffer_object
DrawTile(const DrawTile &other)=delete
~DrawTile()=default
DrawTile(DrawTile &&other) noexcept=default
bool ready_to_draw() const
DrawTile()=default
BlenderDisplayDriver::Params params
DrawTile & operator=(DrawTile &&other)=default
DrawTile & operator=(const DrawTile &other)=delete
DisplayGPUTexture texture
void assign(GraphicsInteropDevice::Type type, int64_t handle, size_t size)
constexpr const T * data() const
Definition BLI_span.hh:219
constexpr int64_t size() const
Definition BLI_span.hh:256
#define CCL_NAMESPACE_END
#define assert(assertion)
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
const ccl_global KernelWorkTile * tile
#define DCHECK(expression)
Definition log.h:135
#define DCHECK_NOTNULL(expression)
Definition log.h:137
#define LOG_ERROR
Definition log.h:101
#define LOG_TRACE
Definition log.h:108
void GPU_fence_free(GPUFence *fence)
Definition gpu_state.cc:316
bool GPU_type_matches_ex(GPUDeviceType device, GPUOSType os, GPUDriverType driver, GPUBackendType backend)
void immEnd()
GPUVertFormat * immVertexFormat()
GPUBackendType GPU_backend_get_type()
@ GPU_DATA_HALF_FLOAT
void immBegin(GPUPrimType, uint vertex_len)
@ GPU_SAMPLER_EXTEND_MODE_EXTEND
@ GPU_PRIM_TRI_STRIP
void GPU_pixel_buffer_unmap(GPUPixelBuffer *pixel_buf)
void * GPU_pixel_buffer_map(GPUPixelBuffer *pixel_buf)
int GPU_shader_get_attribute(const gpu::Shader *shader, const char *name)
void GPU_fence_wait(GPUFence *fence)
Definition gpu_state.cc:326
void immAttr2f(uint attr_id, float x, float y)
void immUnbindProgram()
@ GPU_BLEND_NONE
Definition GPU_state.hh:88
@ GPU_BLEND_ALPHA_PREMULT
Definition GPU_state.hh:91
GPUFence * GPU_fence_create()
Definition gpu_state.cc:310
void immVertex2f(uint attr_id, float x, float y)
@ GPU_TEXTURE_USAGE_GENERAL
void GPU_shader_unbind()
void GPU_texture_filter_mode(gpu::Texture *texture, bool use_filter)
void GPU_shader_bind(gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants_state=nullptr)
void GPU_texture_bind_ex(gpu::Texture *texture, GPUSamplerState state, int unit)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
void GPU_texture_extend_mode(gpu::Texture *texture, GPUSamplerExtendMode extend_mode)
gpu::Shader * GPU_shader_get_bound()
gpu::Shader * GPU_shader_get_builtin_shader(GPUBuiltinShader shader)
void GPU_pixel_buffer_free(GPUPixelBuffer *pixel_buf)
size_t GPU_pixel_buffer_size(GPUPixelBuffer *pixel_buf)
void GPU_flush()
Definition gpu_state.cc:284
GPUPixelBuffer * GPU_pixel_buffer_create(size_t byte_size)
void immBindShader(gpu::Shader *shader)
Span< uint8_t > GPU_platform_uuid()
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:44
void GPU_fence_signal(GPUFence *fence)
Definition gpu_state.cc:321
@ GPU_DEVICE_NVIDIA
void GPU_texture_update_sub_from_pixel_buffer(gpu::Texture *texture, eGPUDataFormat data_format, GPUPixelBuffer *pixel_buf, int offset_x, int offset_y, int offset_z, int width, int height, int depth)
gpu::Texture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
GPUPixelBufferNativeHandle GPU_pixel_buffer_get_native_handle(GPUPixelBuffer *pixel_buf)
#define make_float2
struct BlenderDisplayDriver::Tiles::@017347327365203105213232372177334306235256047361 finished_tiles
static constexpr GPUSamplerState default_sampler()
eRegionView3D_Flag rflag
float x
float y
Definition half.h:53
std::unique_lock< std::mutex > thread_scoped_lock
Definition thread.h:28