wined3d: Introduce struct wined3d_sampler_desc.
This commit is contained in:
parent
95c57c618a
commit
4b480f5519
|
@ -24,6 +24,12 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
|
||||
|
||||
#define D3D10_FILTER_MIP_MASK 0x01
|
||||
#define D3D10_FILTER_MAG_MASK 0x04
|
||||
#define D3D10_FILTER_MIN_MASK 0x10
|
||||
#define D3D10_FILTER_ANISO_MASK 0x40
|
||||
#define D3D10_FILTER_COMPARE_MASK 0x80
|
||||
|
||||
static inline struct d3d10_blend_state *impl_from_ID3D10BlendState(ID3D10BlendState *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, struct d3d10_blend_state, ID3D10BlendState_iface);
|
||||
|
@ -590,16 +596,68 @@ static const struct ID3D10SamplerStateVtbl d3d10_sampler_state_vtbl =
|
|||
d3d10_sampler_state_GetDesc,
|
||||
};
|
||||
|
||||
static enum wined3d_texture_address wined3d_texture_address_from_d3d10core(enum D3D10_TEXTURE_ADDRESS_MODE t)
|
||||
{
|
||||
return (enum wined3d_texture_address)t;
|
||||
}
|
||||
|
||||
static enum wined3d_texture_filter_type wined3d_texture_filter_mip_from_d3d10core(enum D3D10_FILTER f)
|
||||
{
|
||||
if (f & D3D10_FILTER_MIP_MASK)
|
||||
return WINED3D_TEXF_LINEAR;
|
||||
return WINED3D_TEXF_POINT;
|
||||
}
|
||||
|
||||
static enum wined3d_texture_filter_type wined3d_texture_filter_mag_from_d3d10core(enum D3D10_FILTER f)
|
||||
{
|
||||
if (f & D3D10_FILTER_MAG_MASK)
|
||||
return WINED3D_TEXF_LINEAR;
|
||||
return WINED3D_TEXF_POINT;
|
||||
}
|
||||
|
||||
static enum wined3d_texture_filter_type wined3d_texture_filter_min_from_d3d10core(enum D3D10_FILTER f)
|
||||
{
|
||||
if (f & D3D10_FILTER_MIN_MASK)
|
||||
return WINED3D_TEXF_LINEAR;
|
||||
return WINED3D_TEXF_POINT;
|
||||
}
|
||||
|
||||
static BOOL wined3d_texture_compare_from_d3d10core(enum D3D10_FILTER f)
|
||||
{
|
||||
return f & D3D10_FILTER_COMPARE_MASK;
|
||||
}
|
||||
|
||||
static enum wined3d_cmp_func wined3d_cmp_func_from_d3d10core(D3D10_COMPARISON_FUNC f)
|
||||
{
|
||||
return (enum wined3d_cmp_func)f;
|
||||
}
|
||||
|
||||
HRESULT d3d10_sampler_state_init(struct d3d10_sampler_state *state, struct d3d10_device *device,
|
||||
const D3D10_SAMPLER_DESC *desc)
|
||||
{
|
||||
struct wined3d_sampler_desc wined3d_desc;
|
||||
HRESULT hr;
|
||||
|
||||
state->ID3D10SamplerState_iface.lpVtbl = &d3d10_sampler_state_vtbl;
|
||||
state->refcount = 1;
|
||||
state->desc = *desc;
|
||||
|
||||
if (FAILED(hr = wined3d_sampler_create(state, &state->wined3d_sampler)))
|
||||
wined3d_desc.address_u = wined3d_texture_address_from_d3d10core(desc->AddressU);
|
||||
wined3d_desc.address_v = wined3d_texture_address_from_d3d10core(desc->AddressV);
|
||||
wined3d_desc.address_w = wined3d_texture_address_from_d3d10core(desc->AddressW);
|
||||
memcpy(wined3d_desc.border_color, desc->BorderColor, sizeof(wined3d_desc.border_color));
|
||||
wined3d_desc.mag_filter = wined3d_texture_filter_mag_from_d3d10core(desc->Filter);
|
||||
wined3d_desc.min_filter = wined3d_texture_filter_min_from_d3d10core(desc->Filter);
|
||||
wined3d_desc.mip_filter = wined3d_texture_filter_mip_from_d3d10core(desc->Filter);
|
||||
wined3d_desc.lod_bias = desc->MipLODBias;
|
||||
wined3d_desc.min_lod = desc->MinLOD;
|
||||
wined3d_desc.max_lod = desc->MaxLOD;
|
||||
wined3d_desc.max_anisotropy = desc->Filter & D3D10_FILTER_ANISO_MASK ? desc->MaxAnisotropy : 1;
|
||||
wined3d_desc.compare = wined3d_texture_compare_from_d3d10core(desc->Filter);
|
||||
wined3d_desc.comparison_func = wined3d_cmp_func_from_d3d10core(desc->ComparisonFunc);
|
||||
wined3d_desc.srgb_decode = FALSE;
|
||||
|
||||
if (FAILED(hr = wined3d_sampler_create(&wined3d_desc, state, &state->wined3d_sampler)))
|
||||
{
|
||||
WARN("Failed to create wined3d sampler, hr %#x.\n", hr);
|
||||
return hr;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012 Henri Verbeet for CodeWeavers
|
||||
* Copyright 2012, 2015 Henri Verbeet for CodeWeavers
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -52,22 +52,25 @@ void * CDECL wined3d_sampler_get_parent(const struct wined3d_sampler *sampler)
|
|||
return sampler->parent;
|
||||
}
|
||||
|
||||
static void wined3d_sampler_init(struct wined3d_sampler *sampler, void *parent)
|
||||
static void wined3d_sampler_init(struct wined3d_sampler *sampler,
|
||||
const struct wined3d_sampler_desc *desc, void *parent)
|
||||
{
|
||||
sampler->refcount = 1;
|
||||
sampler->parent = parent;
|
||||
sampler->desc = *desc;
|
||||
}
|
||||
|
||||
HRESULT CDECL wined3d_sampler_create(void *parent, struct wined3d_sampler **sampler)
|
||||
HRESULT CDECL wined3d_sampler_create(const struct wined3d_sampler_desc *desc,
|
||||
void *parent, struct wined3d_sampler **sampler)
|
||||
{
|
||||
struct wined3d_sampler *object;
|
||||
|
||||
TRACE("parent %p, sampler %p.\n", parent, sampler);
|
||||
TRACE("desc %p, parent %p, sampler %p.\n", desc, parent, sampler);
|
||||
|
||||
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
wined3d_sampler_init(object, parent);
|
||||
wined3d_sampler_init(object, desc, parent);
|
||||
|
||||
TRACE("Created sampler %p.\n", object);
|
||||
*sampler = object;
|
||||
|
|
|
@ -194,7 +194,7 @@
|
|||
@ cdecl wined3d_rendertarget_view_incref(ptr)
|
||||
@ cdecl wined3d_rendertarget_view_set_parent(ptr ptr)
|
||||
|
||||
@ cdecl wined3d_sampler_create(ptr ptr)
|
||||
@ cdecl wined3d_sampler_create(ptr ptr ptr)
|
||||
@ cdecl wined3d_sampler_decref(ptr)
|
||||
@ cdecl wined3d_sampler_get_parent(ptr)
|
||||
@ cdecl wined3d_sampler_incref(ptr)
|
||||
|
|
|
@ -2409,6 +2409,7 @@ struct wined3d_sampler
|
|||
{
|
||||
LONG refcount;
|
||||
void *parent;
|
||||
struct wined3d_sampler_desc desc;
|
||||
};
|
||||
|
||||
struct wined3d_vertex_declaration_element
|
||||
|
|
|
@ -1976,6 +1976,24 @@ struct wined3d_rendertarget_view_desc
|
|||
} u;
|
||||
};
|
||||
|
||||
struct wined3d_sampler_desc
|
||||
{
|
||||
enum wined3d_texture_address address_u;
|
||||
enum wined3d_texture_address address_v;
|
||||
enum wined3d_texture_address address_w;
|
||||
float border_color[4];
|
||||
enum wined3d_texture_filter_type mag_filter;
|
||||
enum wined3d_texture_filter_type min_filter;
|
||||
enum wined3d_texture_filter_type mip_filter;
|
||||
float lod_bias;
|
||||
float min_lod;
|
||||
float max_lod;
|
||||
unsigned int max_anisotropy;
|
||||
BOOL compare;
|
||||
enum wined3d_cmp_func comparison_func;
|
||||
BOOL srgb_decode;
|
||||
};
|
||||
|
||||
struct wined3d_shader_signature_element
|
||||
{
|
||||
const char *semantic_name;
|
||||
|
@ -2434,7 +2452,8 @@ void * __cdecl wined3d_rendertarget_view_get_sub_resource_parent(const struct wi
|
|||
ULONG __cdecl wined3d_rendertarget_view_incref(struct wined3d_rendertarget_view *view);
|
||||
void __cdecl wined3d_rendertarget_view_set_parent(struct wined3d_rendertarget_view *view, void *parent);
|
||||
|
||||
HRESULT __cdecl wined3d_sampler_create(void *parent, struct wined3d_sampler **sampler);
|
||||
HRESULT __cdecl wined3d_sampler_create(const struct wined3d_sampler_desc *desc,
|
||||
void *parent, struct wined3d_sampler **sampler);
|
||||
ULONG __cdecl wined3d_sampler_decref(struct wined3d_sampler *sampler);
|
||||
void * __cdecl wined3d_sampler_get_parent(const struct wined3d_sampler *sampler);
|
||||
ULONG __cdecl wined3d_sampler_incref(struct wined3d_sampler *sampler);
|
||||
|
|
Loading…
Reference in New Issue