Blender V4.5
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
8
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
74void VKStateManager::image_bind(Texture *tex, int binding)
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 VkDeviceSize offset)
140{
141 storage_buffers_.bind(resource_type, resource, binding, offset);
142 is_dirty = true;
143}
144
146{
147 storage_buffers_.unbind(resource);
148 is_dirty = true;
149}
150
152{
153 storage_buffers_.unbind_all();
154 is_dirty = true;
155}
156
158{
159 texture_unpack_row_length_ = len;
160}
161
163{
164 return texture_unpack_row_length_;
165}
166
167} // namespace blender::gpu
unsigned int uint
eGPUBarrier
Definition GPU_state.hh:29
@ GPU_BARRIER_SHADER_IMAGE_ACCESS
Definition GPU_state.hh:35
static VKContext * get()
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
#define resource
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
static Context * unwrap(GPUContext *ctx)
static constexpr GPUSamplerState default_sampler()
uint len