Blender V4.3
vk_state_manager.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "vk_state_manager.hh"
10#include "vk_context.hh"
11#include "vk_index_buffer.hh"
12#include "vk_shader.hh"
13#include "vk_storage_buffer.hh"
14#include "vk_texture.hh"
15#include "vk_vertex_buffer.hh"
16
17#include "GPU_capabilities.hh"
18
19namespace blender::gpu {
20
22{
23 /* Intentionally empty. State is polled during pipeline creation and doesn't need to be applied.
24 * If this leads to issues we should have an active state. */
25}
26
28{
29 /* Intentionally empty. State is polled during pipeline creation and is always forced. */
30}
31
33{
50 if (bool(barrier_bits & GPU_BARRIER_SHADER_IMAGE_ACCESS)) {
51 VKContext &context = *VKContext::get();
52 context.rendering_end();
53 }
54}
55
57{
58 textures_.bind(BindSpaceTextures::Type::Texture, texture, sampler, binding);
59 is_dirty = true;
60}
61
63{
64 textures_.unbind(texture);
65 is_dirty = true;
66}
67
69{
70 textures_.unbind_all();
71 is_dirty = true;
72}
73
75{
76 VKTexture *texture = unwrap(tex);
77 images_.bind(texture, binding);
78 is_dirty = true;
79}
80
82{
83 VKTexture *texture = unwrap(tex);
84 images_.unbind(texture);
85 is_dirty = true;
86}
87
89{
90 images_.unbind_all();
91 is_dirty = true;
92}
93
94void VKStateManager::uniform_buffer_bind(VKUniformBuffer *uniform_buffer, int binding)
95{
96 uniform_buffers_.bind(uniform_buffer, binding);
97 is_dirty = true;
98}
99
101{
102 uniform_buffers_.unbind(uniform_buffer);
103 is_dirty = true;
104}
105
107{
108 uniform_buffers_.unbind_all();
109 is_dirty = true;
110}
111
113{
114 uniform_buffers_.unbind(resource);
115 storage_buffers_.unbind(resource);
116 images_.unbind(resource);
117 textures_.unbind(resource);
118 is_dirty = true;
119}
120
121void VKStateManager::texel_buffer_bind(VKVertexBuffer &vertex_buffer, int binding)
122{
124 &vertex_buffer,
126 binding);
127 is_dirty = true;
128}
129
131{
132 textures_.unbind(&vertex_buffer);
133 is_dirty = true;
134}
135
137 void *resource,
138 int binding)
139{
140 storage_buffers_.bind(resource_type, resource, binding);
141 is_dirty = true;
142}
143
145{
146 storage_buffers_.unbind(resource);
147 is_dirty = true;
148}
149
151{
152 storage_buffers_.unbind_all();
153 is_dirty = true;
154}
155
157{
158 texture_unpack_row_length_ = len;
159}
160
162{
163 return texture_unpack_row_length_;
164}
165
166} // namespace blender::gpu
unsigned int uint
eGPUBarrier
Definition GPU_state.hh:29
@ GPU_BARRIER_SHADER_IMAGE_ACCESS
Definition GPU_state.hh:35
void bind(VKTexture *resource, int binding)
void bind(Type resource_type, void *resource, int binding)
void bind(Type resource_type, void *resource, GPUSamplerState sampler, int binding)
void bind(VKUniformBuffer *resource, int binding)
static VKContext * get()
Definition vk_context.hh:97
void texel_buffer_bind(VKVertexBuffer &vertex_buffer, int slot)
void issue_barrier(eGPUBarrier barrier_bits) override
void image_bind(Texture *tex, int unit) override
void unbind_from_all_namespaces(void *resource)
void uniform_buffer_unbind(VKUniformBuffer *uniform_buffer)
void storage_buffer_unbind(void *resource)
void uniform_buffer_bind(VKUniformBuffer *uniform_buffer, int slot)
void texture_unbind(Texture *tex) override
void texel_buffer_unbind(VKVertexBuffer &vertex_buffer)
void texture_bind(Texture *tex, GPUSamplerState sampler, int unit) override
void image_unbind(Texture *tex) override
void storage_buffer_bind(BindSpaceStorageBuffers::Type resource_type, void *resource, int binding)
void texture_unpack_row_length_set(uint len) override
local_group_size(16, 16) .push_constant(Type local_group_size(16, 16) .push_constant(Type input_tx sampler(1, ImageType::FLOAT_2D, "matte_tx") .image(0
int len
static Context * unwrap(GPUContext *ctx)
static constexpr GPUSamplerState default_sampler()