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

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d)
 
ULONG CDECL wined3d_sampler_incref (struct wined3d_sampler *sampler)
 
ULONG CDECL wined3d_sampler_decref (struct wined3d_sampler *sampler)
 
void *CDECL wined3d_sampler_get_parent (const struct wined3d_sampler *sampler)
 
static void wined3d_sampler_init (struct wined3d_sampler *sampler, struct wined3d_device *device, const struct wined3d_sampler_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
 
static void wined3d_sampler_gl_cs_init (void *object)
 
void wined3d_sampler_gl_init (struct wined3d_sampler_gl *sampler_gl, struct wined3d_device *device, const struct wined3d_sampler_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
 
static VkFilter vk_filter_from_wined3d (enum wined3d_texture_filter_type f)
 
static VkSamplerMipmapMode vk_mipmap_mode_from_wined3d (enum wined3d_texture_filter_type f)
 
static VkSamplerAddressMode vk_address_mode_from_wined3d (enum wined3d_texture_address a)
 
static VkBorderColor vk_border_colour_from_wined3d (const struct wined3d_color *colour)
 
static void wined3d_sampler_vk_cs_init (void *object)
 
void wined3d_sampler_vk_init (struct wined3d_sampler_vk *sampler_vk, struct wined3d_device *device, const struct wined3d_sampler_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
 
HRESULT CDECL wined3d_sampler_create (struct wined3d_device *device, const struct wined3d_sampler_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_sampler **sampler)
 
static void texture_gl_apply_base_level (struct wined3d_texture_gl *texture_gl, const struct wined3d_sampler_desc *desc, const struct wined3d_gl_info *gl_info)
 
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)
 

Function Documentation

◆ texture_gl_apply_base_level()

static void texture_gl_apply_base_level ( struct wined3d_texture_gl *  texture_gl,
const struct wined3d_sampler_desc *  desc,
const struct wined3d_gl_info *  gl_info 
)
static

Definition at line 306 of file sampler.c.

308{
309 struct gl_texture *gl_tex;
310
311 gl_tex = wined3d_texture_gl_get_gl_texture(texture_gl, texture_gl->t.flags & WINED3D_TEXTURE_IS_SRGB);
312 if (desc->mip_base_level != gl_tex->sampler_desc.mip_base_level)
313 {
314 gl_info->gl_ops.gl.p_glTexParameteri(texture_gl->target, GL_TEXTURE_BASE_LEVEL, desc->mip_base_level);
315 gl_tex->sampler_desc.mip_base_level = desc->mip_base_level;
316 }
317}
#define GL_TEXTURE_BASE_LEVEL
Definition: gl.h:1503
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
struct wined3d_sampler_desc sampler_desc
Definition: wined3d_gl.h:928
struct opengl_funcs gl_ops
Definition: wined3d_gl.h:353
struct wined3d_texture t
Definition: wined3d_gl.h:941
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_TEXTURE_IS_SRGB

Referenced by wined3d_sampler_gl_bind().

◆ vk_address_mode_from_wined3d()

static VkSamplerAddressMode vk_address_mode_from_wined3d ( enum wined3d_texture_address  a)
static

Definition at line 169 of file sampler.c.

170{
171 switch (a)
172 {
173 default:
174 ERR("Invalid address mode %#x.\n", a);
185 }
186}
#define ERR(fmt,...)
Definition: precomp.h:57
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
@ VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT
Definition: vulkan.h:4714
@ VK_SAMPLER_ADDRESS_MODE_REPEAT
Definition: vulkan.h:4713
@ VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE
Definition: vulkan.h:4715
@ VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE
Definition: vulkan.h:4717
@ VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER
Definition: vulkan.h:4716
@ WINED3D_TADDRESS_BORDER
Definition: wined3d.h:661
@ WINED3D_TADDRESS_MIRROR_ONCE
Definition: wined3d.h:662
@ WINED3D_TADDRESS_WRAP
Definition: wined3d.h:658
@ WINED3D_TADDRESS_MIRROR
Definition: wined3d.h:659
@ WINED3D_TADDRESS_CLAMP
Definition: wined3d.h:660

Referenced by wined3d_sampler_vk_cs_init().

◆ vk_border_colour_from_wined3d()

static VkBorderColor vk_border_colour_from_wined3d ( const struct wined3d_color *  colour)
static

Definition at line 188 of file sampler.c.

189{
190 unsigned int i;
191
192 static const struct
193 {
194 struct wined3d_color wined3d_colour;
195 VkBorderColor vk_colour;
196 }
197 colours[] =
198 {
199 {{0.0f, 0.0f, 0.0f, 0.0f}, VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK},
200 {{0.0f, 0.0f, 0.0f, 1.0f}, VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK},
201 {{1.0f, 1.0f, 1.0f, 1.0f}, VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE},
202 };
203
204 for (i = 0; i < ARRAY_SIZE(colours); ++i)
205 {
206 if (!memcmp(&colours[i], colour, sizeof(*colour)))
207 return colours[i].vk_colour;
208 }
209
210 FIXME("Unhandled border colour {%.8e, %.8e, %.8e, %.8e}.\n", colour->r, colour->g, colour->b, colour->a);
211
213}
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FIXME(fmt,...)
Definition: precomp.h:53
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
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
VkBorderColor
Definition: vulkan.h:1887
@ VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE
Definition: vulkan.h:1892
@ VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK
Definition: vulkan.h:1888
@ VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK
Definition: vulkan.h:1890

Referenced by wined3d_sampler_vk_cs_init().

◆ vk_filter_from_wined3d()

static VkFilter vk_filter_from_wined3d ( enum wined3d_texture_filter_type  f)
static

Definition at line 142 of file sampler.c.

143{
144 switch (f)
145 {
146 default:
147 ERR("Invalid filter type %#x.\n", f);
149 return VK_FILTER_NEAREST;
151 return VK_FILTER_LINEAR;
152 }
153}
GLfloat f
Definition: glext.h:7540
@ VK_FILTER_NEAREST
Definition: vulkan.h:2807
@ VK_FILTER_LINEAR
Definition: vulkan.h:2808
@ WINED3D_TEXF_POINT
Definition: wined3d.h:706
@ WINED3D_TEXF_LINEAR
Definition: wined3d.h:707

Referenced by wined3d_sampler_vk_cs_init().

◆ vk_mipmap_mode_from_wined3d()

static VkSamplerMipmapMode vk_mipmap_mode_from_wined3d ( enum wined3d_texture_filter_type  f)
static

Definition at line 155 of file sampler.c.

156{
157 switch (f)
158 {
159 default:
160 ERR("Invalid filter type %#x.\n", f);
166 }
167}
@ VK_SAMPLER_MIPMAP_MODE_NEAREST
Definition: vulkan.h:4734
@ VK_SAMPLER_MIPMAP_MODE_LINEAR
Definition: vulkan.h:4735
@ WINED3D_TEXF_NONE
Definition: wined3d.h:705

Referenced by wined3d_sampler_vk_cs_init().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3d  )

◆ wined3d_sampler_create()

HRESULT CDECL wined3d_sampler_create ( struct wined3d_device *  device,
const struct wined3d_sampler_desc *  desc,
void *  parent,
const struct wined3d_parent_ops *  parent_ops,
struct wined3d_sampler **  sampler 
)

Definition at line 287 of file sampler.c.

289{
290 TRACE("device %p, desc %p, parent %p, parent_ops %p, sampler %p.\n",
291 device, desc, parent, parent_ops, sampler);
292
293 if (desc->address_u < WINED3D_TADDRESS_WRAP || desc->address_u > WINED3D_TADDRESS_MIRROR_ONCE
294 || desc->address_v < WINED3D_TADDRESS_WRAP || desc->address_v > WINED3D_TADDRESS_MIRROR_ONCE
295 || desc->address_w < WINED3D_TADDRESS_WRAP || desc->address_w > WINED3D_TADDRESS_MIRROR_ONCE)
297
298 if (desc->mag_filter < WINED3D_TEXF_POINT || desc->mag_filter > WINED3D_TEXF_LINEAR
299 || desc->min_filter < WINED3D_TEXF_POINT || desc->min_filter > WINED3D_TEXF_LINEAR
300 || desc->mip_filter > WINED3D_TEXF_LINEAR)
302
303 return device->adapter->adapter_ops->adapter_create_sampler(device, desc, parent, parent_ops, sampler);
304}
r parent
Definition: btrfs.c:3010
GLuint sampler
Definition: glext.h:7283
#define TRACE(s)
Definition: solgame.cpp:4
Definition: devices.h:37
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:44

Referenced by d3d_sampler_state_init(), wined3d_device_apply_stateblock(), and wined3d_device_create_default_samplers().

◆ wined3d_sampler_decref()

ULONG CDECL wined3d_sampler_decref ( struct wined3d_sampler *  sampler)

Definition at line 35 of file sampler.c.

36{
37 unsigned int refcount = wined3d_atomic_decrement_mutex_lock(&sampler->refcount);
38
39 TRACE("%p decreasing refcount to %u.\n", sampler, refcount);
40
41 if (!refcount)
42 {
43 sampler->parent_ops->wined3d_object_destroyed(sampler->parent);
44 sampler->device->adapter->adapter_ops->adapter_destroy_sampler(sampler);
46 }
47
48 return refcount;
49}
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:544
static ULONG wined3d_atomic_decrement_mutex_lock(volatile LONG *refcount)

Referenced by d3d11_sampler_state_Release(), device_free_sampler(), state_unbind_resources(), wined3d_cs_packet_decref_objects(), wined3d_device_apply_stateblock(), wined3d_device_context_set_samplers(), and wined3d_device_destroy_default_samplers().

◆ wined3d_sampler_get_parent()

◆ wined3d_sampler_gl_bind()

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 at line 320 of file sampler.c.

322{
323 const struct wined3d_gl_info *gl_info = context_gl->gl_info;
324
325 if (gl_info->supported[ARB_SAMPLER_OBJECTS])
326 {
327 GL_EXTCALL(glBindSampler(unit, sampler_gl->name));
328 checkGLcall("bind sampler");
329 }
330 else if (texture_gl)
331 {
332 wined3d_texture_gl_apply_sampler_desc(texture_gl, &sampler_gl->s.desc, context_gl);
333 }
334 else
335 {
336 ERR("Could not apply sampler state.\n");
337 }
338
339 if (texture_gl)
340 texture_gl_apply_base_level(texture_gl, &sampler_gl->s.desc, gl_info);
341}
void wined3d_texture_gl_apply_sampler_desc(struct wined3d_texture_gl *texture_gl, const struct wined3d_sampler_desc *sampler_desc, const struct wined3d_context_gl *context_gl)
Definition: texture.c:1418
png_const_structrp png_const_inforp int * unit
Definition: png.h:2392
static void texture_gl_apply_base_level(struct wined3d_texture_gl *texture_gl, const struct wined3d_sampler_desc *desc, const struct wined3d_gl_info *gl_info)
Definition: sampler.c:306
const struct wined3d_gl_info * gl_info
Definition: wined3d_gl.h:603
BOOL supported[WINED3D_GL_EXT_COUNT]
Definition: wined3d_gl.h:347
struct wined3d_sampler s
Definition: wined3d_gl.h:1029
@ ARB_SAMPLER_OBJECTS
Definition: wined3d_gl.h:106
#define GL_EXTCALL(f)
Definition: wined3d_gl.h:360
#define checkGLcall(A)
Definition: wined3d_gl.h:402

Referenced by wined3d_shader_resource_view_gl_bind().

◆ wined3d_sampler_gl_cs_init()

static void wined3d_sampler_gl_cs_init ( void *  object)
static

Definition at line 84 of file sampler.c.

85{
86 struct wined3d_sampler_gl *sampler_gl = object;
87 const struct wined3d_sampler_desc *desc;
88 const struct wined3d_gl_info *gl_info;
91
92 TRACE("sampler_gl %p.\n", sampler_gl);
93
94 context = context_acquire(sampler_gl->s.device, NULL, 0);
96
97 desc = &sampler_gl->s.desc;
98 GL_EXTCALL(glGenSamplers(1, &name));
99 GL_EXTCALL(glSamplerParameteri(name, GL_TEXTURE_WRAP_S,
100 gl_info->wrap_lookup[desc->address_u - WINED3D_TADDRESS_WRAP]));
101 GL_EXTCALL(glSamplerParameteri(name, GL_TEXTURE_WRAP_T,
102 gl_info->wrap_lookup[desc->address_v - WINED3D_TADDRESS_WRAP]));
103 GL_EXTCALL(glSamplerParameteri(name, GL_TEXTURE_WRAP_R,
104 gl_info->wrap_lookup[desc->address_w - WINED3D_TADDRESS_WRAP]));
105 GL_EXTCALL(glSamplerParameterfv(name, GL_TEXTURE_BORDER_COLOR, &desc->border_color[0]));
106 GL_EXTCALL(glSamplerParameteri(name, GL_TEXTURE_MAG_FILTER,
107 wined3d_gl_mag_filter(desc->mag_filter)));
108 GL_EXTCALL(glSamplerParameteri(name, GL_TEXTURE_MIN_FILTER,
109 wined3d_gl_min_mip_filter(desc->min_filter, desc->mip_filter)));
110 GL_EXTCALL(glSamplerParameterf(name, GL_TEXTURE_LOD_BIAS, desc->lod_bias));
111 GL_EXTCALL(glSamplerParameterf(name, GL_TEXTURE_MIN_LOD, desc->min_lod));
112 GL_EXTCALL(glSamplerParameterf(name, GL_TEXTURE_MAX_LOD, desc->max_lod));
114 GL_EXTCALL(glSamplerParameteri(name, GL_TEXTURE_MAX_ANISOTROPY, desc->max_anisotropy));
115 if (desc->compare)
117 GL_EXTCALL(glSamplerParameteri(name, GL_TEXTURE_COMPARE_FUNC,
118 wined3d_gl_compare_func(desc->comparison_func)));
119 if ((context->d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL)
120 && gl_info->supported[EXT_TEXTURE_SRGB_DECODE] && !desc->srgb_decode)
122 checkGLcall("sampler creation");
123
124 TRACE("Created sampler %u.\n", name);
125 sampler_gl->name = name;
126
128}
#define NULL
Definition: types.h:112
GLenum wined3d_gl_compare_func(enum wined3d_cmp_func f)
Definition: ffp_gl.c:138
#define GL_TEXTURE_MIN_FILTER
Definition: gl.h:649
#define GL_TEXTURE_BORDER_COLOR
Definition: gl.h:656
#define GL_TEXTURE_WRAP_R
Definition: gl.h:1518
#define GL_TEXTURE_WRAP_S
Definition: gl.h:646
unsigned int GLuint
Definition: gl.h:159
#define GL_TEXTURE_MAX_LOD
Definition: gl.h:1502
#define GL_TEXTURE_WRAP_T
Definition: gl.h:647
#define GL_TEXTURE_MAG_FILTER
Definition: gl.h:648
#define GL_TEXTURE_MIN_LOD
Definition: gl.h:1501
#define GL_SKIP_DECODE_EXT
Definition: glext.h:5291
#define GL_TEXTURE_COMPARE_FUNC
Definition: glext.h:300
#define GL_COMPARE_R_TO_TEXTURE
Definition: glext.h:326
#define GL_TEXTURE_LOD_BIAS
Definition: glext.h:295
#define GL_TEXTURE_SRGB_DECODE_EXT
Definition: glext.h:5289
#define GL_TEXTURE_COMPARE_MODE
Definition: glext.h:299
Definition: http.c:7252
Definition: name.c:39
GLint wrap_lookup[WINED3D_TADDRESS_MIRROR_ONCE - WINED3D_TADDRESS_WRAP+1]
Definition: wined3d_gl.h:348
#define GL_TEXTURE_MAX_ANISOTROPY
Definition: wgl.h:4461
#define WINED3D_SRGB_READ_WRITE_CONTROL
Definition: wined3d.h:1330
@ ARB_TEXTURE_FILTER_ANISOTROPIC
Definition: wined3d_gl.h:134
@ EXT_TEXTURE_SRGB_DECODE
Definition: wined3d_gl.h:203
static GLenum wined3d_gl_mag_filter(enum wined3d_texture_filter_type mag_filter)
Definition: wined3d_gl.h:377
static GLenum wined3d_gl_min_mip_filter(enum wined3d_texture_filter_type min_filter, enum wined3d_texture_filter_type mip_filter)
Definition: wined3d_gl.h:382
static void context_release(struct wined3d_context *context)
static struct wined3d_context * context_acquire(struct wined3d_device *device, struct wined3d_texture *texture, unsigned int sub_resource_idx)

Referenced by wined3d_sampler_gl_init().

◆ wined3d_sampler_gl_init()

void wined3d_sampler_gl_init ( struct wined3d_sampler_gl *  sampler_gl,
struct wined3d_device *  device,
const struct wined3d_sampler_desc *  desc,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)

Definition at line 130 of file sampler.c.

132{
133 TRACE("sampler_gl %p, device %p, desc %p, parent %p, parent_ops %p.\n",
134 sampler_gl, device, desc, parent, parent_ops);
135
136 wined3d_sampler_init(&sampler_gl->s, device, desc, parent, parent_ops);
137
138 if (wined3d_adapter_gl(device->adapter)->gl_info.supported[ARB_SAMPLER_OBJECTS])
140}
void wined3d_cs_init_object(struct wined3d_cs *cs, void(*callback)(void *object), void *object)
Definition: cs.c:2304
static void wined3d_sampler_gl_cs_init(void *object)
Definition: sampler.c:84
static void wined3d_sampler_init(struct wined3d_sampler *sampler, struct wined3d_device *device, const struct wined3d_sampler_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
Definition: sampler.c:58
struct wined3d_gl_info gl_info
Definition: wined3d_gl.h:800

Referenced by adapter_gl_create_sampler().

◆ wined3d_sampler_incref()

ULONG CDECL wined3d_sampler_incref ( struct wined3d_sampler *  sampler)

Definition at line 26 of file sampler.c.

27{
28 unsigned int refcount = InterlockedIncrement(&sampler->refcount);
29
30 TRACE("%p increasing refcount to %u.\n", sampler, refcount);
31
32 return refcount;
33}
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by d3d11_sampler_state_AddRef(), wined3d_cs_packet_incref_objects(), and wined3d_device_context_set_samplers().

◆ wined3d_sampler_init()

static void wined3d_sampler_init ( struct wined3d_sampler *  sampler,
struct wined3d_device *  device,
const struct wined3d_sampler_desc *  desc,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)
static

Definition at line 58 of file sampler.c.

60{
61 TRACE("sampler %p, device %p, desc %p, parent %p, parent_ops %p.\n",
62 sampler, device, desc, parent, parent_ops);
63
64 TRACE(" Address modes: U %#x, V %#x, W %#x.\n", desc->address_u, desc->address_v, desc->address_w);
65 TRACE(" Border colour: {%.8e, %.8e, %.8e, %.8e}.\n",
66 desc->border_color[0], desc->border_color[1], desc->border_color[2], desc->border_color[3]);
67 TRACE(" Filters: mag %#x, min %#x, mip %#x.\n", desc->mag_filter, desc->min_filter, desc->mip_filter);
68 TRACE(" LOD bias: %.8e.\n", desc->lod_bias);
69 TRACE(" Minimum LOD: %.8e.\n", desc->min_lod);
70 TRACE(" Maximum LOD: %.8e.\n", desc->max_lod);
71 TRACE(" Base mip level: %u.\n", desc->mip_base_level);
72 TRACE(" Maximum anisotropy: %u.\n", desc->max_anisotropy);
73 TRACE(" Comparison: %d.\n", desc->compare);
74 TRACE(" Comparison func: %#x.\n", desc->comparison_func);
75 TRACE(" SRGB decode: %d.\n", desc->srgb_decode);
76
77 sampler->refcount = 1;
78 sampler->device = device;
79 sampler->parent = parent;
80 sampler->parent_ops = parent_ops;
81 sampler->desc = *desc;
82}

Referenced by wined3d_sampler_gl_init(), and wined3d_sampler_vk_init().

◆ wined3d_sampler_vk_cs_init()

static void wined3d_sampler_vk_cs_init ( void *  object)
static

Definition at line 215 of file sampler.c.

216{
217 struct wined3d_sampler_vk *sampler_vk = object;
218 const struct wined3d_sampler_desc *desc;
219 const struct wined3d_d3d_info *d3d_info;
220 struct VkSamplerCreateInfo sampler_desc;
221 const struct wined3d_vk_info *vk_info;
222 struct wined3d_context_vk *context_vk;
223 struct wined3d_device_vk *device_vk;
224 VkSampler vk_sampler;
225 VkResult vr;
226
227 TRACE("sampler_vk %p.\n", sampler_vk);
228
229 context_vk = wined3d_context_vk(context_acquire(sampler_vk->s.device, NULL, 0));
230 device_vk = wined3d_device_vk(context_vk->c.device);
231 d3d_info = context_vk->c.d3d_info;
232 vk_info = context_vk->vk_info;
233
234 desc = &sampler_vk->s.desc;
235 sampler_desc.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
236 sampler_desc.pNext = NULL;
237 sampler_desc.flags = 0;
238 sampler_desc.magFilter = vk_filter_from_wined3d(desc->mag_filter);
239 sampler_desc.minFilter = vk_filter_from_wined3d(desc->min_filter);
240 sampler_desc.mipmapMode = vk_mipmap_mode_from_wined3d(desc->mip_filter);
241 sampler_desc.addressModeU = vk_address_mode_from_wined3d(desc->address_u);
242 sampler_desc.addressModeV = vk_address_mode_from_wined3d(desc->address_v);
243 sampler_desc.addressModeW = vk_address_mode_from_wined3d(desc->address_w);
244 sampler_desc.mipLodBias = desc->lod_bias;
245 sampler_desc.anisotropyEnable = desc->max_anisotropy != 1;
246 sampler_desc.maxAnisotropy = desc->max_anisotropy;
247 sampler_desc.compareEnable = !!desc->compare;
248 sampler_desc.compareOp = vk_compare_op_from_wined3d(desc->comparison_func);
249 sampler_desc.minLod = desc->min_lod;
250 sampler_desc.maxLod = desc->max_lod;
251 sampler_desc.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
252 sampler_desc.unnormalizedCoordinates = VK_FALSE;
253
254 if (desc->address_u == WINED3D_TADDRESS_BORDER || desc->address_v == WINED3D_TADDRESS_BORDER
255 || desc->address_w == WINED3D_TADDRESS_BORDER)
256 sampler_desc.borderColor = vk_border_colour_from_wined3d((const struct wined3d_color *)desc->border_color);
257 if (desc->mip_base_level)
258 FIXME("Unhandled mip_base_level %u.\n", desc->mip_base_level);
259 if ((d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL) && !desc->srgb_decode)
260 FIXME("Unhandled srgb_decode %#x.\n", desc->srgb_decode);
261
262 vr = VK_CALL(vkCreateSampler(device_vk->vk_device, &sampler_desc, NULL, &vk_sampler));
264 if (vr < 0)
265 {
266 ERR("Failed to create Vulkan sampler, vr %s.\n", wined3d_debug_vkresult(vr));
267 return;
268 }
269
270 TRACE("Created sampler 0x%s.\n", wine_dbgstr_longlong(vk_sampler));
271
272 sampler_vk->vk_image_info.sampler = vk_sampler;
273 sampler_vk->vk_image_info.imageView = VK_NULL_HANDLE;
275}
VkCompareOp vk_compare_op_from_wined3d(enum wined3d_cmp_func op)
Definition: context_vk.c:30
const char * wined3d_debug_vkresult(VkResult vr)
Definition: utils.c:5463
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
static VkFilter vk_filter_from_wined3d(enum wined3d_texture_filter_type f)
Definition: sampler.c:142
static VkSamplerMipmapMode vk_mipmap_mode_from_wined3d(enum wined3d_texture_filter_type f)
Definition: sampler.c:155
static VkBorderColor vk_border_colour_from_wined3d(const struct wined3d_color *colour)
Definition: sampler.c:188
static VkSamplerAddressMode vk_address_mode_from_wined3d(enum wined3d_texture_address a)
Definition: sampler.c:169
VkImageLayout imageLayout
Definition: vulkan.h:8266
uint32_t wined3d_creation_flags
VkDevice vk_device
Definition: wined3d_vk.h:825
struct wined3d_vk_info vk_info
Definition: wined3d_vk.h:830
struct wined3d_context_vk context_vk
Definition: wined3d_vk.h:823
struct wined3d_sampler s
Definition: wined3d_vk.h:903
VkDescriptorImageInfo vk_image_info
Definition: wined3d_vk.h:905
@ VK_IMAGE_LAYOUT_UNDEFINED
Definition: vulkan.h:3451
#define VK_FALSE
Definition: vulkan.h:56
VkResult
Definition: vulkan.h:4639
VkResult VKAPI_CALL vkCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSampler *pSampler)
#define VK_NULL_HANDLE
Definition: vulkan.h:861
@ VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO
Definition: vulkan.h:4995
#define VK_CALL(f)
Definition: wined3d_vk.h:272

Referenced by wined3d_sampler_vk_init().

◆ wined3d_sampler_vk_init()

void wined3d_sampler_vk_init ( struct wined3d_sampler_vk *  sampler_vk,
struct wined3d_device *  device,
const struct wined3d_sampler_desc *  desc,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)

Definition at line 277 of file sampler.c.

279{
280 TRACE("sampler_vk %p, device %p, desc %p, parent %p, parent_ops %p.\n",
281 sampler_vk, device, desc, parent, parent_ops);
282
283 wined3d_sampler_init(&sampler_vk->s, device, desc, parent, parent_ops);
285}
static void wined3d_sampler_vk_cs_init(void *object)
Definition: sampler.c:215

Referenced by adapter_vk_create_sampler().