Use sampler states in Direct3D 8

This commit is contained in:
rdb 2014-12-12 20:39:24 +01:00
parent 8a5452b0b6
commit 270667ece2
2 changed files with 14 additions and 13 deletions

View File

@ -175,7 +175,7 @@ prepare_texture(Texture *tex, int view) {
// rendering on the ith stage.
////////////////////////////////////////////////////////////////////
void DXGraphicsStateGuardian8::
apply_texture(int i, TextureContext *tc) {
apply_texture(int i, TextureContext *tc, const SamplerState &sampler) {
if (tc == (TextureContext *)NULL) {
// The texture wasn't bound properly or something, so ensure
// texturing is disabled and just return.
@ -194,19 +194,19 @@ apply_texture(int i, TextureContext *tc) {
Texture *tex = tc->get_texture();
SamplerState::WrapMode wrap_u, wrap_v, wrap_w;
wrap_u = tex->get_wrap_u();
wrap_v = tex->get_wrap_v();
wrap_w = tex->get_wrap_w();
wrap_u = sampler.get_wrap_u();
wrap_v = sampler.get_wrap_v();
wrap_w = sampler.get_wrap_w();
_d3d_device->SetTextureStageState(i, D3DTSS_ADDRESSU, get_texture_wrap_mode(wrap_u));
_d3d_device->SetTextureStageState(i, D3DTSS_ADDRESSV, get_texture_wrap_mode(wrap_v));
_d3d_device->SetTextureStageState(i, D3DTSS_ADDRESSW, get_texture_wrap_mode(wrap_w));
_d3d_device->SetTextureStageState(i, D3DTSS_BORDERCOLOR,
LColor_to_D3DCOLOR(tex->get_border_color()));
LColor_to_D3DCOLOR(sampler.get_border_color()));
uint aniso_degree = tex->get_effective_anisotropic_degree();
SamplerState::FilterType ft = tex->get_effective_magfilter();
uint aniso_degree = sampler.get_effective_anisotropic_degree();
SamplerState::FilterType ft = sampler.get_effective_magfilter();
if (aniso_degree >= 1) {
_d3d_device->SetTextureStageState(i, D3DTSS_MAXANISOTROPY, aniso_degree);
@ -222,8 +222,8 @@ apply_texture(int i, TextureContext *tc) {
_d3d_device->SetTextureStageState(i, D3DTSS_MAGFILTER, new_mag_filter);
// map Panda composite min+mip filter types to d3d's separate min & mip filter types
D3DTEXTUREFILTERTYPE new_min_filter = get_d3d_min_type(tex->get_effective_minfilter());
D3DTEXTUREFILTERTYPE new_mip_filter = get_d3d_mip_type(tex->get_effective_minfilter());
D3DTEXTUREFILTERTYPE new_min_filter = get_d3d_min_type(sampler.get_effective_minfilter());
D3DTEXTUREFILTERTYPE new_mip_filter = get_d3d_mip_type(sampler.get_effective_minfilter());
if (!tex->might_have_ram_image()) {
// If the texture is completely dynamic, don't try to issue
@ -2859,11 +2859,12 @@ do_issue_texture() {
Texture *texture = _target_texture->get_on_texture(stage);
nassertv(texture != (Texture *)NULL);
const SamplerState &sampler = _target_texture->get_on_sampler(stage);
// We always reissue every stage in DX, just in case the texcoord
// index or texgen mode or some other property has changed.
TextureContext *tc = texture->prepare_now(0, _prepared_objects, this);
apply_texture(si, tc);
apply_texture(si, tc, sampler);
set_texture_blend_mode(si, stage);
int texcoord_dimensions = 2;

View File

@ -50,7 +50,7 @@ public:
calc_fb_properties(DWORD cformat, DWORD dformat, DWORD multisampletype);
virtual TextureContext *prepare_texture(Texture *tex, int view);
void apply_texture(int i, TextureContext *tc);
void apply_texture(int i, TextureContext *tc, const SamplerState &sampler);
virtual bool update_texture(TextureContext *tc, bool force);
bool upload_texture(DXTextureContext8 *dtc, bool force);
virtual void release_texture(TextureContext *tc);
@ -258,7 +258,7 @@ protected:
const DXIndexBufferContext8 *_active_ibuffer;
int _num_active_texture_stages;
// Cache the data necessary to bind each particular light each
// frame, so if we bind a given light multiple times, we only have
// to compute its data once.
@ -292,7 +292,7 @@ public:
register_type(_type_handle, "DXGraphicsStateGuardian8",
GraphicsStateGuardian::get_class_type());
}
private:
static TypeHandle _type_handle;