ReactOS 0.4.17-dev-966-gf06eace
view.c File Reference
#include "wined3d_private.h"
#include "wined3d_gl.h"
#include "wined3d_vk.h"
Include dependency graph for view.c:

Go to the source code of this file.

Classes

struct  wined3d_uav_clear_constants_vk
 

Macros

#define WINED3D_VIEW_CUBE_ARRAY   (WINED3D_VIEW_TEXTURE_CUBE | WINED3D_VIEW_TEXTURE_ARRAY)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d)
 
static BOOL is_stencil_view_format (const struct wined3d_format *format)
 
static GLenum get_texture_view_target (const struct wined3d_gl_info *gl_info, const struct wined3d_view_desc *desc, const struct wined3d_texture_gl *texture_gl)
 
static const struct wined3d_format * validate_resource_view (const struct wined3d_view_desc *desc, struct wined3d_resource *resource, BOOL mip_slice, BOOL allow_srgb_toggle)
 
static void create_texture_view (struct wined3d_gl_view *view, GLenum view_target, const struct wined3d_view_desc *desc, struct wined3d_texture_gl *texture_gl, const struct wined3d_format *view_format)
 
static void create_buffer_texture (struct wined3d_gl_view *view, struct wined3d_context_gl *context_gl, struct wined3d_buffer *buffer, const struct wined3d_format_gl *view_format_gl, unsigned int offset, unsigned int size)
 
static void get_buffer_view_range (const struct wined3d_buffer *buffer, const struct wined3d_view_desc *desc, const struct wined3d_format *view_format, unsigned int *offset, unsigned int *size)
 
static void create_buffer_view (struct wined3d_gl_view *view, struct wined3d_context *context, const struct wined3d_view_desc *desc, struct wined3d_buffer *buffer, const struct wined3d_format *view_format)
 
static void wined3d_view_invalidate_location (struct wined3d_resource *resource, const struct wined3d_view_desc *desc, DWORD location)
 
static void wined3d_view_load_location (struct wined3d_resource *resource, const struct wined3d_view_desc *desc, struct wined3d_context *context, DWORD location)
 
ULONG CDECL wined3d_rendertarget_view_incref (struct wined3d_rendertarget_view *view)
 
void wined3d_rendertarget_view_cleanup (struct wined3d_rendertarget_view *view)
 
ULONG CDECL wined3d_rendertarget_view_decref (struct wined3d_rendertarget_view *view)
 
void *CDECL wined3d_rendertarget_view_get_parent (const struct wined3d_rendertarget_view *view)
 
void *CDECL wined3d_rendertarget_view_get_sub_resource_parent (const struct wined3d_rendertarget_view *view)
 
void CDECL wined3d_rendertarget_view_set_parent (struct wined3d_rendertarget_view *view, void *parent, const struct wined3d_parent_ops *parent_ops)
 
struct wined3d_resource *CDECL wined3d_rendertarget_view_get_resource (const struct wined3d_rendertarget_view *view)
 
void wined3d_rendertarget_view_get_drawable_size (const struct wined3d_rendertarget_view *view, const struct wined3d_context *context, unsigned int *width, unsigned int *height)
 
void wined3d_rendertarget_view_prepare_location (struct wined3d_rendertarget_view *view, struct wined3d_context *context, uint32_t location)
 
void wined3d_rendertarget_view_load_location (struct wined3d_rendertarget_view *view, struct wined3d_context *context, uint32_t location)
 
void wined3d_rendertarget_view_validate_location (struct wined3d_rendertarget_view *view, uint32_t location)
 
void wined3d_rendertarget_view_invalidate_location (struct wined3d_rendertarget_view *view, uint32_t location)
 
DWORD wined3d_rendertarget_view_get_locations (const struct wined3d_rendertarget_view *view)
 
void wined3d_rendertarget_view_get_box (struct wined3d_rendertarget_view *view, struct wined3d_box *box)
 
static void wined3d_render_target_view_gl_cs_init (void *object)
 
static HRESULT wined3d_rendertarget_view_init (struct wined3d_rendertarget_view *view, const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops)
 
HRESULT wined3d_rendertarget_view_no3d_init (struct wined3d_rendertarget_view *view_no3d, const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops)
 
HRESULT wined3d_rendertarget_view_gl_init (struct wined3d_rendertarget_view_gl *view_gl, const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops)
 
VkImageViewType vk_image_view_type_from_wined3d (enum wined3d_resource_type type, uint32_t flags)
 
static VkBufferView wined3d_view_vk_create_vk_buffer_view (struct wined3d_context_vk *context_vk, const struct wined3d_view_desc *desc, struct wined3d_buffer_vk *buffer_vk, const struct wined3d_format_vk *view_format_vk)
 
static VkImageView wined3d_view_vk_create_vk_image_view (struct wined3d_context_vk *context_vk, const struct wined3d_view_desc *desc, struct wined3d_texture_vk *texture_vk, const struct wined3d_format_vk *view_format_vk, struct color_fixup_desc fixup, bool rtv, VkImageUsageFlags usage)
 
static void wined3d_render_target_view_vk_cs_init (void *object)
 
HRESULT wined3d_rendertarget_view_vk_init (struct wined3d_rendertarget_view_vk *view_vk, const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops)
 
HRESULT CDECL wined3d_rendertarget_view_create (const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_rendertarget_view **view)
 
HRESULT CDECL wined3d_rendertarget_view_create_from_sub_resource (struct wined3d_texture *texture, unsigned int sub_resource_idx, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_rendertarget_view **view)
 
ULONG CDECL wined3d_shader_resource_view_incref (struct wined3d_shader_resource_view *view)
 
void wined3d_shader_resource_view_cleanup (struct wined3d_shader_resource_view *view)
 
void wined3d_shader_resource_view_destroy (struct wined3d_shader_resource_view *view)
 
ULONG CDECL wined3d_shader_resource_view_decref (struct wined3d_shader_resource_view *view)
 
void *CDECL wined3d_shader_resource_view_get_parent (const struct wined3d_shader_resource_view *view)
 
void wined3d_shader_resource_view_gl_update (struct wined3d_shader_resource_view_gl *srv_gl, struct wined3d_context_gl *context_gl)
 
static void wined3d_shader_resource_view_gl_cs_init (void *object)
 
static HRESULT wined3d_shader_resource_view_init (struct wined3d_shader_resource_view *view, const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops)
 
HRESULT wined3d_shader_resource_view_gl_init (struct wined3d_shader_resource_view_gl *view_gl, const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops)
 
void wined3d_shader_resource_view_vk_update_buffer (struct wined3d_shader_resource_view_vk *srv_vk, struct wined3d_context_vk *context_vk)
 
void wined3d_shader_resource_view_vk_update_layout (struct wined3d_shader_resource_view_vk *srv_vk, VkImageLayout layout)
 
static void wined3d_shader_resource_view_vk_cs_init (void *object)
 
HRESULT wined3d_shader_resource_view_vk_init (struct wined3d_shader_resource_view_vk *view_vk, const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops)
 
HRESULT CDECL wined3d_shader_resource_view_create (const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_shader_resource_view **view)
 
void wined3d_shader_resource_view_gl_bind (struct wined3d_shader_resource_view_gl *view_gl, unsigned int unit, struct wined3d_sampler_gl *sampler_gl, struct wined3d_context_gl *context_gl)
 
static void shader_resource_view_gl_bind_and_dirtify (struct wined3d_shader_resource_view_gl *view_gl, struct wined3d_context_gl *context_gl)
 
void wined3d_shader_resource_view_gl_generate_mipmap (struct wined3d_shader_resource_view_gl *view_gl, struct wined3d_context_gl *context_gl)
 
void wined3d_shader_resource_view_vk_generate_mipmap (struct wined3d_shader_resource_view_vk *srv_vk, struct wined3d_context_vk *context_vk)
 
ULONG CDECL wined3d_unordered_access_view_incref (struct wined3d_unordered_access_view *view)
 
void wined3d_unordered_access_view_cleanup (struct wined3d_unordered_access_view *view)
 
ULONG CDECL wined3d_unordered_access_view_decref (struct wined3d_unordered_access_view *view)
 
void *CDECL wined3d_unordered_access_view_get_parent (const struct wined3d_unordered_access_view *view)
 
void wined3d_unordered_access_view_invalidate_location (struct wined3d_unordered_access_view *view, uint32_t location)
 
void wined3d_unordered_access_view_gl_clear (struct wined3d_unordered_access_view_gl *view_gl, const struct wined3d_uvec4 *clear_value, struct wined3d_context_gl *context_gl, bool fp)
 
void wined3d_unordered_access_view_set_counter (struct wined3d_unordered_access_view *view, unsigned int value)
 
void wined3d_unordered_access_view_copy_counter (struct wined3d_unordered_access_view *view, struct wined3d_buffer *buffer, unsigned int offset, struct wined3d_context *context)
 
void wined3d_unordered_access_view_gl_update (struct wined3d_unordered_access_view_gl *uav_gl, struct wined3d_context_gl *context_gl)
 
static void wined3d_unordered_access_view_gl_cs_init (void *object)
 
static HRESULT wined3d_unordered_access_view_init (struct wined3d_unordered_access_view *view, const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops)
 
HRESULT wined3d_unordered_access_view_gl_init (struct wined3d_unordered_access_view_gl *view_gl, const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops)
 
static int compile_hlsl_cs (const struct vkd3d_shader_code *hlsl, struct vkd3d_shader_code *dxbc)
 
static VkPipeline create_uav_pipeline (struct wined3d_context_vk *context_vk, struct wined3d_pipeline_layout_vk *layout, const char *resource_filename, enum wined3d_shader_resource_type resource_type)
 
void wined3d_device_vk_uav_clear_state_init (struct wined3d_device_vk *device_vk)
 
void wined3d_device_vk_uav_clear_state_cleanup (struct wined3d_device_vk *device_vk)
 
void wined3d_unordered_access_view_vk_clear (struct wined3d_unordered_access_view_vk *view_vk, const struct wined3d_uvec4 *clear_value, struct wined3d_context_vk *context_vk, bool fp)
 
void wined3d_unordered_access_view_vk_update (struct wined3d_unordered_access_view_vk *uav_vk, struct wined3d_context_vk *context_vk)
 
static void wined3d_unordered_access_view_vk_cs_init (void *object)
 
HRESULT wined3d_unordered_access_view_vk_init (struct wined3d_unordered_access_view_vk *view_vk, const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops)
 
HRESULT CDECL wined3d_unordered_access_view_create (const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_unordered_access_view **view)
 

Macro Definition Documentation

◆ WINED3D_VIEW_CUBE_ARRAY

#define WINED3D_VIEW_CUBE_ARRAY   (WINED3D_VIEW_TEXTURE_CUBE | WINED3D_VIEW_TEXTURE_ARRAY)

Definition at line 26 of file view.c.

Function Documentation

◆ compile_hlsl_cs()

static int compile_hlsl_cs ( const struct vkd3d_shader_code *  hlsl,
struct vkd3d_shader_code *  dxbc 
)
static

Definition at line 1851 of file view.c.

1852{
1853 struct vkd3d_shader_hlsl_source_info hlsl_info;
1855
1856 static const struct vkd3d_shader_compile_option options[] =
1857 {
1859 };
1860
1862 info.next = &hlsl_info;
1863 info.source = *hlsl;
1864 info.source_type = VKD3D_SHADER_SOURCE_HLSL;
1865 info.target_type = VKD3D_SHADER_TARGET_DXBC_TPF;
1866 info.options = options;
1867 info.option_count = ARRAY_SIZE(options);
1868 info.log_level = VKD3D_SHADER_LOG_NONE;
1869 info.source_name = NULL;
1870
1872 hlsl_info.next = NULL;
1873 hlsl_info.entry_point = "main";
1874 hlsl_info.secondary_code.code = NULL;
1875 hlsl_info.secondary_code.size = 0;
1876 hlsl_info.profile = "cs_5_0";
1877
1878 return vkd3d_shader_compile(&info, dxbc, NULL);
1879}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define NULL
Definition: types.h:112
@ VKD3D_SHADER_COMPILE_OPTION_API_VERSION
Definition: vkd3d_shader.h:279
@ VKD3D_SHADER_SOURCE_HLSL
@ VKD3D_SHADER_LOG_NONE
@ VKD3D_SHADER_STRUCTURE_TYPE_COMPILE_INFO
Definition: vkd3d_shader.h:68
@ VKD3D_SHADER_STRUCTURE_TYPE_HLSL_SOURCE_INFO
Definition: vkd3d_shader.h:84
@ VKD3D_SHADER_API_VERSION_1_12
Definition: vkd3d_shader.h:57
VKD3D_SHADER_API int vkd3d_shader_compile(const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_code *out, char **messages)
@ VKD3D_SHADER_TARGET_DXBC_TPF

Referenced by create_uav_pipeline().

◆ create_buffer_texture()

static void create_buffer_texture ( struct wined3d_gl_view *  view,
struct wined3d_context_gl *  context_gl,
struct wined3d_buffer *  buffer,
const struct wined3d_format_gl *  view_format_gl,
unsigned int  offset,
unsigned int  size 
)
static

Definition at line 244 of file view.c.

247{
248 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
249 const struct wined3d_bo_gl *bo_gl;
250
252 {
253 FIXME("OpenGL implementation does not support buffer textures.\n");
254 return;
255 }
256
258 bo_gl = wined3d_bo_gl(buffer->buffer_object);
259 offset += bo_gl->b.buffer_offset;
260
261 if ((offset & (gl_info->limits.texture_buffer_offset_alignment - 1)))
262 {
263 FIXME("Buffer offset %u is not %u byte aligned.\n",
264 offset, gl_info->limits.texture_buffer_offset_alignment);
265 return;
266 }
267
268 view->target = GL_TEXTURE_BUFFER;
269 if (!view->name)
270 {
271 gl_info->gl_ops.gl.p_glGenTextures(1, &view->name);
272 }
273
276 {
277 GL_EXTCALL(glTexBufferRange(GL_TEXTURE_BUFFER, view_format_gl->internal, bo_gl->id, offset, size));
278 }
279 else
280 {
281 if (offset || size != buffer->resource.size)
282 FIXME("OpenGL implementation does not support ARB_texture_buffer_range.\n");
283 GL_EXTCALL(glTexBuffer(GL_TEXTURE_BUFFER, view_format_gl->internal, bo_gl->id));
284 }
285 checkGLcall("Create buffer texture");
286
289}
#define FIXME(fmt,...)
Definition: precomp.h:53
void wined3d_context_gl_bind_texture(struct wined3d_context_gl *context_gl, GLenum target, GLuint name)
Definition: context_gl.c:2507
BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer, struct wined3d_context *context, uint32_t location)
Definition: buffer.c:269
void context_invalidate_compute_state(struct wined3d_context *context, DWORD state_id)
Definition: context.c:66
void context_invalidate_state(struct wined3d_context *context, unsigned int state_id)
Definition: context.c:76
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
#define GL_TEXTURE_BUFFER
Definition: glext.h:748
struct wined3d_bo b
Definition: wined3d_gl.h:415
struct wined3d_context c
Definition: wined3d_gl.h:601
const struct wined3d_gl_info * gl_info
Definition: wined3d_gl.h:603
BOOL supported[WINED3D_GL_EXT_COUNT]
Definition: wined3d_gl.h:347
struct opengl_funcs gl_ops
Definition: wined3d_gl.h:353
struct wined3d_gl_limits limits
Definition: wined3d_gl.h:344
@ ARB_TEXTURE_BUFFER_OBJECT
Definition: wined3d_gl.h:125
@ ARB_TEXTURE_BUFFER_RANGE
Definition: wined3d_gl.h:126
#define GL_EXTCALL(f)
Definition: wined3d_gl.h:360
#define checkGLcall(A)
Definition: wined3d_gl.h:402
#define STATE_GRAPHICS_SHADER_RESOURCE_BINDING
#define WINED3D_LOCATION_BUFFER
#define STATE_COMPUTE_SHADER_RESOURCE_BINDING

Referenced by create_buffer_view().

◆ create_buffer_view()

static void create_buffer_view ( struct wined3d_gl_view *  view,
struct wined3d_context *  context,
const struct wined3d_view_desc *  desc,
struct wined3d_buffer *  buffer,
const struct wined3d_format *  view_format 
)
static

Definition at line 307 of file view.c.

310{
311 unsigned int offset, size;
312
313 get_buffer_view_range(buffer, desc, view_format, &offset, &size);
315}
static void get_buffer_view_range(const struct wined3d_buffer *buffer, const struct wined3d_view_desc *desc, const struct wined3d_format *view_format, unsigned int *offset, unsigned int *size)
Definition: view.c:291
static void create_buffer_texture(struct wined3d_gl_view *view, struct wined3d_context_gl *context_gl, struct wined3d_buffer *buffer, const struct wined3d_format_gl *view_format_gl, unsigned int offset, unsigned int size)
Definition: view.c:244
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
Definition: http.c:7252

Referenced by wined3d_shader_resource_view_gl_cs_init(), wined3d_shader_resource_view_gl_update(), wined3d_unordered_access_view_gl_cs_init(), and wined3d_unordered_access_view_gl_update().

◆ create_texture_view()

static void create_texture_view ( struct wined3d_gl_view *  view,
GLenum  view_target,
const struct wined3d_view_desc *  desc,
struct wined3d_texture_gl *  texture_gl,
const struct wined3d_format *  view_format 
)
static

Definition at line 165 of file view.c.

168{
169 const struct wined3d_format_gl *view_format_gl;
170 unsigned int level_idx, layer_idx, layer_count;
171 const struct wined3d_gl_info *gl_info;
172 struct wined3d_context_gl *context_gl;
173 struct wined3d_context *context;
174 GLuint texture_name;
175
176 view_format_gl = wined3d_format_gl(view_format);
177 view->target = view_target;
178
179 context = context_acquire(texture_gl->t.resource.device, NULL, 0);
180 context_gl = wined3d_context_gl(context);
181 gl_info = context_gl->gl_info;
182
183 if (!gl_info->supported[ARB_TEXTURE_VIEW])
184 {
186 FIXME("OpenGL implementation does not support texture views.\n");
187 return;
188 }
189
190 wined3d_texture_gl_prepare_texture(texture_gl, context_gl, FALSE);
191 texture_name = wined3d_texture_gl_get_texture_name(texture_gl, context, FALSE);
192
193 level_idx = desc->u.texture.level_idx;
194 layer_idx = desc->u.texture.layer_idx;
195 layer_count = desc->u.texture.layer_count;
196 if (view_target == GL_TEXTURE_3D)
197 {
198 if (layer_idx || layer_count != wined3d_texture_get_level_depth(&texture_gl->t, level_idx))
199 FIXME("Depth slice (%u-%u) not supported.\n", layer_idx, layer_count);
200 layer_idx = 0;
201 layer_count = 1;
202 }
203
204 gl_info->gl_ops.gl.p_glGenTextures(1, &view->name);
205 GL_EXTCALL(glTextureView(view->name, view->target, texture_name, view_format_gl->internal,
206 level_idx, desc->u.texture.level_count, layer_idx, layer_count));
207 checkGLcall("create texture view");
208
209 if (is_stencil_view_format(view_format))
210 {
211 static const GLint swizzle[] = {GL_ZERO, GL_RED, GL_ZERO, GL_ZERO};
212
213 if (!gl_info->supported[ARB_STENCIL_TEXTURING])
214 {
216 FIXME("OpenGL implementation does not support stencil texturing.\n");
217 return;
218 }
219
220 wined3d_context_gl_bind_texture(context_gl, view->target, view->name);
221 gl_info->gl_ops.gl.p_glTexParameteriv(view->target, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
222 gl_info->gl_ops.gl.p_glTexParameteri(view->target, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX);
223 checkGLcall("initialize stencil view");
224
227 }
228 else if (!is_identity_fixup(view_format->color_fixup) && can_use_texture_swizzle(context->d3d_info, view_format))
229 {
230 GLint swizzle[4];
231
232 wined3d_context_gl_bind_texture(context_gl, view->target, view->name);
234 gl_info->gl_ops.gl.p_glTexParameteriv(view->target, GL_TEXTURE_SWIZZLE_RGBA, swizzle);
235 checkGLcall("set format swizzle");
236
239 }
240
242}
#define FALSE
Definition: types.h:117
void wined3d_gl_texture_swizzle_from_color_fixup(GLint swizzle[4], struct color_fixup_desc fixup)
Definition: texture.c:1269
void wined3d_texture_gl_prepare_texture(struct wined3d_texture_gl *texture_gl, struct wined3d_context_gl *context_gl, BOOL srgb)
Definition: texture.c:2029
static BOOL is_stencil_view_format(const struct wined3d_format *format)
Definition: view.c:28
unsigned int GLuint
Definition: gl.h:159
#define GL_TEXTURE_3D
Definition: gl.h:1515
#define GL_ZERO
Definition: gl.h:374
#define GL_RED
Definition: gl.h:480
int GLint
Definition: gl.h:156
#define GL_STENCIL_INDEX
Definition: gl.h:458
GLuint GLenum swizzle
Definition: glext.h:9511
#define GL_TEXTURE_SWIZZLE_RGBA
Definition: glext.h:2032
struct color_fixup_desc color_fixup
struct wined3d_texture t
Definition: wined3d_gl.h:941
#define GL_DEPTH_STENCIL_TEXTURE_MODE
Definition: wgl.h:1008
@ ARB_TEXTURE_VIEW
Definition: wined3d_gl.h:147
@ ARB_STENCIL_TEXTURING
Definition: wined3d_gl.h:121
static GLuint wined3d_texture_gl_get_texture_name(const struct wined3d_texture_gl *texture_gl, const struct wined3d_context *context, bool srgb)
Definition: wined3d_gl.h:982
static void context_release(struct wined3d_context *context)
static BOOL can_use_texture_swizzle(const struct wined3d_d3d_info *d3d_info, const struct wined3d_format *format)
static BOOL is_identity_fixup(struct color_fixup_desc fixup)
static struct wined3d_context * context_acquire(struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)
static unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture *texture, unsigned int level)

Referenced by wined3d_render_target_view_gl_cs_init(), wined3d_shader_resource_view_gl_cs_init(), and wined3d_unordered_access_view_gl_cs_init().

◆ create_uav_pipeline()

static VkPipeline create_uav_pipeline ( struct wined3d_context_vk *  context_vk,
struct wined3d_pipeline_layout_vk *  layout,
const char *  resource_filename,
enum wined3d_shader_resource_type  resource_type 
)
static

Definition at line 1888 of file view.c.

1891{
1892 VkComputePipelineCreateInfo pipeline_info;
1893 struct wined3d_shader_desc shader_desc;
1894 const struct wined3d_vk_info *vk_info;
1895 struct vkd3d_shader_code code, dxbc;
1896 struct wined3d_context *context;
1897 VkShaderModule shader_module;
1898 VkDevice vk_device;
1899 void *resource_ptr;
1900 VkPipeline result;
1903 HRSRC resource;
1904 VkResult vr;
1905 int ret;
1906
1907 vk_info = context_vk->vk_info;
1908 context = &context_vk->c;
1909
1910 if (!GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
1911 (const char *)create_uav_pipeline, &module))
1912 {
1913 ERR("Failed to get a reference to the current module, last error %ld.\n", GetLastError());
1914 return VK_NULL_HANDLE;
1915 }
1916
1917 if (!(resource = FindResourceA(module, resource_filename, (const char *)RT_RCDATA)))
1918 {
1919 ERR("Failed to retrieve resource, last error %ld.\n", GetLastError());
1920 return VK_NULL_HANDLE;
1921 }
1922
1924 {
1925 ERR("Failed to load resource, last error %ld.\n", GetLastError());
1926 return VK_NULL_HANDLE;
1927 }
1928
1929 if (!(resource_ptr = LockResource(global)))
1930 {
1931 ERR("Failed to lock resource.\n");
1933 return VK_NULL_HANDLE;
1934 }
1935
1936 code.code = resource_ptr;
1938
1939 if ((ret = compile_hlsl_cs(&code, &dxbc)) < 0)
1940 {
1941 ERR("Failed to compile shader, ret %d.\n", ret);
1943 return VK_NULL_HANDLE;
1944 }
1945
1947 ERR("Failed to free resource.\n");
1948
1949 shader_desc.byte_code = dxbc.code;
1950 shader_desc.byte_code_size = dxbc.size;
1951
1952 shader_module = (VkShaderModule)context->device->adapter->shader_backend->shader_compile(context, &shader_desc,
1954 if (shader_module == VK_NULL_HANDLE)
1955 {
1956 ERR("Failed to create shader.\n");
1958 return VK_NULL_HANDLE;
1959 }
1960
1962
1964 pipeline_info.pNext = NULL;
1965 pipeline_info.flags = 0;
1967 pipeline_info.stage.pNext = NULL;
1968 pipeline_info.stage.flags = 0;
1969 pipeline_info.stage.stage = VK_SHADER_STAGE_COMPUTE_BIT;
1970 pipeline_info.stage.pName = "main";
1971 pipeline_info.stage.pSpecializationInfo = NULL;
1972 pipeline_info.stage.module = shader_module;
1973 pipeline_info.layout = layout->vk_pipeline_layout;
1974 pipeline_info.basePipelineHandle = VK_NULL_HANDLE;
1975 pipeline_info.basePipelineIndex = -1;
1976
1977 vk_device = wined3d_device_vk(context->device)->vk_device;
1978
1979 if ((vr = VK_CALL(vkCreateComputePipelines(vk_device, VK_NULL_HANDLE, 1, &pipeline_info, NULL, &result))) < 0)
1980 {
1981 ERR("Failed to create Vulkan compute pipeline, vr %s.\n", wined3d_debug_vkresult(vr));
1982 return VK_NULL_HANDLE;
1983 }
1984
1985 VK_CALL(vkDestroyShaderModule(vk_device, shader_module, NULL));
1986 return result;
1987}
#define ERR(fmt,...)
Definition: precomp.h:57
const char * wined3d_debug_vkresult(VkResult vr)
Definition: utils.c:5463
static VkPipeline create_uav_pipeline(struct wined3d_context_vk *context_vk, struct wined3d_pipeline_layout_vk *layout, const char *resource_filename, enum wined3d_shader_resource_type resource_type)
Definition: view.c:1888
static int compile_hlsl_cs(const struct vkd3d_shader_code *hlsl, struct vkd3d_shader_code *dxbc)
Definition: view.c:1851
BOOL WINAPI GetModuleHandleExA(IN DWORD dwFlags, IN LPCSTR lpModuleName OPTIONAL, OUT HMODULE *phModule)
Definition: loader.c:896
BOOL WINAPI FreeResource(HGLOBAL handle)
Definition: res.c:559
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
return ret
Definition: mutex.c:147
int global
Definition: ehframes.cpp:22
GLuint64EXT * result
Definition: glext.h:11304
#define resource
Definition: kernel32.h:9
#define RT_RCDATA
Definition: pedump.c:372
VkStructureType sType
Definition: vulkan.h:17583
VkPipelineCreateFlags flags
Definition: vulkan.h:17585
Definition: inflate.c:139
const struct wined3d_vk_info * vk_info
Definition: wined3d_vk.h:590
struct wined3d_context c
Definition: wined3d_vk.h:588
VkDevice vk_device
Definition: wined3d_vk.h:825
VkPipelineLayout vk_pipeline_layout
Definition: wined3d_vk.h:521
VKD3D_SHADER_API void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code)
@ VK_SHADER_STAGE_COMPUTE_BIT
Definition: vulkan.h:4880
VkResult VKAPI_CALL vkCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkComputePipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines)
void VKAPI_CALL vkDestroyShaderModule(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks *pAllocator)
VkResult
Definition: vulkan.h:4639
#define VK_NULL_HANDLE
Definition: vulkan.h:861
@ VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO
Definition: vulkan.h:4993
@ VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO
Definition: vulkan.h:4982
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
@ WINED3D_SHADER_TYPE_COMPUTE
Definition: wined3d.h:848
#define VK_CALL(f)
Definition: wined3d_vk.h:272

Referenced by create_uav_pipeline(), and wined3d_device_vk_uav_clear_state_init().

◆ get_buffer_view_range()

static void get_buffer_view_range ( const struct wined3d_buffer *  buffer,
const struct wined3d_view_desc *  desc,
const struct wined3d_format *  view_format,
unsigned int *  offset,
unsigned int *  size 
)
static

Definition at line 291 of file view.c.

294{
295 if (desc->format_id == WINED3DFMT_UNKNOWN)
296 {
297 *offset = desc->u.buffer.start_idx * buffer->structure_byte_stride;
298 *size = desc->u.buffer.count * buffer->structure_byte_stride;
299 }
300 else
301 {
302 *offset = desc->u.buffer.start_idx * view_format->byte_count;
303 *size = desc->u.buffer.count * view_format->byte_count;
304 }
305}
@ WINED3DFMT_UNKNOWN
Definition: wined3d.h:127

Referenced by create_buffer_view(), wined3d_unordered_access_view_gl_clear(), wined3d_unordered_access_view_vk_clear(), and wined3d_view_vk_create_vk_buffer_view().

◆ get_texture_view_target()

static GLenum get_texture_view_target ( const struct wined3d_gl_info *  gl_info,
const struct wined3d_view_desc *  desc,
const struct wined3d_texture_gl *  texture_gl 
)
static

Definition at line 34 of file view.c.

36{
37 static const struct
38 {
39 GLenum texture_target;
40 unsigned int view_flags;
41 GLenum view_target;
42 enum wined3d_gl_extension extension;
43 }
44 view_types[] =
45 {
48
55
60
65 };
68 unsigned int i;
69
70 for (i = 0; i < ARRAY_SIZE(view_types); ++i)
71 {
72 if (view_types[i].texture_target != texture_gl->target || view_types[i].view_flags != flags)
73 continue;
74 if (gl_info->supported[view_types[i].extension])
75 return view_types[i].view_target;
76
77 FIXME("Extension %#x not supported.\n", view_types[i].extension);
78 }
79
80 FIXME("Unhandled view flags %#x for texture target %#x.\n", flags, texture_gl->target);
81 return texture_gl->target;
82}
#define WINED3D_VIEW_CUBE_ARRAY
Definition: view.c:26
#define GL_TEXTURE_CUBE_MAP
Definition: gl.h:1788
unsigned int GLenum
Definition: gl.h:150
#define GL_TEXTURE_2D
Definition: gl.h:645
#define GL_TEXTURE_1D
Definition: gl.h:644
#define GL_TEXTURE_1D_ARRAY
Definition: glext.h:533
GLbitfield flags
Definition: glext.h:7161
#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY
Definition: glext.h:1941
#define GL_TEXTURE_2D_MULTISAMPLE
Definition: glext.h:1939
#define GL_TEXTURE_CUBE_MAP_ARRAY
Definition: glext.h:920
#define GL_TEXTURE_2D_ARRAY
Definition: glext.h:535
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define WINED3D_VIEW_TEXTURE_CUBE
Definition: wined3d.h:1582
#define WINED3D_VIEW_TEXTURE_ARRAY
Definition: wined3d.h:1583
#define WINED3D_VIEW_BUFFER_RAW
Definition: wined3d.h:1579
#define WINED3D_VIEW_BUFFER_APPEND
Definition: wined3d.h:1580
#define WINED3D_VIEW_BUFFER_COUNTER
Definition: wined3d.h:1581
wined3d_gl_extension
Definition: wined3d_gl.h:42
@ ARB_TEXTURE_CUBE_MAP_ARRAY
Definition: wined3d_gl.h:131

Referenced by wined3d_shader_resource_view_gl_cs_init(), and wined3d_unordered_access_view_gl_cs_init().

◆ is_stencil_view_format()

static BOOL is_stencil_view_format ( const struct wined3d_format *  format)
static

◆ shader_resource_view_gl_bind_and_dirtify()

static void shader_resource_view_gl_bind_and_dirtify ( struct wined3d_shader_resource_view_gl *  view_gl,
struct wined3d_context_gl *  context_gl 
)
static

Definition at line 1301 of file view.c.

1303{
1304 /* FIXME: Ideally we'd only do this when touching a binding that's used by
1305 * a shader. */
1308
1309 wined3d_context_gl_bind_texture(context_gl, view_gl->gl_view.target, view_gl->gl_view.name);
1310}
struct wined3d_gl_view gl_view
Definition: wined3d_gl.h:1083

Referenced by wined3d_shader_resource_view_gl_generate_mipmap().

◆ validate_resource_view()

static const struct wined3d_format * validate_resource_view ( const struct wined3d_view_desc *  desc,
struct wined3d_resource *  resource,
BOOL  mip_slice,
BOOL  allow_srgb_toggle 
)
static

Definition at line 84 of file view.c.

86{
87 const struct wined3d_adapter *adapter = resource->device->adapter;
88 const struct wined3d_format *format;
89
90 format = wined3d_get_format(adapter, desc->format_id, resource->bind_flags);
92 {
94 {
95 WARN("Invalid format %s for raw buffer view.\n", debug_d3dformat(format->id));
96 return NULL;
97 }
98
100 }
101
103 {
104 WARN("Trying to create view for typeless format %s.\n", debug_d3dformat(format->id));
105 return NULL;
106 }
107
108 if (resource->type == WINED3D_RTYPE_BUFFER)
109 {
111 unsigned int buffer_size, element_size;
112
113 if (buffer->structure_byte_stride)
114 {
115 if (desc->format_id != WINED3DFMT_UNKNOWN)
116 {
117 WARN("Invalid format %s for structured buffer view.\n", debug_d3dformat(desc->format_id));
118 return NULL;
119 }
120
122 element_size = buffer->structure_byte_stride;
123 }
124 else
125 {
126 element_size = format->byte_count;
127 }
128
129 if (!element_size)
130 return NULL;
131
132 buffer_size = buffer->resource.size / element_size;
133 if (!wined3d_bound_range(desc->u.buffer.start_idx, desc->u.buffer.count, buffer_size))
134 return NULL;
135 }
136 else
137 {
139 unsigned int depth_or_layer_count;
140
141 if (resource->format->id != format->id && !wined3d_format_is_typeless(resource->format)
142 && (!allow_srgb_toggle || !wined3d_formats_are_srgb_variants(resource->format->id, format->id)))
143 {
144 WARN("Trying to create incompatible view for non typeless format %s.\n",
146 return NULL;
147 }
148
149 if (mip_slice && resource->type == WINED3D_RTYPE_TEXTURE_3D)
150 depth_or_layer_count = wined3d_texture_get_level_depth(texture, desc->u.texture.level_idx);
151 else
152 depth_or_layer_count = texture->layer_count;
153
154 if (!desc->u.texture.level_count
155 || (mip_slice && desc->u.texture.level_count != 1)
156 || !wined3d_bound_range(desc->u.texture.level_idx, desc->u.texture.level_count, texture->level_count)
157 || !desc->u.texture.layer_count
158 || !wined3d_bound_range(desc->u.texture.layer_idx, desc->u.texture.layer_count, depth_or_layer_count))
159 return NULL;
160 }
161
162 return format;
163}
#define WARN(fmt,...)
Definition: precomp.h:61
size_t const element_size
Definition: debug_heap.cpp:510
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:4605
const struct wined3d_format * wined3d_get_format(const struct wined3d_adapter *adapter, enum wined3d_format_id format_id, unsigned int bind_flags)
Definition: utils.c:4428
BOOL wined3d_formats_are_srgb_variants(enum wined3d_format_id format1, enum wined3d_format_id format2)
Definition: utils.c:4535
return adapter
GLenum GLuint texture
Definition: glext.h:6295
wchar_t const *const size_t const buffer_size
Definition: stat.cpp:95
@ WINED3D_RTYPE_BUFFER
Definition: wined3d.h:718
@ WINED3D_RTYPE_TEXTURE_3D
Definition: wined3d.h:721
@ WINED3DFMT_R32_UINT
Definition: wined3d.h:199
@ WINED3DFMT_R32_TYPELESS
Definition: wined3d.h:196
static bool wined3d_bound_range(unsigned int start, unsigned int count, unsigned int limit)
Definition: wined3d.h:2995
static BOOL wined3d_format_is_typeless(const struct wined3d_format *format)
static struct wined3d_texture * texture_from_resource(struct wined3d_resource *resource)
static struct wined3d_buffer * buffer_from_resource(struct wined3d_resource *resource)

Referenced by wined3d_rendertarget_view_init(), wined3d_shader_resource_view_init(), and wined3d_unordered_access_view_init().

◆ vk_image_view_type_from_wined3d()

VkImageViewType vk_image_view_type_from_wined3d ( enum wined3d_resource_type  type,
uint32_t  flags 
)

Definition at line 676 of file view.c.

677{
678 switch (type)
679 {
683 else
685
688 {
691 else
693 }
696 else
698
701
702 default:
703 ERR("Unhandled resource type %s.\n", debug_d3dresourcetype(type));
704 return ~0u;
705 }
706}
const char * debug_d3dresourcetype(enum wined3d_resource_type resource_type)
Definition: utils.c:4992
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
@ VK_IMAGE_VIEW_TYPE_1D
Definition: vulkan.h:3548
@ VK_IMAGE_VIEW_TYPE_2D_ARRAY
Definition: vulkan.h:3553
@ VK_IMAGE_VIEW_TYPE_1D_ARRAY
Definition: vulkan.h:3552
@ VK_IMAGE_VIEW_TYPE_CUBE_ARRAY
Definition: vulkan.h:3554
@ VK_IMAGE_VIEW_TYPE_3D
Definition: vulkan.h:3550
@ VK_IMAGE_VIEW_TYPE_2D
Definition: vulkan.h:3549
@ VK_IMAGE_VIEW_TYPE_CUBE
Definition: vulkan.h:3551
@ WINED3D_RTYPE_TEXTURE_2D
Definition: wined3d.h:720
@ WINED3D_RTYPE_TEXTURE_1D
Definition: wined3d.h:719

Referenced by wined3d_texture_vk_get_default_image_info(), and wined3d_view_vk_create_vk_image_view().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3d  )

◆ wined3d_device_vk_uav_clear_state_cleanup()

void wined3d_device_vk_uav_clear_state_cleanup ( struct wined3d_device_vk *  device_vk)

Definition at line 2057 of file view.c.

2058{
2059 struct wined3d_uav_clear_state_vk *state = &device_vk->uav_clear_state;
2060 const struct wined3d_vk_info *vk_info = &device_vk->vk_info;
2061
2062 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->float_pipelines.buffer, NULL));
2063 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->float_pipelines.image_1d, NULL));
2064 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->float_pipelines.image_1d_array, NULL));
2065 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->float_pipelines.image_2d, NULL));
2066 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->float_pipelines.image_2d_array, NULL));
2067 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->float_pipelines.image_3d, NULL));
2068
2069 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->uint_pipelines.buffer, NULL));
2070 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->uint_pipelines.image_1d, NULL));
2071 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->uint_pipelines.image_1d_array, NULL));
2072 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->uint_pipelines.image_2d, NULL));
2073 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->uint_pipelines.image_2d_array, NULL));
2074 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->uint_pipelines.image_3d, NULL));
2075}
static int state
Definition: maze.c:121
struct wined3d_vk_info vk_info
Definition: wined3d_vk.h:830
struct wined3d_uav_clear_state_vk uav_clear_state
Definition: wined3d_vk.h:838
void VKAPI_CALL vkDestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks *pAllocator)

Referenced by adapter_vk_uninit_3d_cs().

◆ wined3d_device_vk_uav_clear_state_init()

void wined3d_device_vk_uav_clear_state_init ( struct wined3d_device_vk *  device_vk)

Definition at line 1989 of file view.c.

1990{
1991 struct wined3d_uav_clear_state_vk *state = &device_vk->uav_clear_state;
1992 struct wined3d_context_vk *context_vk = &device_vk->context_vk;
1993 VkDescriptorSetLayoutBinding vk_set_bindings[2];
1994
1995 vk_set_bindings[0].binding = 0;
1996 vk_set_bindings[0].descriptorCount = 1;
1997 vk_set_bindings[0].stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
1998 vk_set_bindings[0].pImmutableSamplers = NULL;
2000
2001 vk_set_bindings[1].binding = 1;
2002 vk_set_bindings[1].descriptorCount = 1;
2003 vk_set_bindings[1].stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
2004 vk_set_bindings[1].pImmutableSamplers = NULL;
2005
2007 state->image_layout = wined3d_context_vk_get_pipeline_layout(context_vk, vk_set_bindings, 2);
2008
2010 state->buffer_layout = wined3d_context_vk_get_pipeline_layout(context_vk, vk_set_bindings, 2);
2011
2012 state->float_pipelines.buffer = create_uav_pipeline(context_vk, state->buffer_layout,
2013 "cs_uav_clear_buffer_float_code.hlsl", WINED3D_SHADER_RESOURCE_BUFFER);
2014 state->uint_pipelines.buffer = create_uav_pipeline(context_vk, state->buffer_layout,
2015 "cs_uav_clear_buffer_uint_code.hlsl", WINED3D_SHADER_RESOURCE_BUFFER);
2016 state->float_pipelines.image_1d = create_uav_pipeline(context_vk, state->image_layout,
2017 "cs_uav_clear_1d_float_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_1D);
2018 state->uint_pipelines.image_1d = create_uav_pipeline(context_vk, state->image_layout,
2019 "cs_uav_clear_1d_uint_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_1D);
2020 state->float_pipelines.image_1d_array = create_uav_pipeline(context_vk, state->image_layout,
2021 "cs_uav_clear_1d_array_float_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY);
2022 state->uint_pipelines.image_1d_array = create_uav_pipeline(context_vk, state->image_layout,
2023 "cs_uav_clear_1d_array_uint_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY);
2024 state->float_pipelines.image_2d = create_uav_pipeline(context_vk, state->image_layout,
2025 "cs_uav_clear_2d_float_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_2D);
2026 state->uint_pipelines.image_2d = create_uav_pipeline(context_vk, state->image_layout,
2027 "cs_uav_clear_2d_uint_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_2D);
2028 state->float_pipelines.image_2d_array = create_uav_pipeline(context_vk, state->image_layout,
2029 "cs_uav_clear_2d_array_float_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY);
2030 state->uint_pipelines.image_2d_array = create_uav_pipeline(context_vk, state->image_layout,
2031 "cs_uav_clear_2d_array_uint_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY);
2032 state->float_pipelines.image_3d = create_uav_pipeline(context_vk, state->image_layout,
2033 "cs_uav_clear_3d_float_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_3D);
2034 state->uint_pipelines.image_3d = create_uav_pipeline(context_vk, state->image_layout,
2035 "cs_uav_clear_3d_uint_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_3D);
2036
2037 state->buffer_group_size.x = 128;
2038 state->buffer_group_size.y = 1;
2039 state->buffer_group_size.z = 1;
2040 state->image_1d_group_size.x = 64;
2041 state->image_1d_group_size.y = 1;
2042 state->image_1d_group_size.z = 1;
2043 state->image_1d_array_group_size.x = 64;
2044 state->image_1d_array_group_size.y = 1;
2045 state->image_1d_array_group_size.z = 1;
2046 state->image_2d_group_size.x = 8;
2047 state->image_2d_group_size.y = 8;
2048 state->image_2d_group_size.z = 1;
2049 state->image_2d_array_group_size.x = 8;
2050 state->image_2d_array_group_size.y = 8;
2051 state->image_2d_array_group_size.z = 1;
2052 state->image_3d_group_size.x = 8;
2053 state->image_3d_group_size.y = 8;
2054 state->image_3d_group_size.z = 1;
2055}
struct wined3d_pipeline_layout_vk * wined3d_context_vk_get_pipeline_layout(struct wined3d_context_vk *context_vk, VkDescriptorSetLayoutBinding *bindings, SIZE_T binding_count)
Definition: context_vk.c:3442
VkDescriptorType descriptorType
Definition: vulkan.h:8303
const VkSampler * pImmutableSamplers
Definition: vulkan.h:8306
VkShaderStageFlags stageFlags
Definition: vulkan.h:8305
struct wined3d_context_vk context_vk
Definition: wined3d_vk.h:823
@ VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
Definition: vulkan.h:2469
@ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
Definition: vulkan.h:2470
@ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE
Definition: vulkan.h:2467
@ WINED3D_SHADER_RESOURCE_BUFFER
@ WINED3D_SHADER_RESOURCE_TEXTURE_3D
@ WINED3D_SHADER_RESOURCE_TEXTURE_2D
@ WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY
@ WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY
@ WINED3D_SHADER_RESOURCE_TEXTURE_1D

Referenced by adapter_vk_init_3d().

◆ wined3d_render_target_view_gl_cs_init()

static void wined3d_render_target_view_gl_cs_init ( void *  object)
static

Definition at line 556 of file view.c.

557{
558 struct wined3d_rendertarget_view_gl *view_gl = object;
559 struct wined3d_resource *resource = view_gl->v.resource;
560 const struct wined3d_view_desc *desc = &view_gl->v.desc;
561
562 TRACE("view_gl %p.\n", view_gl);
563
564 if (resource->type == WINED3D_RTYPE_BUFFER)
565 {
566 FIXME("Not implemented for resources %s.\n", debug_d3dresourcetype(resource->type));
567 }
568 else
569 {
571 unsigned int depth_or_layer_count;
572
574 depth_or_layer_count = wined3d_texture_get_level_depth(&texture_gl->t, desc->u.texture.level_idx);
575 else
576 depth_or_layer_count = texture_gl->t.layer_count;
577
578 if (resource->format->id != view_gl->v.format->id
579 || (view_gl->v.layer_count != 1 && view_gl->v.layer_count != depth_or_layer_count))
580 {
581 GLenum resource_class, view_class;
582
583 resource_class = wined3d_format_gl(resource->format)->view_class;
584 view_class = wined3d_format_gl(view_gl->v.format)->view_class;
585 if (resource_class != view_class)
586 {
587 FIXME("Render target view not supported, resource format %s, view format %s.\n",
588 debug_d3dformat(resource->format->id), debug_d3dformat(view_gl->v.format->id));
589 return;
590 }
591 if (texture_gl->t.swapchain && texture_gl->t.swapchain->state.desc.backbuffer_count > 1)
592 {
593 FIXME("Swapchain views not supported.\n");
594 return;
595 }
596
597 create_texture_view(&view_gl->gl_view, texture_gl->target, desc, texture_gl, view_gl->v.format);
598 }
599 }
600}
static void create_texture_view(struct wined3d_gl_view *view, GLenum view_target, const struct wined3d_view_desc *desc, struct wined3d_texture_gl *texture_gl, const struct wined3d_format *view_format)
Definition: view.c:165
#define TRACE(s)
Definition: solgame.cpp:4
struct wined3d_rendertarget_view v
Definition: wined3d_gl.h:1065
struct wined3d_gl_view gl_view
Definition: wined3d_gl.h:1066

Referenced by wined3d_rendertarget_view_gl_init().

◆ wined3d_render_target_view_vk_cs_init()

static void wined3d_render_target_view_vk_cs_init ( void *  object)
static

Definition at line 858 of file view.c.

859{
860 struct wined3d_rendertarget_view_vk *view_vk = object;
861 struct wined3d_view_desc *desc = &view_vk->v.desc;
862 const struct wined3d_format_vk *format_vk;
863 struct wined3d_texture_vk *texture_vk;
865 struct wined3d_context *context;
866 VkImageUsageFlags vk_usage = 0;
868
869 TRACE("view_vk %p.\n", view_vk);
870
871 resource = view_vk->v.resource;
872 if (resource->type == WINED3D_RTYPE_BUFFER)
873 {
874 FIXME("Buffer views not implemented.\n");
875 return;
876 }
877
879 format_vk = wined3d_format_vk(view_vk->v.format);
880
881 if (texture_vk->t.layer_count > 1)
883
884 if (resource->format->id == format_vk->f.id && desc->flags == default_flags
885 && !desc->u.texture.level_idx && desc->u.texture.level_count == texture_vk->t.level_count
886 && !desc->u.texture.layer_idx && desc->u.texture.layer_count == texture_vk->t.layer_count
887 && !is_stencil_view_format(&format_vk->f) && resource->type != WINED3D_RTYPE_TEXTURE_3D
888 && is_identity_fixup(format_vk->f.color_fixup))
889 {
890 TRACE("Creating identity render target view.\n");
891 return;
892 }
893
894 if (texture_vk->t.swapchain && texture_vk->t.swapchain->state.desc.backbuffer_count > 1)
895 {
896 FIXME("Swapchain views not supported.\n");
897 return;
898 }
899
900 if (resource->bind_flags & WINED3D_BIND_RENDER_TARGET)
902 if (resource->bind_flags & WINED3D_BIND_DEPTH_STENCIL)
904
905 context = context_acquire(resource->device, NULL, 0);
907 desc, texture_vk, format_vk, COLOR_FIXUP_IDENTITY, true, vk_usage);
909
910 if (!view_vk->vk_image_view)
911 return;
912
913 TRACE("Created image view 0x%s.\n", wine_dbgstr_longlong(view_vk->vk_image_view));
914}
UINT32 uint32_t
Definition: types.h:75
static VkImageView wined3d_view_vk_create_vk_image_view(struct wined3d_context_vk *context_vk, const struct wined3d_view_desc *desc, struct wined3d_texture_vk *texture_vk, const struct wined3d_format_vk *view_format_vk, struct color_fixup_desc fixup, bool rtv, VkImageUsageFlags usage)
Definition: view.c:742
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
static unsigned char default_flags
Definition: debug.c:44
struct wined3d_format f
Definition: wined3d_vk.h:1081
struct wined3d_rendertarget_view v
Definition: wined3d_vk.h:949
struct wined3d_texture t
Definition: wined3d_vk.h:875
VkFlags VkImageUsageFlags
Definition: vulkan.h:1050
@ VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
Definition: vulkan.h:3515
@ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
Definition: vulkan.h:3514
#define WINED3D_BIND_DEPTH_STENCIL
Definition: wined3d.h:915
#define WINED3D_BIND_RENDER_TARGET
Definition: wined3d.h:914
static const struct color_fixup_desc COLOR_FIXUP_IDENTITY

Referenced by wined3d_rendertarget_view_vk_init().

◆ wined3d_rendertarget_view_cleanup()

void wined3d_rendertarget_view_cleanup ( struct wined3d_rendertarget_view *  view)

Definition at line 374 of file view.c.

375{
376 view->parent_ops->wined3d_object_destroyed(view->parent);
377}

Referenced by adapter_gl_destroy_rendertarget_view(), adapter_no3d_destroy_rendertarget_view(), and adapter_vk_destroy_rendertarget_view().

◆ wined3d_rendertarget_view_create()

HRESULT CDECL wined3d_rendertarget_view_create ( const struct wined3d_view_desc *  desc,
struct wined3d_resource *  resource,
void *  parent,
const struct wined3d_parent_ops *  parent_ops,
struct wined3d_rendertarget_view **  view 
)

Definition at line 933 of file view.c.

936{
937 const struct wined3d_adapter_ops *adapter_ops;
938
939 TRACE("desc %s, resource %p, parent %p, parent_ops %p, view %p.\n",
941
942 adapter_ops = resource->device->adapter->adapter_ops;
943 return adapter_ops->adapter_create_rendertarget_view(desc, resource, parent, parent_ops, view);
944}
const char * wined3d_debug_view_desc(const struct wined3d_view_desc *d, const struct wined3d_resource *resource)
Definition: utils.c:4867
r parent
Definition: btrfs.c:3010
HRESULT(* adapter_create_rendertarget_view)(const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_rendertarget_view **view)

Referenced by d3d_depthstencil_view_init(), d3d_rendertarget_view_init(), wined3d_device_reset(), wined3d_device_set_implicit_swapchain(), wined3d_rendertarget_view_create_from_sub_resource(), and wined3d_swapchain_init().

◆ wined3d_rendertarget_view_create_from_sub_resource()

HRESULT CDECL wined3d_rendertarget_view_create_from_sub_resource ( struct wined3d_texture *  texture,
unsigned int  sub_resource_idx,
void *  parent,
const struct wined3d_parent_ops *  parent_ops,
struct wined3d_rendertarget_view **  view 
)

Definition at line 946 of file view.c.

949{
950 struct wined3d_view_desc desc;
951
952 TRACE("texture %p, sub_resource_idx %u, parent %p, parent_ops %p, view %p.\n",
953 texture, sub_resource_idx, parent, parent_ops, view);
954
955 desc.format_id = texture->resource.format->id;
956 desc.flags = 0;
957 desc.u.texture.level_idx = sub_resource_idx % texture->level_count;
958 desc.u.texture.level_count = 1;
959 desc.u.texture.layer_idx = sub_resource_idx / texture->level_count;
960 desc.u.texture.layer_count = 1;
961
962 return wined3d_rendertarget_view_create(&desc, &texture->resource, parent, parent_ops, view);
963}
HRESULT CDECL wined3d_rendertarget_view_create(const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_rendertarget_view **view)
Definition: view.c:933

Referenced by d3d8_surface_acquire_rendertarget_view(), d3d9_surface_acquire_rendertarget_view(), and ddraw_surface_get_rendertarget_view().

◆ wined3d_rendertarget_view_decref()

ULONG CDECL wined3d_rendertarget_view_decref ( struct wined3d_rendertarget_view *  view)

Definition at line 379 of file view.c.

380{
381 unsigned int refcount = InterlockedDecrement(&view->refcount);
382
383 TRACE("%p decreasing refcount to %u.\n", view, refcount);
384
385 if (!refcount)
386 {
387 struct wined3d_resource *resource = view->resource;
388
389 /* Release the resource after destroying the view.
390 * See wined3d_shader_resource_view_decref(). */
392 resource->device->adapter->adapter_ops->adapter_destroy_rendertarget_view(view);
395 }
396
397 return refcount;
398}
#define InterlockedDecrement
Definition: armddk.h:52
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:544
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:539
static ULONG wined3d_resource_decref(struct wined3d_resource *resource)

Referenced by d3d11_depthstencil_view_Release(), d3d11_rendertarget_view_Release(), d3d8_surface_Release(), d3d8_texture_decref(), d3d9_surface_Release(), d3d9_texture_decref(), ddraw_surface7_SetSurfaceDesc(), ddraw_surface_cleanup(), state_unbind_resources(), wined3d_cs_packet_decref_objects(), wined3d_device_context_set_depth_stencil_view(), wined3d_device_context_set_rendertarget_views(), wined3d_device_reset(), and wined3d_device_uninit_3d().

◆ wined3d_rendertarget_view_get_box()

void wined3d_rendertarget_view_get_box ( struct wined3d_rendertarget_view *  view,
struct wined3d_box *  box 
)

Definition at line 542 of file view.c.

544{
545 if (view->resource->type != WINED3D_RTYPE_TEXTURE_3D)
546 {
547 wined3d_box_set(box, 0, 0, view->width, view->height, 0, 1);
548 }
549 else
550 {
552 wined3d_texture_get_level_box(texture, view->sub_resource_idx, box);
553 }
554}
Definition: palette.c:466
enum view_type type
static void wined3d_box_set(struct wined3d_box *box, unsigned int left, unsigned int top, unsigned int right, unsigned int bottom, unsigned int front, unsigned int back)
Definition: wined3d.h:3006
static void wined3d_texture_get_level_box(const struct wined3d_texture *texture, unsigned int level, struct wined3d_box *box)

Referenced by cpu_blitter_clear().

◆ wined3d_rendertarget_view_get_drawable_size()

void wined3d_rendertarget_view_get_drawable_size ( const struct wined3d_rendertarget_view *  view,
const struct wined3d_context *  context,
unsigned int *  width,
unsigned int *  height 
)

Definition at line 437 of file view.c.

439{
440 const struct wined3d_texture *texture;
441
442 if (view->resource->type != WINED3D_RTYPE_TEXTURE_2D)
443 {
444 *width = view->width;
445 *height = view->height;
446 return;
447 }
448
450 if (texture->swapchain)
451 {
452 /* The drawable size of an onscreen drawable is the surface size.
453 * (Actually: The window size, but the surface is created in window
454 * size.) */
455 *width = texture->resource.width;
456 *height = texture->resource.height;
457 }
458 else
459 {
460 unsigned int level_idx = view->sub_resource_idx % texture->level_count;
461
462 /* The drawable size of an FBO target is the OpenGL texture size,
463 * which is the power of two size. */
466 }
467}
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)

Referenced by ffp_blitter_clear_rendertargets().

◆ wined3d_rendertarget_view_get_locations()

DWORD wined3d_rendertarget_view_get_locations ( const struct wined3d_rendertarget_view *  view)

Definition at line 520 of file view.c.

521{
522 struct wined3d_resource *resource = view->resource;
523 unsigned int i, sub_resource_idx, layer_count;
524 const struct wined3d_texture *texture;
525 DWORD ret = ~0u;
526
527 if (resource->type == WINED3D_RTYPE_BUFFER)
528 return buffer_from_resource(resource)->locations;
529
531 sub_resource_idx = view->sub_resource_idx;
532 layer_count = resource->type != WINED3D_RTYPE_TEXTURE_3D ? view->layer_count : 1;
533 for (i = 0; i < layer_count; ++i, sub_resource_idx += texture->level_count)
534 ret &= texture->sub_resources[sub_resource_idx].locations;
535
536 if (!ret)
537 WARN("View %p (texture %p) layers do not have a location in common.\n", view, texture);
538
539 return ret;
540}
unsigned long DWORD
Definition: ntddk_ex.h:95
if(dx< 0)
Definition: linetemp.h:194

Referenced by wined3d_context_vk_begin_render_pass(), wined3d_context_vk_prepare_used_rtv(), and wined3d_render_pass_key_vk_init().

◆ wined3d_rendertarget_view_get_parent()

void *CDECL wined3d_rendertarget_view_get_parent ( const struct wined3d_rendertarget_view *  view)

Definition at line 400 of file view.c.

401{
402 TRACE("view %p.\n", view);
403
404 return view->parent;
405}

Referenced by d3d10_device_OMGetRenderTargets(), d3d11_device_context_OMGetRenderTargets(), and d3d_device_sync_rendertarget().

◆ wined3d_rendertarget_view_get_resource()

struct wined3d_resource *CDECL wined3d_rendertarget_view_get_resource ( const struct wined3d_rendertarget_view *  view)

Definition at line 430 of file view.c.

431{
432 TRACE("view %p.\n", view);
433
434 return view->resource;
435}

Referenced by d3d8_device_Reset(), d3d8_swapchain_create(), d3d9_device_reset(), d3d9_swapchain_create(), and resolve_depth_buffer().

◆ wined3d_rendertarget_view_get_sub_resource_parent()

void *CDECL wined3d_rendertarget_view_get_sub_resource_parent ( const struct wined3d_rendertarget_view *  view)

Definition at line 407 of file view.c.

408{
409 struct wined3d_texture *texture;
410
411 TRACE("view %p.\n", view);
412
413 if (view->resource->type == WINED3D_RTYPE_BUFFER)
415
417
418 return texture->sub_resources[view->sub_resource_idx].parent;
419}
void *CDECL wined3d_buffer_get_parent(const struct wined3d_buffer *buffer)
Definition: buffer.c:476

Referenced by d3d8_device_GetDepthStencilSurface(), d3d8_device_GetRenderTarget(), d3d8_device_SetRenderTarget(), d3d8_device_SetViewport(), d3d9_device_GetDepthStencilSurface(), d3d9_device_GetRenderTarget(), d3d9_device_reset(), d3d_device7_SetViewport(), d3d_viewport_SetViewport(), d3d_viewport_SetViewport2(), device_init(), and resolve_depth_buffer().

◆ wined3d_rendertarget_view_gl_init()

HRESULT wined3d_rendertarget_view_gl_init ( struct wined3d_rendertarget_view_gl *  view_gl,
const struct wined3d_view_desc *  desc,
struct wined3d_resource *  resource,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)

Definition at line 659 of file view.c.

662{
663 HRESULT hr;
664
665 TRACE("view_gl %p, desc %s, resource %p, parent %p, parent_ops %p.\n",
666 view_gl, wined3d_debug_view_desc(desc, resource), resource, parent, parent_ops);
667
668 if (FAILED(hr = wined3d_rendertarget_view_init(&view_gl->v, desc, resource, parent, parent_ops)))
669 return hr;
670
672
673 return hr;
674}
void wined3d_cs_init_object(struct wined3d_cs *cs, void(*callback)(void *object), void *object)
Definition: cs.c:2304
HRESULT hr
Definition: delayimp.cpp:582
static void wined3d_render_target_view_gl_cs_init(void *object)
Definition: view.c:556
static HRESULT wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *view, const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops)
Definition: view.c:602
#define FAILED(hr)
Definition: intsafe.h:51

Referenced by adapter_gl_create_rendertarget_view().

◆ wined3d_rendertarget_view_incref()

ULONG CDECL wined3d_rendertarget_view_incref ( struct wined3d_rendertarget_view *  view)

◆ wined3d_rendertarget_view_init()

static HRESULT wined3d_rendertarget_view_init ( struct wined3d_rendertarget_view *  view,
const struct wined3d_view_desc *  desc,
struct wined3d_resource *  resource,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)
static

Definition at line 602 of file view.c.

605{
606 BOOL allow_srgb_toggle = FALSE;
607
608 view->refcount = 1;
609 view->parent = parent;
610 view->parent_ops = parent_ops;
611
612 if (resource->type != WINED3D_RTYPE_BUFFER)
613 {
615
616 if (texture->swapchain)
617 allow_srgb_toggle = TRUE;
618 }
619 if (!(view->format = validate_resource_view(desc, resource, TRUE, allow_srgb_toggle)))
620 return E_INVALIDARG;
621 view->format_attrs = view->format->attrs;
622 view->format_caps = view->format->caps[resource->gl_type];
623 view->desc = *desc;
624
625 if (resource->type == WINED3D_RTYPE_BUFFER)
626 {
627 view->sub_resource_idx = 0;
628 view->layer_count = 1;
629 view->width = desc->u.buffer.count;
630 view->height = 1;
631 }
632 else
633 {
635
636 view->sub_resource_idx = desc->u.texture.level_idx;
638 view->sub_resource_idx += desc->u.texture.layer_idx * texture->level_count;
639 view->layer_count = desc->u.texture.layer_count;
640 view->width = wined3d_texture_get_level_width(texture, desc->u.texture.level_idx);
641 view->height = wined3d_texture_get_level_height(texture, desc->u.texture.level_idx);
642 }
643
645
646 return WINED3D_OK;
647}
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRUE
Definition: types.h:120
static const struct wined3d_format * validate_resource_view(const struct wined3d_view_desc *desc, struct wined3d_resource *resource, BOOL mip_slice, BOOL allow_srgb_toggle)
Definition: view.c:84
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WINED3D_OK
Definition: wined3d.h:33
static ULONG wined3d_resource_incref(struct wined3d_resource *resource)

Referenced by wined3d_rendertarget_view_gl_init(), wined3d_rendertarget_view_no3d_init(), and wined3d_rendertarget_view_vk_init().

◆ wined3d_rendertarget_view_invalidate_location()

void wined3d_rendertarget_view_invalidate_location ( struct wined3d_rendertarget_view *  view,
uint32_t  location 
)

Definition at line 514 of file view.c.

515{
517}
static void wined3d_view_invalidate_location(struct wined3d_resource *resource, const struct wined3d_view_desc *desc, DWORD location)
Definition: view.c:317

Referenced by draw_primitive(), ffp_blitter_clear_rendertargets(), vk_blitter_clear_rendertargets(), and wined3d_context_vk_apply_draw_state().

◆ wined3d_rendertarget_view_load_location()

void wined3d_rendertarget_view_load_location ( struct wined3d_rendertarget_view *  view,
struct wined3d_context *  context,
uint32_t  location 
)

Definition at line 489 of file view.c.

491{
493}
static void wined3d_view_load_location(struct wined3d_resource *resource, const struct wined3d_view_desc *desc, struct wined3d_context *context, DWORD location)
Definition: view.c:341

Referenced by draw_primitive(), ffp_blitter_clear_rendertargets(), vk_blitter_clear_rendertargets(), and wined3d_context_vk_prepare_used_rtv().

◆ wined3d_rendertarget_view_no3d_init()

HRESULT wined3d_rendertarget_view_no3d_init ( struct wined3d_rendertarget_view *  view_no3d,
const struct wined3d_view_desc *  desc,
struct wined3d_resource *  resource,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)

Definition at line 649 of file view.c.

652{
653 TRACE("view_no3d %p, desc %s, resource %p, parent %p, parent_ops %p.\n",
654 view_no3d, wined3d_debug_view_desc(desc, resource), resource, parent, parent_ops);
655
656 return wined3d_rendertarget_view_init(view_no3d, desc, resource, parent, parent_ops);
657}

Referenced by adapter_no3d_create_rendertarget_view().

◆ wined3d_rendertarget_view_prepare_location()

void wined3d_rendertarget_view_prepare_location ( struct wined3d_rendertarget_view *  view,
struct wined3d_context *  context,
uint32_t  location 
)

Definition at line 469 of file view.c.

471{
472 struct wined3d_resource *resource = view->resource;
473 unsigned int i, sub_resource_idx, layer_count;
474 struct wined3d_texture *texture;
475
476 if (resource->type == WINED3D_RTYPE_BUFFER)
477 {
478 FIXME("Not implemented for resources %s.\n", debug_d3dresourcetype(resource->type));
479 return;
480 }
481
483 sub_resource_idx = view->sub_resource_idx;
484 layer_count = resource->type != WINED3D_RTYPE_TEXTURE_3D ? view->layer_count : 1;
485 for (i = 0; i < layer_count; ++i, sub_resource_idx += texture->level_count)
487}
BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, unsigned int location)
Definition: texture.c:2116

Referenced by draw_primitive(), ffp_blitter_clear_rendertargets(), wined3d_context_vk_apply_draw_state(), and wined3d_context_vk_prepare_used_rtv().

◆ wined3d_rendertarget_view_set_parent()

void CDECL wined3d_rendertarget_view_set_parent ( struct wined3d_rendertarget_view *  view,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)

Definition at line 421 of file view.c.

423{
424 TRACE("view %p, parent %p, parent_ops %p.\n", view, parent, parent_ops);
425
426 view->parent = parent;
427 view->parent_ops = parent_ops;
428}

Referenced by ddraw_surface7_SetSurfaceDesc(), and ddraw_texture_rename_to().

◆ wined3d_rendertarget_view_validate_location()

void wined3d_rendertarget_view_validate_location ( struct wined3d_rendertarget_view *  view,
uint32_t  location 
)

Definition at line 495 of file view.c.

496{
497 struct wined3d_resource *resource = view->resource;
498 unsigned int i, sub_resource_idx, layer_count;
499 struct wined3d_texture *texture;
500
501 if (resource->type == WINED3D_RTYPE_BUFFER)
502 {
503 FIXME("Not implemented for resources %s.\n", debug_d3dresourcetype(resource->type));
504 return;
505 }
506
508 sub_resource_idx = view->sub_resource_idx;
509 layer_count = resource->type != WINED3D_RTYPE_TEXTURE_3D ? view->layer_count : 1;
510 for (i = 0; i < layer_count; ++i, sub_resource_idx += texture->level_count)
512}
void wined3d_texture_validate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, uint32_t location)
Definition: texture.c:678

Referenced by draw_primitive(), ffp_blitter_clear_rendertargets(), vk_blitter_clear_rendertargets(), wined3d_context_vk_apply_draw_state(), and wined3d_cs_exec_present().

◆ wined3d_rendertarget_view_vk_init()

HRESULT wined3d_rendertarget_view_vk_init ( struct wined3d_rendertarget_view_vk *  view_vk,
const struct wined3d_view_desc *  desc,
struct wined3d_resource *  resource,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)

Definition at line 916 of file view.c.

919{
920 HRESULT hr;
921
922 TRACE("view_vk %p, desc %s, resource %p, parent %p, parent_ops %p.\n",
923 view_vk, wined3d_debug_view_desc(desc, resource), resource, parent, parent_ops);
924
925 if (FAILED(hr = wined3d_rendertarget_view_init(&view_vk->v, desc, resource, parent, parent_ops)))
926 return hr;
927
929
930 return hr;
931}
static void wined3d_render_target_view_vk_cs_init(void *object)
Definition: view.c:858

Referenced by adapter_vk_create_rendertarget_view().

◆ wined3d_shader_resource_view_cleanup()

void wined3d_shader_resource_view_cleanup ( struct wined3d_shader_resource_view *  view)

Definition at line 978 of file view.c.

979{
980 view->parent_ops->wined3d_object_destroyed(view->parent);
981}

Referenced by adapter_gl_destroy_shader_resource_view(), and adapter_vk_destroy_shader_resource_view().

◆ wined3d_shader_resource_view_create()

HRESULT CDECL wined3d_shader_resource_view_create ( const struct wined3d_view_desc *  desc,
struct wined3d_resource *  resource,
void *  parent,
const struct wined3d_parent_ops *  parent_ops,
struct wined3d_shader_resource_view **  view 
)

Definition at line 1261 of file view.c.

1264{
1265 const struct wined3d_adapter_ops *adapter_ops;
1266
1267 TRACE("desc %s, resource %p, parent %p, parent_ops %p, view %p.\n",
1269
1270 adapter_ops = resource->device->adapter->adapter_ops;
1271 return adapter_ops->adapter_create_shader_resource_view(desc, resource, parent, parent_ops, view);
1272}
HRESULT(* adapter_create_shader_resource_view)(const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_shader_resource_view **view)

Referenced by d3d_shader_resource_view_init(), and wined3d_texture_acquire_identity_srv().

◆ wined3d_shader_resource_view_decref()

ULONG CDECL wined3d_shader_resource_view_decref ( struct wined3d_shader_resource_view *  view)

Definition at line 990 of file view.c.

991{
992 unsigned int refcount;
993
994 if (view->desc.flags & WINED3D_VIEW_FORWARD_REFERENCE)
995 return wined3d_resource_decref(view->resource);
996
997 refcount = InterlockedDecrement(&view->refcount);
998 TRACE("%p decreasing refcount to %u.\n", view, refcount);
999
1000 if (!refcount)
1001 {
1002 struct wined3d_resource *resource = view->resource;
1003
1004 /* Release the resource after destroying the view:
1005 * - adapter_destroy_shader_resource_view() needs a reference to the
1006 * device, which the resource implicitly provides.
1007 * - We shouldn't free buffer resources until after we've removed the
1008 * view from its bo_user list. */
1011 }
1012
1013 return refcount;
1014}
void wined3d_shader_resource_view_destroy(struct wined3d_shader_resource_view *view)
Definition: view.c:983
#define WINED3D_VIEW_FORWARD_REFERENCE
Definition: wined3d.h:1588

Referenced by d3d11_shader_resource_view_Release(), state_unbind_resources(), wined3d_cs_packet_decref_objects(), wined3d_device_context_set_shader_resource_views(), wined3d_device_set_texture(), and wined3d_texture_acquire_identity_srv().

◆ wined3d_shader_resource_view_destroy()

void wined3d_shader_resource_view_destroy ( struct wined3d_shader_resource_view *  view)

Definition at line 983 of file view.c.

984{
986 view->resource->device->adapter->adapter_ops->adapter_destroy_shader_resource_view(view);
988}

Referenced by wined3d_shader_resource_view_decref(), and wined3d_texture_decref().

◆ wined3d_shader_resource_view_get_parent()

◆ wined3d_shader_resource_view_gl_bind()

void wined3d_shader_resource_view_gl_bind ( struct wined3d_shader_resource_view_gl *  view_gl,
unsigned int  unit,
struct wined3d_sampler_gl *  sampler_gl,
struct wined3d_context_gl *  context_gl 
)

Definition at line 1274 of file view.c.

1276{
1277 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
1278 struct wined3d_texture_gl *texture_gl;
1279
1280 wined3d_context_gl_active_texture(context_gl, gl_info, unit);
1281
1282 if (view_gl->gl_view.name)
1283 {
1284 wined3d_context_gl_bind_texture(context_gl, view_gl->gl_view.target, view_gl->gl_view.name);
1285 wined3d_sampler_gl_bind(sampler_gl, unit, NULL, context_gl);
1286 return;
1287 }
1288
1289 if (view_gl->v.resource->type == WINED3D_RTYPE_BUFFER)
1290 {
1291 FIXME("Buffer shader resources not supported.\n");
1292 return;
1293 }
1294
1295 texture_gl = wined3d_texture_gl(wined3d_texture_from_resource(view_gl->v.resource));
1296 wined3d_texture_gl_bind(texture_gl, context_gl, sampler_gl->s.desc.srgb_decode);
1297 wined3d_sampler_gl_bind(sampler_gl, unit, texture_gl, context_gl);
1298}
void wined3d_context_gl_active_texture(struct wined3d_context_gl *context_gl, const struct wined3d_gl_info *gl_info, unsigned int unit)
Definition: context_gl.c:2489
struct wined3d_texture *__cdecl wined3d_texture_from_resource(struct wined3d_resource *resource)
Definition: texture.c:3343
void wined3d_texture_gl_bind(struct wined3d_texture_gl *texture_gl, struct wined3d_context_gl *context_gl, BOOL srgb)
Definition: texture.c:1288
png_const_structrp png_const_inforp int * unit
Definition: png.h:2392
void wined3d_sampler_gl_bind(struct wined3d_sampler_gl *sampler_gl, unsigned int unit, struct wined3d_texture_gl *texture_gl, const struct wined3d_context_gl *context_gl)
Definition: sampler.c:320
struct wined3d_sampler s
Definition: wined3d_gl.h:1029
struct wined3d_shader_resource_view v
Definition: wined3d_gl.h:1081

Referenced by wined3d_context_gl_bind_shader_resources().

◆ wined3d_shader_resource_view_gl_cs_init()

static void wined3d_shader_resource_view_gl_cs_init ( void *  object)
static

Definition at line 1035 of file view.c.

1036{
1037 struct wined3d_shader_resource_view_gl *view_gl = object;
1038 struct wined3d_resource *resource = view_gl->v.resource;
1039 const struct wined3d_format *view_format;
1040 const struct wined3d_gl_info *gl_info;
1041 const struct wined3d_view_desc *desc;
1042 GLenum view_target;
1043
1044 TRACE("view_gl %p.\n", view_gl);
1045
1046 view_format = view_gl->v.format;
1047 gl_info = &wined3d_adapter_gl(resource->device->adapter)->gl_info;
1048 desc = &view_gl->v.desc;
1049
1050 if (resource->type == WINED3D_RTYPE_BUFFER)
1051 {
1053 struct wined3d_context *context;
1054
1055 context = context_acquire(resource->device, NULL, 0);
1056 create_buffer_view(&view_gl->gl_view, context, desc, buffer, view_format);
1057 view_gl->bo_user.valid = true;
1058 list_add_head(&buffer->buffer_object->users, &view_gl->bo_user.entry);
1060 }
1061 else
1062 {
1064 GLenum resource_class, view_class;
1065
1066 resource_class = wined3d_format_gl(resource->format)->view_class;
1067 view_class = wined3d_format_gl(view_format)->view_class;
1068 view_target = get_texture_view_target(gl_info, desc, texture_gl);
1069
1070 if (resource->format->id == view_format->id && texture_gl->target == view_target
1071 && !desc->u.texture.level_idx && desc->u.texture.level_count == texture_gl->t.level_count
1072 && !desc->u.texture.layer_idx && desc->u.texture.layer_count == texture_gl->t.layer_count
1073 && !is_stencil_view_format(view_format))
1074 {
1075 TRACE("Creating identity shader resource view.\n");
1076 }
1077 else if (texture_gl->t.swapchain && texture_gl->t.swapchain->state.desc.backbuffer_count > 1)
1078 {
1079 FIXME("Swapchain shader resource views not supported.\n");
1080 }
1081 else if (resource->format->typeless_id == view_format->typeless_id
1082 && resource_class == view_class)
1083 {
1084 create_texture_view(&view_gl->gl_view, view_target, desc, texture_gl, view_format);
1085 }
1086 else if (wined3d_format_is_depth_view(resource->format->id, view_format->id))
1087 {
1088 create_texture_view(&view_gl->gl_view, view_target, desc, texture_gl, resource->format);
1089 }
1090 else
1091 {
1092 FIXME("Shader resource view not supported, resource format %s, view format %s.\n",
1093 debug_d3dformat(resource->format->id), debug_d3dformat(view_format->id));
1094 }
1095 }
1096}
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
BOOL wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id, enum wined3d_format_id view_format_id)
Definition: utils.c:4476
static GLenum get_texture_view_target(const struct wined3d_gl_info *gl_info, const struct wined3d_view_desc *desc, const struct wined3d_texture_gl *texture_gl)
Definition: view.c:34
static void create_buffer_view(struct wined3d_gl_view *view, struct wined3d_context *context, const struct wined3d_view_desc *desc, struct wined3d_buffer *buffer, const struct wined3d_format *view_format)
Definition: view.c:307
struct wined3d_gl_info gl_info
Definition: wined3d_gl.h:800
enum wined3d_format_id id
enum wined3d_format_id typeless_id
struct wined3d_bo_user bo_user
Definition: wined3d_gl.h:1082

Referenced by wined3d_shader_resource_view_gl_init().

◆ wined3d_shader_resource_view_gl_generate_mipmap()

void wined3d_shader_resource_view_gl_generate_mipmap ( struct wined3d_shader_resource_view_gl *  view_gl,
struct wined3d_context_gl *  context_gl 
)

Definition at line 1312 of file view.c.

1314{
1315 unsigned int i, j, layer_count, level_count, base_level, base_layer, sub_resource_idx;
1316 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
1317 struct wined3d_texture_gl *texture_gl;
1318 struct gl_texture *gl_tex;
1320 BOOL srgb;
1321
1322 TRACE("view_gl %p.\n", view_gl);
1323
1324 layer_count = view_gl->v.desc.u.texture.layer_count;
1325 level_count = view_gl->v.desc.u.texture.level_count;
1326 base_level = view_gl->v.desc.u.texture.level_idx;
1327 base_layer = view_gl->v.desc.u.texture.layer_idx;
1328
1329 texture_gl = wined3d_texture_gl(texture_from_resource(view_gl->v.resource));
1330 srgb = !!(texture_gl->t.flags & WINED3D_TEXTURE_IS_SRGB);
1332 for (i = 0; i < layer_count; ++i)
1333 {
1334 sub_resource_idx = (base_layer + i) * texture_gl->t.level_count + base_level;
1335 if (!wined3d_texture_load_location(&texture_gl->t, sub_resource_idx, &context_gl->c, location))
1336 ERR("Failed to load source layer %u.\n", base_layer + i);
1337 }
1338
1339 if (view_gl->gl_view.name)
1340 {
1341 shader_resource_view_gl_bind_and_dirtify(view_gl, context_gl);
1342 }
1343 else
1344 {
1345 wined3d_texture_gl_bind_and_dirtify(texture_gl, context_gl, srgb);
1346 gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target, GL_TEXTURE_BASE_LEVEL, base_level);
1347 gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target, GL_TEXTURE_MAX_LEVEL, base_level + level_count - 1);
1348 }
1349
1350 if (gl_info->supported[ARB_SAMPLER_OBJECTS])
1351 GL_EXTCALL(glBindSampler(context_gl->active_texture, 0));
1352 gl_tex = wined3d_texture_gl_get_gl_texture(texture_gl, srgb);
1353 if (context_gl->c.d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL
1355 {
1356 gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target,
1358 gl_tex->sampler_desc.srgb_decode = FALSE;
1359 }
1360
1361 gl_info->fbo_ops.glGenerateMipmap(texture_gl->target);
1362 checkGLcall("glGenerateMipMap()");
1363
1364 for (i = 0; i < layer_count; ++i)
1365 {
1366 for (j = 1; j < level_count; ++j)
1367 {
1368 sub_resource_idx = (base_layer + i) * texture_gl->t.level_count + base_level + j;
1369 wined3d_texture_validate_location(&texture_gl->t, sub_resource_idx, location);
1370 wined3d_texture_invalidate_location(&texture_gl->t, sub_resource_idx, ~location);
1371 }
1372 }
1373
1374 if (!view_gl->gl_view.name)
1375 {
1376 gl_tex->sampler_desc.mip_base_level = base_level;
1377 gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target,
1378 GL_TEXTURE_MAX_LEVEL, texture_gl->t.level_count - 1);
1379 }
1380}
void wined3d_texture_invalidate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, uint32_t location)
Definition: texture.c:702
void wined3d_texture_gl_bind_and_dirtify(struct wined3d_texture_gl *texture_gl, struct wined3d_context_gl *context_gl, BOOL srgb)
Definition: texture.c:1405
BOOL wined3d_texture_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, uint32_t location)
Definition: texture.c:770
static void shader_resource_view_gl_bind_and_dirtify(struct wined3d_shader_resource_view_gl *view_gl, struct wined3d_context_gl *context_gl)
Definition: view.c:1301
#define GL_TEXTURE_BASE_LEVEL
Definition: gl.h:1503
#define GL_TEXTURE_MAX_LEVEL
Definition: gl.h:1504
#define GL_SKIP_DECODE_EXT
Definition: glext.h:5291
#define GL_TEXTURE_SRGB_DECODE_EXT
Definition: glext.h:5289
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define location(file, line)
Definition: kmtest.h:18
struct wined3d_sampler_desc sampler_desc
Definition: wined3d_gl.h:928
unsigned int active_texture
Definition: wined3d_gl.h:621
struct wined3d_fbo_ops fbo_ops
Definition: wined3d_gl.h:354
#define WINED3D_SRGB_READ_WRITE_CONTROL
Definition: wined3d.h:1330
@ EXT_TEXTURE_SRGB_DECODE
Definition: wined3d_gl.h:203
@ ARB_SAMPLER_OBJECTS
Definition: wined3d_gl.h:106
static struct gl_texture * wined3d_texture_gl_get_gl_texture(struct wined3d_texture_gl *texture_gl, bool srgb)
Definition: wined3d_gl.h:959
#define WINED3D_LOCATION_TEXTURE_SRGB
#define WINED3D_LOCATION_TEXTURE_RGB
#define WINED3D_TEXTURE_IS_SRGB

Referenced by adapter_gl_generate_mipmap().

◆ wined3d_shader_resource_view_gl_init()

HRESULT wined3d_shader_resource_view_gl_init ( struct wined3d_shader_resource_view_gl *  view_gl,
const struct wined3d_view_desc *  desc,
struct wined3d_resource *  resource,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)

Definition at line 1121 of file view.c.

1124{
1125 HRESULT hr;
1126
1127 TRACE("view_gl %p, desc %s, resource %p, parent %p, parent_ops %p.\n",
1128 view_gl, wined3d_debug_view_desc(desc, resource), resource, parent, parent_ops);
1129
1130 if (FAILED(hr = wined3d_shader_resource_view_init(&view_gl->v, desc, resource, parent, parent_ops)))
1131 return hr;
1132
1133 list_init(&view_gl->bo_user.entry);
1135
1136 return hr;
1137}
static void list_init(struct list_entry *head)
Definition: list.h:51
static void wined3d_shader_resource_view_gl_cs_init(void *object)
Definition: view.c:1035
static HRESULT wined3d_shader_resource_view_init(struct wined3d_shader_resource_view *view, const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops)
Definition: view.c:1098

Referenced by adapter_gl_create_shader_resource_view().

◆ wined3d_shader_resource_view_gl_update()

void wined3d_shader_resource_view_gl_update ( struct wined3d_shader_resource_view_gl *  srv_gl,
struct wined3d_context_gl *  context_gl 
)

Definition at line 1023 of file view.c.

1025{
1026 struct wined3d_buffer *buffer = buffer_from_resource(srv_gl->v.resource);
1027
1028 assert(!srv_gl->bo_user.valid);
1029
1030 create_buffer_view(&srv_gl->gl_view, &context_gl->c, &srv_gl->v.desc, buffer, srv_gl->v.format);
1031 srv_gl->bo_user.valid = true;
1032 list_add_head(&buffer->buffer_object->users, &srv_gl->bo_user.entry);
1033}
#define assert(_expr)
Definition: assert.h:32

Referenced by context_gl_load_shader_resources().

◆ wined3d_shader_resource_view_incref()

ULONG CDECL wined3d_shader_resource_view_incref ( struct wined3d_shader_resource_view *  view)

Definition at line 965 of file view.c.

966{
967 unsigned int refcount;
968
969 if (view->desc.flags & WINED3D_VIEW_FORWARD_REFERENCE)
970 return wined3d_resource_incref(view->resource);
971
972 refcount = InterlockedIncrement(&view->refcount);
973 TRACE("%p increasing refcount to %u.\n", view, refcount);
974
975 return refcount;
976}

Referenced by d3d11_shader_resource_view_AddRef(), wined3d_cs_packet_incref_objects(), wined3d_device_context_set_shader_resource_views(), and wined3d_device_set_texture().

◆ wined3d_shader_resource_view_init()

static HRESULT wined3d_shader_resource_view_init ( struct wined3d_shader_resource_view *  view,
const struct wined3d_view_desc *  desc,
struct wined3d_resource *  resource,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)
static

Definition at line 1098 of file view.c.

1101{
1102 view->refcount = 1;
1103 view->parent = parent;
1104 view->parent_ops = parent_ops;
1105
1106 if (!(resource->bind_flags & WINED3D_BIND_SHADER_RESOURCE))
1107 return E_INVALIDARG;
1108 if (!(view->format = validate_resource_view(desc, resource, FALSE, FALSE)))
1109 return E_INVALIDARG;
1110 view->desc = *desc;
1111
1112 /* If WINED3D_VIEW_FORWARD_REFERENCE, the view shouldn't take a reference
1113 * to the resource. However, the reference to the view returned by this
1114 * function should translate to a resource reference, so we increment the
1115 * resource's reference count anyway. */
1117
1118 return WINED3D_OK;
1119}
#define WINED3D_BIND_SHADER_RESOURCE
Definition: wined3d.h:912

Referenced by wined3d_shader_resource_view_gl_init(), and wined3d_shader_resource_view_vk_init().

◆ wined3d_shader_resource_view_vk_cs_init()

static void wined3d_shader_resource_view_vk_cs_init ( void *  object)
static

Definition at line 1167 of file view.c.

1168{
1169 struct wined3d_shader_resource_view_vk *srv_vk = object;
1170 struct wined3d_view_desc *desc = &srv_vk->v.desc;
1171 struct wined3d_texture_vk *texture_vk;
1172 const struct wined3d_format *format;
1173 struct wined3d_buffer_vk *buffer_vk;
1174 struct wined3d_resource *resource;
1175 struct wined3d_context *context;
1176 VkBufferView vk_buffer_view;
1178 VkImageView vk_image_view;
1179 struct wined3d_bo_vk *bo;
1180
1181 TRACE("srv_vk %p.\n", srv_vk);
1182
1183 resource = srv_vk->v.resource;
1184 format = srv_vk->v.format;
1185
1186 if (resource->type == WINED3D_RTYPE_BUFFER)
1187 {
1189
1190 context = context_acquire(resource->device, NULL, 0);
1192 desc, buffer_vk, wined3d_format_vk(format));
1194
1195 if (!vk_buffer_view)
1196 return;
1197 bo = wined3d_bo_vk(buffer_vk->b.buffer_object);
1198
1199 TRACE("Created buffer view 0x%s.\n", wine_dbgstr_longlong(vk_buffer_view));
1200
1201 srv_vk->view_vk.u.vk_buffer_view = vk_buffer_view;
1202 srv_vk->view_vk.bo_user.valid = true;
1203 list_add_head(&bo->b.users, &srv_vk->view_vk.bo_user.entry);
1204
1205 return;
1206 }
1207
1209
1210 if (texture_vk->t.layer_count > 1)
1212
1213 if (resource->format->id == format->id && desc->flags == default_flags
1214 && !desc->u.texture.level_idx && desc->u.texture.level_count == texture_vk->t.level_count
1215 && !desc->u.texture.layer_idx && desc->u.texture.layer_count == texture_vk->t.layer_count
1216 && !(resource->bind_flags & WINED3D_BIND_DEPTH_STENCIL))
1217 {
1218 TRACE("Creating identity shader resource view.\n");
1219 return;
1220 }
1221
1222 if (texture_vk->t.swapchain && texture_vk->t.swapchain->state.desc.backbuffer_count > 1)
1223 FIXME("Swapchain shader resource views not supported.\n");
1224
1225 context = context_acquire(resource->device, NULL, 0);
1227 desc, texture_vk, wined3d_format_vk(format), format->color_fixup, false, VK_IMAGE_USAGE_SAMPLED_BIT);
1229
1230 if (!vk_image_view)
1231 return;
1232
1233 TRACE("Created image view 0x%s.\n", wine_dbgstr_longlong(vk_image_view));
1234
1235 srv_vk->view_vk.u.vk_image_info.imageView = vk_image_view;
1236 srv_vk->view_vk.u.vk_image_info.sampler = VK_NULL_HANDLE;
1237 if (texture_vk->layout == VK_IMAGE_LAYOUT_GENERAL)
1238 srv_vk->view_vk.u.vk_image_info.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
1239 else
1240 srv_vk->view_vk.u.vk_image_info.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
1241}
static VkBufferView wined3d_view_vk_create_vk_buffer_view(struct wined3d_context_vk *context_vk, const struct wined3d_view_desc *desc, struct wined3d_buffer_vk *buffer_vk, const struct wined3d_format_vk *view_format_vk)
Definition: view.c:708
struct wined3d_bo b
Definition: wined3d_vk.h:310
struct wined3d_buffer b
Definition: wined3d_vk.h:920
struct wined3d_view_vk view_vk
Definition: wined3d_vk.h:997
struct wined3d_shader_resource_view v
Definition: wined3d_vk.h:996
enum VkImageLayout layout
Definition: wined3d_vk.h:878
@ VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
Definition: vulkan.h:3456
@ VK_IMAGE_LAYOUT_GENERAL
Definition: vulkan.h:3452
@ VK_IMAGE_USAGE_SAMPLED_BIT
Definition: vulkan.h:3512

Referenced by wined3d_shader_resource_view_vk_init().

◆ wined3d_shader_resource_view_vk_generate_mipmap()

void wined3d_shader_resource_view_vk_generate_mipmap ( struct wined3d_shader_resource_view_vk *  srv_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 1382 of file view.c.

1384{
1385 unsigned int i, j, layer_count, level_count, base_level, base_layer, sub_resource_idx;
1386 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
1387 VkImageSubresourceRange vk_src_range, vk_dst_range;
1388 struct wined3d_texture_vk *texture_vk;
1389 VkCommandBuffer vk_command_buffer;
1391
1392 TRACE("srv_vk %p.\n", srv_vk);
1393
1394 layer_count = srv_vk->v.desc.u.texture.layer_count;
1395 level_count = srv_vk->v.desc.u.texture.level_count;
1396 base_level = srv_vk->v.desc.u.texture.level_idx;
1397 base_layer = srv_vk->v.desc.u.texture.layer_idx;
1398
1399 texture_vk = wined3d_texture_vk(texture_from_resource(srv_vk->v.resource));
1400 for (i = 0; i < layer_count; ++i)
1401 {
1402 sub_resource_idx = (base_layer + i) * texture_vk->t.level_count + base_level;
1403 if (!wined3d_texture_load_location(&texture_vk->t, sub_resource_idx,
1404 &context_vk->c, WINED3D_LOCATION_TEXTURE_RGB))
1405 ERR("Failed to load source layer %u.\n", base_layer + i);
1406 }
1407
1408 if (context_vk->c.d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL)
1409 FIXME("Unhandled sRGB read/write control.\n");
1410
1411 if (wined3d_format_vk(srv_vk->v.format)->vk_format != wined3d_format_vk(texture_vk->t.resource.format)->vk_format)
1412 FIXME("Ignoring view format %s.\n", debug_d3dformat(srv_vk->v.format->id));
1413
1414 if (wined3d_resource_get_sample_count(&texture_vk->t.resource) > 1)
1415 FIXME("Unhandled multi-sampled resource.\n");
1416
1417 if (!(vk_command_buffer = wined3d_context_vk_get_command_buffer(context_vk)))
1418 {
1419 ERR("Failed to get command buffer.\n");
1420 return;
1421 }
1422
1423 vk_src_range.aspectMask = vk_aspect_mask_from_format(texture_vk->t.resource.format);
1424 vk_src_range.baseMipLevel = base_level;
1425 vk_src_range.levelCount = 1;
1426 vk_src_range.baseArrayLayer = base_layer;
1427 vk_src_range.layerCount = layer_count;
1428
1429 vk_dst_range = vk_src_range;
1430 ++vk_dst_range.baseMipLevel;
1431
1432 wined3d_context_vk_image_barrier(context_vk, vk_command_buffer,
1434 vk_access_mask_from_bind_flags(texture_vk->t.resource.bind_flags),
1437 texture_vk->image.vk_image, &vk_src_range);
1438 wined3d_context_vk_image_barrier(context_vk, vk_command_buffer,
1440 vk_access_mask_from_bind_flags(texture_vk->t.resource.bind_flags),
1443 texture_vk->image.vk_image, &vk_dst_range);
1444
1445 region.srcSubresource.aspectMask = vk_src_range.aspectMask;
1446 region.srcSubresource.mipLevel = vk_src_range.baseMipLevel;
1447 region.srcSubresource.baseArrayLayer = vk_src_range.baseArrayLayer;
1448 region.srcSubresource.layerCount = vk_src_range.layerCount;
1449 region.srcOffsets[0].x = 0;
1450 region.srcOffsets[0].y = 0;
1451 region.srcOffsets[0].z = 0;
1452
1453 region.dstSubresource.aspectMask = vk_dst_range.aspectMask;
1454 region.dstSubresource.mipLevel = vk_dst_range.baseMipLevel;
1455 region.dstSubresource.baseArrayLayer = vk_dst_range.baseArrayLayer;
1456 region.dstSubresource.layerCount = vk_dst_range.layerCount;
1457 region.dstOffsets[0].x = 0;
1458 region.dstOffsets[0].y = 0;
1459 region.dstOffsets[0].z = 0;
1460
1461 for (i = 1; i < level_count; ++i)
1462 {
1463 region.srcOffsets[1].x = wined3d_texture_get_level_width(&texture_vk->t, vk_src_range.baseMipLevel);
1464 region.srcOffsets[1].y = wined3d_texture_get_level_height(&texture_vk->t, vk_src_range.baseMipLevel);
1465 region.srcOffsets[1].z = wined3d_texture_get_level_depth(&texture_vk->t, vk_src_range.baseMipLevel);
1466
1467 region.dstOffsets[1].x = wined3d_texture_get_level_width(&texture_vk->t, vk_dst_range.baseMipLevel);
1468 region.dstOffsets[1].y = wined3d_texture_get_level_height(&texture_vk->t, vk_dst_range.baseMipLevel);
1469 region.dstOffsets[1].z = wined3d_texture_get_level_depth(&texture_vk->t, vk_dst_range.baseMipLevel);
1470
1471 VK_CALL(vkCmdBlitImage(vk_command_buffer, texture_vk->image.vk_image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
1473
1474 wined3d_context_vk_image_barrier(context_vk, vk_command_buffer,
1477 vk_access_mask_from_bind_flags(texture_vk->t.resource.bind_flags),
1479 texture_vk->image.vk_image, &vk_src_range);
1480
1481 if (i == level_count - 1)
1482 {
1483 wined3d_context_vk_image_barrier(context_vk, vk_command_buffer,
1486 vk_access_mask_from_bind_flags(texture_vk->t.resource.bind_flags),
1488 texture_vk->image.vk_image, &vk_dst_range);
1489 }
1490 else
1491 {
1492 region.srcSubresource.mipLevel = ++vk_src_range.baseMipLevel;
1493 region.dstSubresource.mipLevel = ++vk_dst_range.baseMipLevel;
1494
1495 wined3d_context_vk_image_barrier(context_vk, vk_command_buffer,
1499 texture_vk->image.vk_image, &vk_src_range);
1500 wined3d_context_vk_image_barrier(context_vk, vk_command_buffer,
1502 vk_access_mask_from_bind_flags(texture_vk->t.resource.bind_flags),
1505 texture_vk->image.vk_image, &vk_dst_range);
1506 }
1507 }
1508
1509 for (i = 0; i < layer_count; ++i)
1510 {
1511 for (j = 1; j < level_count; ++j)
1512 {
1513 sub_resource_idx = (base_layer + i) * texture_vk->t.level_count + base_level + j;
1514 wined3d_texture_validate_location(&texture_vk->t, sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB);
1515 wined3d_texture_invalidate_location(&texture_vk->t, sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB);
1516 }
1517 }
1518
1519 wined3d_context_vk_reference_texture(context_vk, texture_vk);
1520}
VkCommandBuffer wined3d_context_vk_get_command_buffer(struct wined3d_context_vk *context_vk)
Definition: context_vk.c:1805
void wined3d_context_vk_image_barrier(struct wined3d_context_vk *context_vk, VkCommandBuffer vk_command_buffer, VkPipelineStageFlags src_stage_mask, VkPipelineStageFlags dst_stage_mask, VkAccessFlags src_access_mask, VkAccessFlags dst_access_mask, VkImageLayout old_layout, VkImageLayout new_layout, VkImage image, const VkImageSubresourceRange *range)
Definition: context_vk.c:2022
VkAccessFlags vk_access_mask_from_bind_flags(uint32_t bind_flags)
Definition: resource.c:526
unsigned int wined3d_resource_get_sample_count(const struct wined3d_resource *resource)
Definition: resource.c:456
uint32_t baseArrayLayer
Definition: vulkan.h:9076
VkImageAspectFlags aspectMask
Definition: vulkan.h:9073
VkFormat vk_format
Definition: wined3d_vk.h:1083
struct wined3d_image_vk image
Definition: wined3d_vk.h:877
@ VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL
Definition: vulkan.h:3457
@ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
Definition: vulkan.h:3458
void VKAPI_CALL vkCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit *pRegions, VkFilter filter)
@ VK_FILTER_LINEAR
Definition: vulkan.h:2808
@ VK_ACCESS_TRANSFER_WRITE_BIT
Definition: vulkan.h:1641
@ VK_ACCESS_TRANSFER_READ_BIT
Definition: vulkan.h:1640
@ VK_PIPELINE_STAGE_ALL_COMMANDS_BIT
Definition: vulkan.h:4288
@ VK_PIPELINE_STAGE_TRANSFER_BIT
Definition: vulkan.h:4284
static VkImageAspectFlags vk_aspect_mask_from_format(const struct wined3d_format *format)
Definition: wined3d_vk.h:294
static void wined3d_context_vk_reference_texture(const struct wined3d_context_vk *context_vk, struct wined3d_texture_vk *texture_vk)
Definition: wined3d_vk.h:1103

Referenced by adapter_vk_generate_mipmap().

◆ wined3d_shader_resource_view_vk_init()

HRESULT wined3d_shader_resource_view_vk_init ( struct wined3d_shader_resource_view_vk *  view_vk,
const struct wined3d_view_desc *  desc,
struct wined3d_resource *  resource,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)

Definition at line 1243 of file view.c.

1246{
1247 HRESULT hr;
1248
1249 TRACE("view_vk %p, desc %s, resource %p, parent %p, parent_ops %p.\n",
1250 view_vk, wined3d_debug_view_desc(desc, resource), resource, parent, parent_ops);
1251
1252 if (FAILED(hr = wined3d_shader_resource_view_init(&view_vk->v, desc, resource, parent, parent_ops)))
1253 return hr;
1254
1255 list_init(&view_vk->view_vk.bo_user.entry);
1257
1258 return hr;
1259}
static void wined3d_shader_resource_view_vk_cs_init(void *object)
Definition: view.c:1167

Referenced by adapter_vk_create_shader_resource_view().

◆ wined3d_shader_resource_view_vk_update_buffer()

void wined3d_shader_resource_view_vk_update_buffer ( struct wined3d_shader_resource_view_vk *  srv_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 1139 of file view.c.

1141{
1142 const struct wined3d_format_vk *view_format_vk = wined3d_format_vk(srv_vk->v.format);
1143 const struct wined3d_view_desc *desc = &srv_vk->v.desc;
1144 struct wined3d_resource *resource = srv_vk->v.resource;
1145 struct wined3d_view_vk *view_vk = &srv_vk->view_vk;
1146 struct wined3d_buffer_vk *buffer_vk;
1147 VkBufferView vk_buffer_view;
1148
1149 assert(!view_vk->bo_user.valid);
1150
1153 if ((vk_buffer_view = wined3d_view_vk_create_vk_buffer_view(context_vk, desc, buffer_vk, view_format_vk)))
1154 {
1155 view_vk->u.vk_buffer_view = vk_buffer_view;
1156 view_vk->bo_user.valid = true;
1157 list_add_head(&buffer_vk->b.buffer_object->users, &view_vk->bo_user.entry);
1158 }
1159}
void wined3d_context_vk_destroy_vk_buffer_view(struct wined3d_context_vk *context_vk, VkBufferView vk_view, uint64_t command_buffer_id)
Definition: context_vk.c:931
struct wined3d_bo_user bo_user
Definition: wined3d_vk.h:985
VkBufferView vk_buffer_view
Definition: wined3d_vk.h:988
union wined3d_view_vk::@365 u
uint64_t command_buffer_id
Definition: wined3d_vk.h:991

Referenced by wined3d_context_vk_load_shader_resources().

◆ wined3d_shader_resource_view_vk_update_layout()

void wined3d_shader_resource_view_vk_update_layout ( struct wined3d_shader_resource_view_vk *  srv_vk,
VkImageLayout  layout 
)

Definition at line 1161 of file view.c.

1163{
1164 srv_vk->view_vk.u.vk_image_info.imageLayout = layout;
1165}

Referenced by wined3d_shader_descriptor_writes_vk_add_srv_write().

◆ wined3d_unordered_access_view_cleanup()

void wined3d_unordered_access_view_cleanup ( struct wined3d_unordered_access_view *  view)

Definition at line 1531 of file view.c.

1532{
1533 view->parent_ops->wined3d_object_destroyed(view->parent);
1534}

Referenced by adapter_gl_destroy_unordered_access_view(), and adapter_vk_destroy_unordered_access_view().

◆ wined3d_unordered_access_view_copy_counter()

void wined3d_unordered_access_view_copy_counter ( struct wined3d_unordered_access_view *  view,
struct wined3d_buffer *  buffer,
unsigned int  offset,
struct wined3d_context *  context 
)

Definition at line 1739 of file view.c.

1741{
1743
1744 if (!view->counter_bo)
1745 return;
1746
1747 src.buffer_object = view->counter_bo;
1748 src.addr = NULL;
1749
1751}
void wined3d_buffer_copy_bo_address(struct wined3d_buffer *dst_buffer, struct wined3d_context *context, unsigned int dst_offset, const struct wined3d_const_bo_address *src_addr, unsigned int size)
Definition: buffer.c:785
GLenum src
Definition: glext.h:6340
struct wined3d_bo * buffer_object

Referenced by wined3d_cs_exec_copy_uav_counter().

◆ wined3d_unordered_access_view_create()

HRESULT CDECL wined3d_unordered_access_view_create ( const struct wined3d_view_desc *  desc,
struct wined3d_resource *  resource,
void *  parent,
const struct wined3d_parent_ops *  parent_ops,
struct wined3d_unordered_access_view **  view 
)

Definition at line 2551 of file view.c.

2554{
2555 const struct wined3d_adapter_ops *adapter_ops;
2556
2557 TRACE("desc %s, resource %p, parent %p, parent_ops %p, view %p.\n",
2559
2560 adapter_ops = resource->device->adapter->adapter_ops;
2561 return adapter_ops->adapter_create_unordered_access_view(desc, resource, parent, parent_ops, view);
2562}
HRESULT(* adapter_create_unordered_access_view)(const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_unordered_access_view **view)

Referenced by d3d11_unordered_access_view_init().

◆ wined3d_unordered_access_view_decref()

ULONG CDECL wined3d_unordered_access_view_decref ( struct wined3d_unordered_access_view *  view)

Definition at line 1536 of file view.c.

1537{
1538 unsigned int refcount = InterlockedDecrement(&view->refcount);
1539
1540 TRACE("%p decreasing refcount to %u.\n", view, refcount);
1541
1542 if (!refcount)
1543 {
1544 struct wined3d_resource *resource = view->resource;
1545
1546 /* Release the resource after destroying the view.
1547 * See wined3d_shader_resource_view_decref(). */
1549 resource->device->adapter->adapter_ops->adapter_destroy_unordered_access_view(view);
1552 }
1553
1554 return refcount;
1555}

Referenced by d3d11_unordered_access_view_Release(), state_unbind_resources(), wined3d_cs_packet_decref_objects(), and wined3d_device_context_set_unordered_access_views().

◆ wined3d_unordered_access_view_get_parent()

void *CDECL wined3d_unordered_access_view_get_parent ( const struct wined3d_unordered_access_view *  view)

Definition at line 1557 of file view.c.

1558{
1559 TRACE("view %p.\n", view);
1560
1561 return view->parent;
1562}

Referenced by d3d11_device_context_CSGetUnorderedAccessViews(), and d3d11_device_context_OMGetRenderTargetsAndUnorderedAccessViews().

◆ wined3d_unordered_access_view_gl_clear()

void wined3d_unordered_access_view_gl_clear ( struct wined3d_unordered_access_view_gl *  view_gl,
const struct wined3d_uvec4 *  clear_value,
struct wined3d_context_gl *  context_gl,
bool  fp 
)

Definition at line 1570 of file view.c.

1572{
1573 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
1574 const struct wined3d_format_gl *format_gl;
1575 struct wined3d_resource *resource;
1576 struct wined3d_buffer *buffer;
1577 struct wined3d_bo_gl *bo_gl;
1578 unsigned int offset, size;
1579
1580 resource = view_gl->v.resource;
1581 if (resource->type != WINED3D_RTYPE_BUFFER)
1582 {
1583 unsigned int layer_count, level_count, base_level, base_layer;
1584 unsigned int sub_resource_idx, width, height, depth, i, j;
1585 struct wined3d_texture_gl *texture_gl;
1586 const void *data = clear_value;
1587 GLenum gl_format, gl_type;
1589
1590 if (!gl_info->supported[ARB_CLEAR_TEXTURE])
1591 {
1592 FIXME("OpenGL implementation does not support ARB_clear_texture.\n");
1593 return;
1594 }
1595
1596 format_gl = wined3d_format_gl(resource->format);
1598 level_count = view_gl->v.desc.u.texture.level_count;
1599 base_level = view_gl->v.desc.u.texture.level_idx;
1600
1602 {
1603 layer_count = 1;
1604 base_layer = 0;
1605 }
1606 else
1607 {
1608 layer_count = view_gl->v.desc.u.texture.layer_count;
1609 base_layer = view_gl->v.desc.u.texture.layer_idx;
1610 }
1611
1612 if (format_gl->f.byte_count <= 4 && !fp)
1613 {
1614 gl_format = format_gl->format;
1615 gl_type = format_gl->type;
1616 packed = wined3d_format_pack(&format_gl->f, clear_value);
1617 data = &packed;
1618 }
1619 else if (resource->format_attrs & WINED3D_FORMAT_ATTR_INTEGER)
1620 {
1621 gl_format = GL_RGBA_INTEGER;
1622 gl_type = GL_UNSIGNED_INT;
1623 }
1624 else
1625 {
1626 gl_format = GL_RGBA;
1627 gl_type = GL_FLOAT;
1628 }
1629
1630 for (i = 0; i < layer_count; ++i)
1631 {
1632 for (j = 0; j < level_count; ++j)
1633 {
1634 sub_resource_idx = (base_layer + i) * texture_gl->t.level_count + base_level + j;
1635 wined3d_texture_prepare_location(&texture_gl->t, sub_resource_idx,
1636 &context_gl->c, WINED3D_LOCATION_TEXTURE_RGB);
1637
1638 width = wined3d_texture_get_level_width(&texture_gl->t, base_level + j);
1639 height = wined3d_texture_get_level_height(&texture_gl->t, base_level + j);
1640 depth = wined3d_texture_get_level_depth(&texture_gl->t, base_level + j);
1641
1642 switch (texture_gl->target)
1643 {
1645 GL_EXTCALL(glClearTexSubImage(texture_gl->texture_rgb.name, base_level + j,
1646 0, base_layer + i, 0, width, 1, 1, gl_format, gl_type, data));
1647 break;
1648
1653 GL_EXTCALL(glClearTexSubImage(texture_gl->texture_rgb.name, base_level + j,
1654 0, 0, base_layer + i, width, height, 1, gl_format, gl_type, data));
1655 break;
1656
1657 default:
1658 GL_EXTCALL(glClearTexSubImage(texture_gl->texture_rgb.name, base_level + j,
1659 0, 0, 0, width, height, depth, gl_format, gl_type, data));
1660 break;
1661 }
1662
1663 wined3d_texture_validate_location(&texture_gl->t, sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB);
1664 wined3d_texture_invalidate_location(&texture_gl->t, sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB);
1665 }
1666 }
1667
1668 return;
1669 }
1670
1671 if (!gl_info->supported[ARB_CLEAR_BUFFER_OBJECT])
1672 {
1673 FIXME("OpenGL implementation does not support ARB_clear_buffer_object.\n");
1674 return;
1675 }
1676
1677 format_gl = wined3d_format_gl(view_gl->v.format);
1678 if (format_gl->f.id != WINED3DFMT_R32_UINT && format_gl->f.id != WINED3DFMT_R32_SINT
1679 && format_gl->f.id != WINED3DFMT_R32G32B32A32_UINT
1680 && format_gl->f.id != WINED3DFMT_R32G32B32A32_SINT)
1681 {
1682 FIXME("Not implemented for format %s.\n", debug_d3dformat(format_gl->f.id));
1683 return;
1684 }
1685
1686 if (fp)
1687 {
1688 FIXME("Floating-point buffer clears not implemented.\n");
1689 return;
1690 }
1691
1693 get_buffer_view_range(buffer, &view_gl->v.desc, &format_gl->f, &offset, &size);
1694
1695 if (!offset && size == buffer->resource.size)
1696 {
1698 }
1699 else
1700 {
1703 }
1705
1706 bo_gl = wined3d_bo_gl(buffer->buffer_object);
1707 wined3d_context_gl_bind_bo(context_gl, bo_gl->binding, bo_gl->id);
1708 GL_EXTCALL(glClearBufferSubData(bo_gl->binding, format_gl->internal,
1709 bo_gl->b.buffer_offset + offset, size, format_gl->format, format_gl->type, clear_value));
1710 wined3d_context_gl_reference_bo(context_gl, bo_gl);
1711 checkGLcall("clear unordered access view");
1712}
void wined3d_context_gl_bind_bo(struct wined3d_context_gl *context_gl, GLenum binding, GLuint name)
Definition: context_gl.c:2497
BOOL wined3d_buffer_prepare_location(struct wined3d_buffer *buffer, struct wined3d_context *context, unsigned int location)
Definition: buffer.c:257
void wined3d_buffer_acquire_bo_for_write(struct wined3d_buffer *buffer, struct wined3d_context *context)
Definition: buffer.c:750
uint32_t wined3d_format_pack(const struct wined3d_format *format, const struct wined3d_uvec4 *value)
Definition: utils.c:5778
void wined3d_unordered_access_view_invalidate_location(struct wined3d_unordered_access_view *view, uint32_t location)
Definition: view.c:1564
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
#define GL_UNSIGNED_INT
Definition: gl.h:182
#define GL_FLOAT
Definition: gl.h:183
#define GL_RGBA
Definition: gl.h:503
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define GL_RGBA_INTEGER
Definition: glext.h:575
GLuint GLenum GLsizei GLsizei GLint GLint GLboolean packed
Definition: glext.h:9271
GLenum binding
Definition: wined3d_gl.h:422
struct wined3d_format f
Definition: wined3d_gl.h:1142
struct wined3d_unordered_access_view v
Definition: wined3d_gl.h:1104
@ WINED3DFMT_R32_SINT
Definition: wined3d.h:200
@ WINED3DFMT_R32G32B32A32_UINT
Definition: wined3d.h:158
@ WINED3DFMT_R32G32B32A32_SINT
Definition: wined3d.h:159
@ ARB_CLEAR_TEXTURE
Definition: wined3d_gl.h:57
@ ARB_CLEAR_BUFFER_OBJECT
Definition: wined3d_gl.h:56
static void wined3d_context_gl_reference_bo(struct wined3d_context_gl *context_gl, struct wined3d_bo_gl *bo_gl)
Definition: wined3d_gl.h:912
#define WINED3D_FORMAT_ATTR_INTEGER

Referenced by adapter_gl_clear_uav().

◆ wined3d_unordered_access_view_gl_cs_init()

static void wined3d_unordered_access_view_gl_cs_init ( void *  object)
static

Definition at line 1764 of file view.c.

1765{
1766 struct wined3d_unordered_access_view_gl *view_gl = object;
1767 struct wined3d_resource *resource = view_gl->v.resource;
1768 struct wined3d_view_desc *desc = &view_gl->v.desc;
1769 const struct wined3d_gl_info *gl_info;
1770
1771 TRACE("view_gl %p.\n", view_gl);
1772
1773 gl_info = &wined3d_adapter_gl(resource->device->adapter)->gl_info;
1774
1775 if (resource->type == WINED3D_RTYPE_BUFFER)
1776 {
1777 struct wined3d_device_gl *device_gl = wined3d_device_gl(resource->device);
1779 struct wined3d_context_gl *context_gl;
1780
1781 context_gl = wined3d_context_gl(context_acquire(&device_gl->d, NULL, 0));
1782 create_buffer_view(&view_gl->gl_view, &context_gl->c, desc, buffer, view_gl->v.format);
1783 view_gl->bo_user.valid = true;
1784 list_add_head(&buffer->buffer_object->users, &view_gl->bo_user.entry);
1786 {
1787 struct wined3d_bo_gl *bo = &view_gl->counter_bo;
1788
1789 view_gl->v.counter_bo = &bo->b;
1790 wined3d_device_gl_create_bo(device_gl, context_gl, sizeof(uint32_t), GL_ATOMIC_COUNTER_BUFFER,
1793 }
1794 context_release(&context_gl->c);
1795 }
1796 else
1797 {
1799 unsigned int depth_or_layer_count;
1800
1802 depth_or_layer_count = wined3d_texture_get_level_depth(&texture_gl->t, desc->u.texture.level_idx);
1803 else
1804 depth_or_layer_count = texture_gl->t.layer_count;
1805
1806 if (desc->u.texture.layer_idx || desc->u.texture.layer_count != depth_or_layer_count)
1807 {
1808 create_texture_view(&view_gl->gl_view, get_texture_view_target(gl_info, desc, texture_gl),
1809 desc, texture_gl, view_gl->v.format);
1810 }
1811 }
1812}
bool wined3d_device_gl_create_bo(struct wined3d_device_gl *device_gl, struct wined3d_context_gl *context_gl, GLsizeiptr size, GLenum binding, GLenum usage, bool coherent, GLbitfield flags, struct wined3d_bo_gl *bo)
Definition: device.c:1335
void wined3d_unordered_access_view_set_counter(struct wined3d_unordered_access_view *view, unsigned int value)
Definition: view.c:1714
#define GL_MAP_READ_BIT
Definition: glext.h:1793
#define GL_ATOMIC_COUNTER_BUFFER
Definition: glext.h:2297
#define GL_MAP_WRITE_BIT
Definition: glext.h:1794
#define GL_STATIC_DRAW
Definition: glext.h:350
struct wined3d_device d
Definition: wined3d_gl.h:847
struct wined3d_bo_gl counter_bo
Definition: wined3d_gl.h:1107
struct wined3d_bo_user bo_user
Definition: wined3d_gl.h:1105
struct wined3d_gl_view gl_view
Definition: wined3d_gl.h:1106
#define GL_CLIENT_STORAGE_BIT
Definition: wgl.h:399

Referenced by wined3d_unordered_access_view_gl_init().

◆ wined3d_unordered_access_view_gl_init()

HRESULT wined3d_unordered_access_view_gl_init ( struct wined3d_unordered_access_view_gl *  view_gl,
const struct wined3d_view_desc *  desc,
struct wined3d_resource *  resource,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)

Definition at line 1833 of file view.c.

1836{
1837 HRESULT hr;
1838
1839 TRACE("view_gl %p, desc %s, resource %p, parent %p, parent_ops %p.\n",
1840 view_gl, wined3d_debug_view_desc(desc, resource), resource, parent, parent_ops);
1841
1842 if (FAILED(hr = wined3d_unordered_access_view_init(&view_gl->v, desc, resource, parent, parent_ops)))
1843 return hr;
1844
1845 list_init(&view_gl->bo_user.entry);
1847
1848 return hr;
1849}
static HRESULT wined3d_unordered_access_view_init(struct wined3d_unordered_access_view *view, const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops)
Definition: view.c:1814
static void wined3d_unordered_access_view_gl_cs_init(void *object)
Definition: view.c:1764

Referenced by adapter_gl_create_unordered_access_view().

◆ wined3d_unordered_access_view_gl_update()

void wined3d_unordered_access_view_gl_update ( struct wined3d_unordered_access_view_gl *  uav_gl,
struct wined3d_context_gl *  context_gl 
)

Definition at line 1753 of file view.c.

1755{
1756 struct wined3d_buffer *buffer = buffer_from_resource(uav_gl->v.resource);
1757
1758 assert(!uav_gl->bo_user.valid);
1759 create_buffer_view(&uav_gl->gl_view, &context_gl->c, &uav_gl->v.desc, buffer, uav_gl->v.format);
1760 uav_gl->bo_user.valid = true;
1761 list_add_head(&buffer->buffer_object->users, &uav_gl->bo_user.entry);
1762}

Referenced by context_gl_load_unordered_access_resources().

◆ wined3d_unordered_access_view_incref()

ULONG CDECL wined3d_unordered_access_view_incref ( struct wined3d_unordered_access_view *  view)

Definition at line 1522 of file view.c.

1523{
1524 unsigned int refcount = InterlockedIncrement(&view->refcount);
1525
1526 TRACE("%p increasing refcount to %u.\n", view, refcount);
1527
1528 return refcount;
1529}

Referenced by d3d11_unordered_access_view_AddRef(), wined3d_cs_packet_incref_objects(), and wined3d_device_context_set_unordered_access_views().

◆ wined3d_unordered_access_view_init()

static HRESULT wined3d_unordered_access_view_init ( struct wined3d_unordered_access_view *  view,
const struct wined3d_view_desc *  desc,
struct wined3d_resource *  resource,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)
static

Definition at line 1814 of file view.c.

1817{
1818 view->refcount = 1;
1819 view->parent = parent;
1820 view->parent_ops = parent_ops;
1821
1822 if (!(resource->bind_flags & WINED3D_BIND_UNORDERED_ACCESS))
1823 return E_INVALIDARG;
1824 if (!(view->format = validate_resource_view(desc, resource, TRUE, FALSE)))
1825 return E_INVALIDARG;
1826 view->desc = *desc;
1827
1829
1830 return WINED3D_OK;
1831}
#define WINED3D_BIND_UNORDERED_ACCESS
Definition: wined3d.h:916

Referenced by wined3d_unordered_access_view_gl_init(), and wined3d_unordered_access_view_vk_init().

◆ wined3d_unordered_access_view_invalidate_location()

void wined3d_unordered_access_view_invalidate_location ( struct wined3d_unordered_access_view *  view,
uint32_t  location 
)

◆ wined3d_unordered_access_view_set_counter()

void wined3d_unordered_access_view_set_counter ( struct wined3d_unordered_access_view *  view,
unsigned int  value 
)

Definition at line 1714 of file view.c.

1716{
1717 struct wined3d_bo_address dst, src;
1718 struct wined3d_context *context;
1719 struct wined3d_range range;
1720
1721 if (!view->counter_bo)
1722 return;
1723
1724 context = context_acquire(view->resource->device, NULL, 0);
1725
1726 src.buffer_object = 0;
1727 src.addr = (void *)&value;
1728
1729 dst.buffer_object = view->counter_bo;
1730 dst.addr = NULL;
1731
1732 range.offset = 0;
1733 range.size = sizeof(value);
1735
1737}
range
Definition: d3dx9_private.h:58
GLenum GLenum dst
Definition: glext.h:6340
Definition: pdh_main.c:64
#define WINED3D_MAP_DISCARD
Definition: wined3d.h:953
#define WINED3D_MAP_WRITE
Definition: wined3d.h:956
static void wined3d_context_copy_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, unsigned int range_count, const struct wined3d_range *ranges, uint32_t map_flags)

Referenced by wined3d_cs_exec_set_unordered_access_views(), and wined3d_unordered_access_view_gl_cs_init().

◆ wined3d_unordered_access_view_vk_clear()

void wined3d_unordered_access_view_vk_clear ( struct wined3d_unordered_access_view_vk *  view_vk,
const struct wined3d_uvec4 *  clear_value,
struct wined3d_context_vk *  context_vk,
bool  fp 
)

Definition at line 2077 of file view.c.

2079{
2080 struct wined3d_bo_address cb_source_address, cb_destination_address;
2081 const struct wined3d_format *view_format = view_vk->v.format;
2082 struct wined3d_view_desc *view_desc = &view_vk->v.desc;
2084 struct wined3d_device *device = context_vk->c.device;
2085 struct wined3d_shader_thread_group_size group_count;
2086 enum wined3d_format_id format_id = view_format->id;
2088 struct wined3d_texture_vk *texture_vk = NULL;
2089 struct wined3d_pipeline_layout_vk *layout;
2091 const struct wined3d_vk_info *vk_info;
2092 VkDescriptorImageInfo vk_image_info;
2093 struct wined3d_device_vk *device_vk;
2094 VkDescriptorBufferInfo buffer_info;
2095 struct wined3d_resource *resource;
2096 VkCommandBuffer vk_command_buffer;
2097 struct wined3d_bo_vk constants_bo;
2098 VkWriteDescriptorSet vk_writes[2];
2099 VkBufferView vk_buffer_view;
2100 struct wined3d_range range;
2101 VkMemoryBarrier vk_barrier;
2102 VkPipeline vk_pipeline;
2103 bool is_array;
2104
2105 device_vk = wined3d_device_vk(device);
2106 state = &device_vk->uav_clear_state;
2107 pipelines = fp ? &state->float_pipelines : &state->uint_pipelines;
2108
2109 resource = view_vk->v.resource;
2111
2112 switch (resource->type)
2113 {
2115 vk_pipeline = pipelines->buffer;
2116 group_count = state->buffer_group_size;
2117 break;
2119 if (is_array)
2120 {
2121 vk_pipeline = pipelines->image_1d_array;
2122 group_count = state->image_1d_array_group_size;
2123 }
2124 else
2125 {
2126 vk_pipeline = pipelines->image_1d;
2127 group_count = state->image_1d_group_size;
2128 }
2129 break;
2131 if (is_array)
2132 {
2133 vk_pipeline = pipelines->image_2d_array;
2134 group_count = state->image_2d_array_group_size;
2135 }
2136 else
2137 {
2138 vk_pipeline = pipelines->image_2d;
2139 group_count = state->image_2d_group_size;
2140 }
2141 break;
2143 vk_pipeline = pipelines->image_3d;
2144 group_count = state->image_3d_group_size;
2145 break;
2146
2147 default:
2148 ERR("Unhandled resource type %s.\n", debug_d3dresourcetype(resource->type));
2149 return;
2150 }
2151
2152 if (vk_pipeline == VK_NULL_HANDLE)
2153 {
2154 ERR("Pipeline was not correctly initialized.\n");
2155 return;
2156 }
2157
2158 vk_writes[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
2159 vk_writes[0].pNext = NULL;
2160 vk_writes[0].dstBinding = 1;
2161 vk_writes[0].dstArrayElement = 0;
2162 vk_writes[0].descriptorCount = 1;
2163 vk_writes[0].pImageInfo = NULL;
2164 vk_writes[0].pTexelBufferView = &vk_buffer_view;
2165 vk_writes[0].pImageInfo = &vk_image_info;
2166
2167 if (resource->type == WINED3D_RTYPE_BUFFER)
2168 {
2170 unsigned int offset, size;
2171
2172 layout = state->buffer_layout;
2173 vk_writes[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER;
2174
2175 if (buffer->structure_byte_stride)
2176 constants.extent.width = view_desc->u.buffer.count * buffer->structure_byte_stride / 4;
2177 else
2178 constants.extent.width = view_desc->u.buffer.count;
2179 constants.extent.height = 1;
2180
2181 get_buffer_view_range(buffer, view_desc, view_format, &offset, &size);
2182 if (!offset && size == buffer->resource.size)
2183 {
2185 }
2186 else
2187 {
2190 }
2193 }
2194 else
2195 {
2196 unsigned int layer_count, level_count, base_level, base_layer, i, j;
2197
2199
2200 layout = state->image_layout;
2201 vk_writes[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
2202
2203 level_count = view_desc->u.texture.level_count;
2204 base_level = view_desc->u.texture.level_idx;
2206 {
2207 layer_count = 1;
2208 base_layer = 0;
2209 }
2210 else
2211 {
2212 layer_count = view_desc->u.texture.layer_count;
2213 base_layer = view_desc->u.texture.layer_idx;
2214 }
2215
2216 constants.extent.width = wined3d_texture_get_level_width(&texture_vk->t, base_level);
2217 constants.extent.height = wined3d_texture_get_level_height(&texture_vk->t, base_level);
2218 group_count.z = (view_desc->u.texture.layer_count + group_count.z - 1) / group_count.z;
2219
2220 for (i = 0; i < layer_count; ++i)
2221 {
2222 for (j = 0; j < level_count; ++j)
2223 {
2224 unsigned int sub_resource_idx = (base_layer + i) * texture_vk->t.level_count + base_level + j;
2225
2226 wined3d_texture_prepare_location(&texture_vk->t, sub_resource_idx,
2227 &context_vk->c, WINED3D_LOCATION_TEXTURE_RGB);
2228 wined3d_texture_validate_location(&texture_vk->t, sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB);
2229 wined3d_texture_invalidate_location(&texture_vk->t, sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB);
2230 }
2231 }
2232 }
2233
2234 group_count.x = (constants.extent.width + group_count.x - 1) / group_count.x;
2235 group_count.y = (constants.extent.height + group_count.y - 1) / group_count.y;
2236
2237 constants.color.uint32[0] = clear_value->x;
2238 constants.color.uint32[1] = clear_value->y;
2239 constants.color.uint32[2] = clear_value->z;
2240 constants.color.uint32[3] = clear_value->w;
2241
2242 if (!fp)
2243 {
2244 /* Make sure values are truncated, not saturated to some maximum value. */
2245 constants.color.uint32[0] &= wined3d_mask_from_size(view_format->red_size);
2246 constants.color.uint32[1] &= wined3d_mask_from_size(view_format->green_size);
2247 constants.color.uint32[2] &= wined3d_mask_from_size(view_format->blue_size);
2248 constants.color.uint32[3] &= wined3d_mask_from_size(view_format->alpha_size);
2249
2250 if (view_format->id == WINED3DFMT_R11G11B10_FLOAT)
2251 {
2252 constants.color.uint32[0] |= constants.color.uint32[1] << 11;
2253 constants.color.uint32[0] |= constants.color.uint32[2] << 22;
2255 }
2256 else
2257 {
2258 format_id = wined3d_get_typed_format_id(context_vk->c.device->adapter, view_format,
2260 }
2261 }
2262
2264 {
2265 ERR("Unsupported format %s.\n", debug_d3dformat(view_format->id));
2266 return;
2267 }
2268
2269 if (resource->type == WINED3D_RTYPE_BUFFER)
2270 {
2271 if (format_id == view_format->id)
2272 vk_buffer_view = view_vk->view_vk.u.vk_buffer_view;
2273 else
2274 {
2275 vk_buffer_view = wined3d_view_vk_create_vk_buffer_view(context_vk, view_desc,
2277 wined3d_get_format(context_vk->c.device->adapter, format_id, WINED3D_BIND_UNORDERED_ACCESS)));
2278 if (vk_buffer_view == VK_NULL_HANDLE)
2279 return;
2280 }
2281 }
2282 else
2283 {
2284 if (format_id == view_format->id)
2285 {
2286 vk_image_info = view_vk->view_vk.u.vk_image_info;
2287 if (!vk_image_info.imageView)
2288 {
2290 if (!(default_info = wined3d_texture_vk_get_default_image_info(texture_vk, context_vk)))
2291 return;
2292 vk_image_info = *default_info;
2293 }
2294 }
2295 else
2296 {
2297 vk_image_info.sampler = VK_NULL_HANDLE;
2298 vk_image_info.imageLayout = texture_vk->layout;
2299 vk_image_info.imageView = wined3d_view_vk_create_vk_image_view(context_vk, view_desc, texture_vk,
2300 wined3d_format_vk(wined3d_get_format(context_vk->c.device->adapter, format_id,
2303
2304 if (vk_image_info.imageView == VK_NULL_HANDLE)
2305 return;
2306 }
2307 }
2308
2309 vk_writes[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
2310 vk_writes[1].pNext = NULL;
2311 vk_writes[1].dstBinding = 0;
2312 vk_writes[1].dstArrayElement = 0;
2313 vk_writes[1].descriptorCount = 1;
2314 vk_writes[1].pImageInfo = NULL;
2315 vk_writes[1].pTexelBufferView = NULL;
2316 vk_writes[1].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
2317 vk_writes[1].pBufferInfo = &buffer_info;
2318
2321 {
2322 ERR("Failed to create constants BO.\n");
2323 goto out;
2324 }
2325
2326 cb_source_address.buffer_object = NULL;
2327 cb_source_address.addr = (BYTE *)&constants;
2328 cb_destination_address.buffer_object = &constants_bo.b;
2329 cb_destination_address.addr = 0;
2330
2331 range.offset = 0;
2332 range.size = sizeof(constants);
2333 adapter_vk_copy_bo_address(&context_vk->c, &cb_destination_address,
2334 &cb_source_address, 1, &range, WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD);
2335
2336 buffer_info.buffer = constants_bo.vk_buffer;
2337 buffer_info.range = constants_bo.size;
2338 buffer_info.offset = constants_bo.b.buffer_offset;
2339
2340 vk_info = context_vk->vk_info;
2341
2342 if (!(vk_writes[0].dstSet = wined3d_context_vk_create_vk_descriptor_set(context_vk, layout->vk_set_layout)))
2343 {
2344 ERR("Failed to create descriptor set.\n");
2345 wined3d_context_vk_destroy_bo(context_vk, &constants_bo);
2346 goto out;
2347 }
2348
2349 vk_writes[1].dstSet = vk_writes[0].dstSet;
2350
2351 VK_CALL(vkUpdateDescriptorSets(device_vk->vk_device, 2, vk_writes, 0, NULL));
2352
2353 vk_command_buffer = wined3d_context_vk_get_command_buffer(context_vk);
2355
2357 wined3d_context_vk_reference_bo(context_vk, &constants_bo);
2358 wined3d_context_vk_destroy_bo(context_vk, &constants_bo);
2359
2360 vk_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER;
2361 vk_barrier.pNext = NULL;
2362 vk_barrier.srcAccessMask = vk_access_mask_from_bind_flags(resource->bind_flags);
2363 vk_barrier.dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT;
2364
2365 VK_CALL(vkCmdPipelineBarrier(vk_command_buffer,
2368 0, 1, &vk_barrier, 0, NULL, 0, NULL));
2369 VK_CALL(vkCmdBindPipeline(vk_command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, vk_pipeline));
2371 layout->vk_pipeline_layout, 0, 1, &vk_writes[0].dstSet, 0, NULL));
2372 VK_CALL(vkCmdDispatch(vk_command_buffer, group_count.x, group_count.y, group_count.z));
2373
2374 vk_barrier.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT;
2375 vk_barrier.dstAccessMask = vk_access_mask_from_bind_flags(resource->bind_flags);
2376
2377 VK_CALL(vkCmdPipelineBarrier(vk_command_buffer,
2380 0, 1, &vk_barrier, 0, NULL, 0, NULL));
2381
2383
2384out:
2385 if (format_id != view_format->id)
2386 {
2387 if (resource->type == WINED3D_RTYPE_BUFFER)
2388 wined3d_context_vk_destroy_vk_buffer_view(context_vk, vk_buffer_view, view_vk->view_vk.command_buffer_id);
2389 else
2390 wined3d_context_vk_destroy_vk_image_view(context_vk, vk_image_info.imageView,
2391 view_vk->view_vk.command_buffer_id);
2392 }
2393}
void adapter_vk_copy_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, unsigned int range_count, const struct wined3d_range *ranges, uint32_t map_flags)
Definition: adapter_vk.c:1020
BOOL wined3d_context_vk_create_bo(struct wined3d_context_vk *context_vk, VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags memory_type, struct wined3d_bo_vk *bo)
Definition: context_vk.c:528
void wined3d_context_vk_end_current_render_pass(struct wined3d_context_vk *context_vk)
Definition: context_vk.c:1564
VkDescriptorSet wined3d_context_vk_create_vk_descriptor_set(struct wined3d_context_vk *context_vk, VkDescriptorSetLayout vk_set_layout)
Definition: context_vk.c:3048
void wined3d_context_vk_destroy_vk_image_view(struct wined3d_context_vk *context_vk, VkImageView vk_view, uint64_t command_buffer_id)
Definition: context_vk.c:956
void wined3d_context_vk_destroy_bo(struct wined3d_context_vk *context_vk, const struct wined3d_bo_vk *bo)
Definition: context_vk.c:1106
void wined3d_buffer_invalidate_location(struct wined3d_buffer *buffer, uint32_t location)
Definition: buffer.c:131
void wined3d_buffer_validate_location(struct wined3d_buffer *buffer, uint32_t location)
Definition: buffer.c:102
VkPipelineStageFlags vk_pipeline_stage_mask_from_bind_flags(uint32_t bind_flags)
Definition: resource.c:552
const VkDescriptorImageInfo * wined3d_texture_vk_get_default_image_info(struct wined3d_texture_vk *texture_vk, struct wined3d_context_vk *context_vk)
Definition: texture.c:4601
enum wined3d_format_id wined3d_get_typed_format_id(const struct wined3d_adapter *adapter, const struct wined3d_format *format, enum wined3d_channel_type channel_type)
Definition: utils.c:4460
static struct @1920 default_info
const GLuint * pipelines
Definition: glext.h:7624
constants
Definition: resource.c:30
static UINT format_id
Definition: clipboard.c:1455
for(i=0;i< sizeof(testsuite)/sizeof(testsuite[0]);++i) ok(call_test(testsuite[i].func)
static int is_array(const type_t *t)
Definition: header.h:60
VkImageLayout imageLayout
Definition: vulkan.h:8266
Definition: devices.h:37
VkDescriptorSetLayout vk_set_layout
Definition: wined3d_vk.h:522
struct wined3d_unordered_access_view v
Definition: wined3d_vk.h:1024
struct wined3d_view_vk view_vk
Definition: wined3d_vk.h:1025
unsigned int y
Definition: wined3d.h:1660
unsigned int x
Definition: wined3d.h:1659
unsigned int w
Definition: wined3d.h:1662
unsigned int z
Definition: wined3d.h:1661
struct wined3d_view_desc::@4822::@4823 buffer
unsigned int flags
Definition: wined3d.h:2131
struct wined3d_view_desc::@4822::@4824 texture
union wined3d_view_desc::@4822 u
@ VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
Definition: vulkan.h:3771
void VKAPI_CALL vkCmdBindDescriptorSets(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t descriptorSetCount, const VkDescriptorSet *pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t *pDynamicOffsets)
@ VK_PIPELINE_BIND_POINT_COMPUTE
Definition: vulkan.h:4069
@ VK_IMAGE_USAGE_STORAGE_BIT
Definition: vulkan.h:3513
void VKAPI_CALL vkCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline)
@ VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT
Definition: vulkan.h:1919
void VKAPI_CALL vkCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ)
@ VK_ACCESS_SHADER_WRITE_BIT
Definition: vulkan.h:1635
void VKAPI_CALL vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet *pDescriptorCopies)
@ VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT
Definition: vulkan.h:4283
void VKAPI_CALL vkCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier *pImageMemoryBarriers)
@ VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET
Definition: vulkan.h:4999
@ VK_STRUCTURE_TYPE_MEMORY_BARRIER
Definition: vulkan.h:5010
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
wined3d_format_id
Definition: wined3d.h:126
@ WINED3DFMT_R11G11B10_FLOAT
Definition: wined3d.h:183
@ WINED3D_CHANNEL_TYPE_UINT
#define STATE_COMPUTE_SHADER
static uint32_t wined3d_mask_from_size(unsigned int size)
static void wined3d_context_vk_reference_unordered_access_view(const struct wined3d_context_vk *context_vk, struct wined3d_unordered_access_view_vk *uav_vk)
Definition: wined3d_vk.h:1144
static void wined3d_context_vk_reference_bo(const struct wined3d_context_vk *context_vk, struct wined3d_bo_vk *bo)
Definition: wined3d_vk.h:1091
unsigned char BYTE
Definition: xxhash.c:193

Referenced by adapter_vk_clear_uav().

◆ wined3d_unordered_access_view_vk_cs_init()

static void wined3d_unordered_access_view_vk_cs_init ( void *  object)
static

Definition at line 2417 of file view.c.

2418{
2420 struct wined3d_view_vk *view_vk = &uav_vk->view_vk;
2421 struct wined3d_view_desc *desc = &uav_vk->v.desc;
2422 const struct wined3d_format_vk *format_vk;
2423 const struct wined3d_vk_info *vk_info;
2424 struct wined3d_texture_vk *texture_vk;
2425 struct wined3d_context_vk *context_vk;
2426 struct wined3d_device_vk *device_vk;
2427 struct wined3d_buffer_vk *buffer_vk;
2428 VkBufferViewCreateInfo create_info;
2429 struct wined3d_resource *resource;
2430 VkBufferView vk_buffer_view;
2432 VkImageView vk_image_view;
2433 VkResult vr;
2434
2435 TRACE("uav_vk %p.\n", uav_vk);
2436
2437 resource = uav_vk->v.resource;
2438 device_vk = wined3d_device_vk(resource->device);
2439 format_vk = wined3d_format_vk(uav_vk->v.format);
2440
2441 if (resource->type == WINED3D_RTYPE_BUFFER)
2442 {
2444
2445 context_vk = wined3d_context_vk(context_acquire(&device_vk->d, NULL, 0));
2446 vk_info = context_vk->vk_info;
2447
2448 if ((vk_buffer_view = wined3d_view_vk_create_vk_buffer_view(context_vk, desc, buffer_vk, format_vk)))
2449 {
2450 struct wined3d_bo_vk *bo = wined3d_bo_vk(buffer_vk->b.buffer_object);
2451
2452 TRACE("Created buffer view 0x%s.\n", wine_dbgstr_longlong(vk_buffer_view));
2453
2454 uav_vk->view_vk.u.vk_buffer_view = vk_buffer_view;
2455 uav_vk->view_vk.bo_user.valid = true;
2456 list_add_head(&bo->b.users, &view_vk->bo_user.entry);
2457 }
2458
2460 {
2464 {
2465 ERR("Failed to create counter bo.\n");
2466 context_release(&context_vk->c);
2467
2468 return;
2469 }
2470
2473 uav_vk->counter_bo.vk_buffer, uav_vk->counter_bo.b.buffer_offset, sizeof(uint32_t), 0));
2474 wined3d_context_vk_reference_bo(context_vk, &uav_vk->counter_bo);
2475
2477 create_info.pNext = NULL;
2478 create_info.flags = 0;
2479 create_info.buffer = uav_vk->counter_bo.vk_buffer;
2480 create_info.format = VK_FORMAT_R32_UINT;
2481 create_info.offset = uav_vk->counter_bo.b.buffer_offset;
2482 create_info.range = sizeof(uint32_t);
2483 if ((vr = VK_CALL(vkCreateBufferView(device_vk->vk_device,
2484 &create_info, NULL, &uav_vk->vk_counter_view))) < 0)
2485 {
2486 ERR("Failed to create counter buffer view, vr %s.\n", wined3d_debug_vkresult(vr));
2487 }
2488 else
2489 {
2490 TRACE("Created counter buffer view 0x%s.\n", wine_dbgstr_longlong(uav_vk->vk_counter_view));
2491
2492 uav_vk->v.counter_bo = &uav_vk->counter_bo.b;
2493 }
2494 }
2495
2496 context_release(&context_vk->c);
2497
2498 return;
2499 }
2500
2502
2503 if (texture_vk->t.layer_count > 1)
2505
2506 if (resource->format->id == format_vk->f.id && desc->flags == default_flags
2507 && !desc->u.texture.level_idx && desc->u.texture.level_count == texture_vk->t.level_count
2508 && !desc->u.texture.layer_idx && desc->u.texture.layer_count == texture_vk->t.layer_count
2510 {
2511 TRACE("Creating identity unordered access view.\n");
2512 return;
2513 }
2514
2515 if (texture_vk->t.swapchain && texture_vk->t.swapchain->state.desc.backbuffer_count > 1)
2516 FIXME("Swapchain unordered access views not supported.\n");
2517
2518 context_vk = wined3d_context_vk(context_acquire(&device_vk->d, NULL, 0));
2519 vk_image_view = wined3d_view_vk_create_vk_image_view(context_vk, desc,
2520 texture_vk, format_vk, format_vk->f.color_fixup, false, VK_IMAGE_USAGE_STORAGE_BIT);
2521 context_release(&context_vk->c);
2522
2523 if (!vk_image_view)
2524 return;
2525
2526 TRACE("Created image view 0x%s.\n", wine_dbgstr_longlong(vk_image_view));
2527
2528 view_vk->u.vk_image_info.imageView = vk_image_view;
2529 view_vk->u.vk_image_info.sampler = VK_NULL_HANDLE;
2530 view_vk->u.vk_image_info.imageLayout = texture_vk->layout;
2531}
#define uint32_t
Definition: nsiface.idl:61
const void * pNext
Definition: vulkan.h:7684
VkBufferViewCreateFlags flags
Definition: vulkan.h:7685
VkStructureType sType
Definition: vulkan.h:7683
struct wined3d_device d
Definition: wined3d_vk.h:821
struct wined3d_bo_vk counter_bo
Definition: wined3d_vk.h:1028
VkDescriptorImageInfo vk_image_info
Definition: wined3d_vk.h:989
@ VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
Definition: vulkan.h:3770
@ VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT
Definition: vulkan.h:1918
@ VK_BUFFER_USAGE_TRANSFER_DST_BIT
Definition: vulkan.h:1916
@ VK_BUFFER_USAGE_TRANSFER_SRC_BIT
Definition: vulkan.h:1915
VkResult VKAPI_CALL vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkBufferView *pView)
@ VK_FORMAT_R32_UINT
Definition: vulkan.h:2914
void VKAPI_CALL vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data)
@ VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO
Definition: vulkan.h:4977

Referenced by wined3d_unordered_access_view_vk_init().

◆ wined3d_unordered_access_view_vk_init()

HRESULT wined3d_unordered_access_view_vk_init ( struct wined3d_unordered_access_view_vk *  view_vk,
const struct wined3d_view_desc *  desc,
struct wined3d_resource *  resource,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)

Definition at line 2533 of file view.c.

2536{
2537 HRESULT hr;
2538
2539 TRACE("view_vk %p, desc %s, resource %p, parent %p, parent_ops %p.\n",
2540 view_vk, wined3d_debug_view_desc(desc, resource), resource, parent, parent_ops);
2541
2542 if (FAILED(hr = wined3d_unordered_access_view_init(&view_vk->v, desc, resource, parent, parent_ops)))
2543 return hr;
2544
2545 list_init(&view_vk->view_vk.bo_user.entry);
2547
2548 return hr;
2549}
static void wined3d_unordered_access_view_vk_cs_init(void *object)
Definition: view.c:2417

Referenced by adapter_vk_create_unordered_access_view().

◆ wined3d_unordered_access_view_vk_update()

void wined3d_unordered_access_view_vk_update ( struct wined3d_unordered_access_view_vk *  uav_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 2395 of file view.c.

2397{
2398 const struct wined3d_format_vk *view_format_vk = wined3d_format_vk(uav_vk->v.format);
2399 const struct wined3d_view_desc *desc = &uav_vk->v.desc;
2400 struct wined3d_resource *resource = uav_vk->v.resource;
2401 struct wined3d_view_vk *view_vk = &uav_vk->view_vk;
2402 struct wined3d_buffer_vk *buffer_vk;
2403 VkBufferView vk_buffer_view;
2404
2405 assert(!view_vk->bo_user.valid);
2406
2409 if ((vk_buffer_view = wined3d_view_vk_create_vk_buffer_view(context_vk, desc, buffer_vk, view_format_vk)))
2410 {
2411 view_vk->u.vk_buffer_view = vk_buffer_view;
2412 view_vk->bo_user.valid = true;
2413 list_add_head(&buffer_vk->b.buffer_object->users, &view_vk->bo_user.entry);
2414 }
2415}

Referenced by wined3d_context_vk_load_shader_resources().

◆ wined3d_view_invalidate_location()

static void wined3d_view_invalidate_location ( struct wined3d_resource *  resource,
const struct wined3d_view_desc *  desc,
DWORD  location 
)
static

Definition at line 317 of file view.c.

319{
320 unsigned int i, sub_resource_idx;
321 struct wined3d_texture *texture;
322
323 if (resource->type == WINED3D_RTYPE_BUFFER)
324 {
326 return;
327 }
328
331 {
333 return;
334 }
335
336 sub_resource_idx = desc->u.texture.layer_idx * texture->level_count + desc->u.texture.level_idx;
337 for (i = 0; i < desc->u.texture.layer_count; ++i, sub_resource_idx += texture->level_count)
339}

Referenced by wined3d_rendertarget_view_invalidate_location(), and wined3d_unordered_access_view_invalidate_location().

◆ wined3d_view_load_location()

static void wined3d_view_load_location ( struct wined3d_resource *  resource,
const struct wined3d_view_desc *  desc,
struct wined3d_context *  context,
DWORD  location 
)
static

Definition at line 341 of file view.c.

343{
344 unsigned int i, sub_resource_idx;
345 struct wined3d_texture *texture;
346
347 if (resource->type == WINED3D_RTYPE_BUFFER)
348 {
350 return;
351 }
352
355 {
357 return;
358 }
359
360 sub_resource_idx = desc->u.texture.layer_idx * texture->level_count + desc->u.texture.level_idx;
361 for (i = 0; i < desc->u.texture.layer_count; ++i, sub_resource_idx += texture->level_count)
363}

Referenced by wined3d_rendertarget_view_load_location().

◆ wined3d_view_vk_create_vk_buffer_view()

static VkBufferView wined3d_view_vk_create_vk_buffer_view ( struct wined3d_context_vk *  context_vk,
const struct wined3d_view_desc *  desc,
struct wined3d_buffer_vk *  buffer_vk,
const struct wined3d_format_vk *  view_format_vk 
)
static

Definition at line 708 of file view.c.

711{
712 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
713 VkBufferViewCreateInfo create_info;
714 struct wined3d_device_vk *device_vk;
715 VkBufferView vk_buffer_view;
716 unsigned int offset, size;
717 struct wined3d_bo_vk *bo;
718 VkResult vr;
719
720 get_buffer_view_range(&buffer_vk->b, desc, &view_format_vk->f, &offset, &size);
722 bo = wined3d_bo_vk(buffer_vk->b.buffer_object);
723
725 create_info.pNext = NULL;
726 create_info.flags = 0;
727 create_info.buffer = bo->vk_buffer;
728 create_info.format = view_format_vk->vk_format;
729 create_info.offset = bo->b.buffer_offset + offset;
730 create_info.range = size;
731
732 device_vk = wined3d_device_vk(buffer_vk->b.resource.device);
733 if ((vr = VK_CALL(vkCreateBufferView(device_vk->vk_device, &create_info, NULL, &vk_buffer_view))) < 0)
734 {
735 ERR("Failed to create buffer view, vr %s.\n", wined3d_debug_vkresult(vr));
736 return VK_NULL_HANDLE;
737 }
738
739 return vk_buffer_view;
740}
VkBuffer vk_buffer
Definition: wined3d_vk.h:312

Referenced by wined3d_shader_resource_view_vk_cs_init(), wined3d_shader_resource_view_vk_update_buffer(), wined3d_unordered_access_view_vk_clear(), wined3d_unordered_access_view_vk_cs_init(), and wined3d_unordered_access_view_vk_update().

◆ wined3d_view_vk_create_vk_image_view()

static VkImageView wined3d_view_vk_create_vk_image_view ( struct wined3d_context_vk *  context_vk,
const struct wined3d_view_desc *  desc,
struct wined3d_texture_vk *  texture_vk,
const struct wined3d_format_vk *  view_format_vk,
struct color_fixup_desc  fixup,
bool  rtv,
VkImageUsageFlags  usage 
)
static

Definition at line 742 of file view.c.

746{
747 const struct wined3d_resource *resource = &texture_vk->t.resource;
748 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
749 const struct wined3d_format_vk *format_vk;
751 struct wined3d_device_vk *device_vk;
752 VkImageViewCreateInfo create_info;
753 VkImageView vk_image_view;
754 VkResult vr;
755
756 device_vk = wined3d_device_vk(resource->device);
757
759 {
760 ERR("Failed to prepare texture.\n");
761 return VK_NULL_HANDLE;
762 }
763
764 /* Depth formats are a little complicated. For example, the typeless
765 * format corresponding to depth/stencil view format WINED3DFMT_D32_FLOAT
766 * is WINED3DFMT_R32_TYPELESS, and the corresponding shader resource view
767 * format would be WINED3DFMT_R32_FLOAT. Vulkan depth/stencil formats are
768 * only compatible with themselves, so it's not possible to create e.g. a
769 * VK_FORMAT_R32_SFLOAT view on a VK_FORMAT_D32_SFLOAT image. In order to
770 * make it work, we create Vulkan images for WINED3DFMT_R32_TYPELESS
771 * resources with either a depth format (VK_FORMAT_D32_SFLOAT) or a colour
772 * format, depending on whether the bind flags include
773 * WINED3D_BIND_DEPTH_STENCIL or not. In order to then create a Vulkan
774 * view on the image, we then replace the view format here with the
775 * underlying resource format. However, that means it's still not possible
776 * to create e.g. a WINED3DFMT_R32_UINT view on a WINED3DFMT_R32_TYPELESS
777 * depth/stencil resource. */
778 if (resource->bind_flags & WINED3D_BIND_DEPTH_STENCIL)
779 format_vk = wined3d_format_vk(resource->format);
780 else
781 format_vk = view_format_vk;
782
784 create_info.pNext = NULL;
785 create_info.flags = 0;
786 create_info.image = texture_vk->image.vk_image;
787 create_info.viewType = vk_image_view_type_from_wined3d(resource->type, desc->flags);
788 if (rtv && create_info.viewType == VK_IMAGE_VIEW_TYPE_3D)
789 {
790 if (desc->u.texture.layer_count > 1)
792 else
793 create_info.viewType = VK_IMAGE_VIEW_TYPE_2D;
794 }
795 create_info.format = format_vk->vk_format;
796 if (is_stencil_view_format(&view_format_vk->f))
797 {
799 create_info.components.g = VK_COMPONENT_SWIZZLE_R;
802 }
803 else if (is_identity_fixup(fixup) || !can_use_texture_swizzle(context_vk->c.d3d_info, &format_vk->f))
804 {
809 }
810 else
811 {
813 }
814 if ((resource->bind_flags & WINED3D_BIND_DEPTH_STENCIL)
815 && (view_format_vk->f.red_size || view_format_vk->f.green_size))
816 {
817 create_info.subresourceRange.aspectMask = 0;
818 if (view_format_vk->f.red_size)
820 if (view_format_vk->f.green_size)
822 }
823 else
824 {
825 create_info.subresourceRange.aspectMask = vk_aspect_mask_from_format(&format_vk->f);
826 }
827 create_info.subresourceRange.baseMipLevel = desc->u.texture.level_idx;
828 create_info.subresourceRange.levelCount = desc->u.texture.level_count;
829 if (create_info.viewType == VK_IMAGE_VIEW_TYPE_3D)
830 {
831 if (desc->u.texture.layer_idx || (desc->u.texture.layer_count != texture_vk->t.resource.depth
832 && desc->u.texture.layer_count != ~0u))
833 WARN("Partial 3D texture views are not supported.\n");
834 create_info.subresourceRange.baseArrayLayer = 0;
835 create_info.subresourceRange.layerCount = 1;
836 }
837 else
838 {
839 create_info.subresourceRange.baseArrayLayer = desc->u.texture.layer_idx;
840 create_info.subresourceRange.layerCount = desc->u.texture.layer_count;
841 }
842 if (vk_info->supported[WINED3D_VK_KHR_MAINTENANCE2] || vk_info->api_version >= VK_API_VERSION_1_1)
843 {
845 usage_info.pNext = NULL;
846 usage_info.usage = usage;
847 create_info.pNext = &usage_info;
848 }
849 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &create_info, NULL, &vk_image_view))) < 0)
850 {
851 ERR("Failed to create Vulkan image view, vr %s.\n", wined3d_debug_vkresult(vr));
852 return VK_NULL_HANDLE;
853 }
854
855 return vk_image_view;
856}
void wined3d_vk_swizzle_from_color_fixup(VkComponentMapping *mapping, struct color_fixup_desc fixup)
Definition: texture.c:4583
BOOL wined3d_texture_vk_prepare_texture(struct wined3d_texture_vk *texture_vk, struct wined3d_context_vk *context_vk)
Definition: texture.c:5244
VkImageViewType vk_image_view_type_from_wined3d(enum wined3d_resource_type type, uint32_t flags)
Definition: view.c:676
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
VkComponentSwizzle r
Definition: vulkan.h:7880
VkComponentSwizzle a
Definition: vulkan.h:7883
VkComponentSwizzle g
Definition: vulkan.h:7881
VkComponentSwizzle b
Definition: vulkan.h:7882
VkImageSubresourceRange subresourceRange
Definition: vulkan.h:9118
VkComponentMapping components
Definition: vulkan.h:9117
VkImageViewType viewType
Definition: vulkan.h:9115
VkStructureType sType
Definition: vulkan.h:9111
const void * pNext
Definition: vulkan.h:9112
VkImageViewCreateFlags flags
Definition: vulkan.h:9113
VkImageUsageFlags usage
Definition: vulkan.h:9149
VkStructureType sType
Definition: vulkan.h:9147
@ VK_IMAGE_ASPECT_STENCIL_BIT
Definition: vulkan.h:3367
@ VK_IMAGE_ASPECT_DEPTH_BIT
Definition: vulkan.h:3366
@ VK_COMPONENT_SWIZZLE_IDENTITY
Definition: vulkan.h:2188
@ VK_COMPONENT_SWIZZLE_R
Definition: vulkan.h:2191
@ VK_COMPONENT_SWIZZLE_ZERO
Definition: vulkan.h:2189
VkResult VKAPI_CALL vkCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImageView *pView)
#define VK_API_VERSION_1_1
Definition: vulkan.h:843
@ VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO_KHR
Definition: vulkan.h:5896
@ VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
Definition: vulkan.h:4979
@ WINED3D_VK_KHR_MAINTENANCE2
Definition: wined3d_vk.h:247

Referenced by wined3d_render_target_view_vk_cs_init(), wined3d_shader_resource_view_vk_cs_init(), wined3d_unordered_access_view_vk_clear(), and wined3d_unordered_access_view_vk_cs_init().