|
@@ -160,7 +160,9 @@ prepare_texture(Texture *tex) {
|
|
|
return NULL;
|
|
return NULL;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (!dtc->create_texture(*_screen)) {
|
|
|
|
|
|
|
+ if (!upload_texture(dtc)) {
|
|
|
|
|
+ dxgsg8_cat.error()
|
|
|
|
|
+ << "Unable to create texture " << *tex << endl;
|
|
|
delete dtc;
|
|
delete dtc;
|
|
|
return NULL;
|
|
return NULL;
|
|
|
}
|
|
}
|
|
@@ -186,28 +188,21 @@ apply_texture(int i, TextureContext *tc) {
|
|
|
tc->set_active(true);
|
|
tc->set_active(true);
|
|
|
|
|
|
|
|
DXTextureContext8 *dtc = DCAST(DXTextureContext8, tc);
|
|
DXTextureContext8 *dtc = DCAST(DXTextureContext8, tc);
|
|
|
|
|
+ Texture *tex = tc->get_texture();
|
|
|
|
|
|
|
|
// If the texture image has changed, or if its use of mipmaps has
|
|
// If the texture image has changed, or if its use of mipmaps has
|
|
|
// changed, we need to re-create the image.
|
|
// changed, we need to re-create the image.
|
|
|
|
|
|
|
|
if (dtc->was_modified()) {
|
|
if (dtc->was_modified()) {
|
|
|
- if (!get_supports_compressed_texture_format(tc->get_texture()->get_ram_image_compression())) {
|
|
|
|
|
- dxgsg8_cat.error()
|
|
|
|
|
- << *dtc->get_texture() << " is stored in an unsupported compressed format.\n";
|
|
|
|
|
- _d3d_device->SetTextureStageState(i, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (!dtc->create_texture(*_screen)) {
|
|
|
|
|
|
|
+ if (!upload_texture(dtc)) {
|
|
|
// Oops, we can't re-create the texture for some reason.
|
|
// Oops, we can't re-create the texture for some reason.
|
|
|
dxgsg8_cat.error()
|
|
dxgsg8_cat.error()
|
|
|
- << "Unable to re-create texture " << *dtc->get_texture() << endl;
|
|
|
|
|
- _d3d_device->SetTextureStageState(i, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
|
|
|
|
|
|
+ << "Unable to re-create texture " << *tex << endl;
|
|
|
|
|
+ _d3d_device->SetTextureStageState(i, D3DTSS_COLOROP, D3DTOP_DISABLE);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- Texture *tex = tc->get_texture();
|
|
|
|
|
Texture::WrapMode wrap_u, wrap_v, wrap_w;
|
|
Texture::WrapMode wrap_u, wrap_v, wrap_w;
|
|
|
wrap_u = tex->get_wrap_u();
|
|
wrap_u = tex->get_wrap_u();
|
|
|
wrap_v = tex->get_wrap_v();
|
|
wrap_v = tex->get_wrap_v();
|
|
@@ -249,16 +244,10 @@ apply_texture(int i, TextureContext *tc) {
|
|
|
new_mip_filter = D3DTEXF_NONE;
|
|
new_mip_filter = D3DTEXF_NONE;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#ifndef NDEBUG
|
|
|
|
|
// sanity check
|
|
// sanity check
|
|
|
- if ((!dtc->has_mipmaps()) && (new_mip_filter != D3DTEXF_NONE)) {
|
|
|
|
|
- dxgsg8_cat.error()
|
|
|
|
|
- << "Trying to set mipmap filtering for texture with no generated mipmaps!! texname["
|
|
|
|
|
- << tex->get_name() << "], filter("
|
|
|
|
|
- << tex->get_minfilter() << ")\n";
|
|
|
|
|
|
|
+ if (!dtc->has_mipmaps()) {
|
|
|
new_mip_filter = D3DTEXF_NONE;
|
|
new_mip_filter = D3DTEXF_NONE;
|
|
|
}
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
|
|
|
|
if (aniso_degree >= 2) {
|
|
if (aniso_degree >= 2) {
|
|
|
new_min_filter = D3DTEXF_ANISOTROPIC;
|
|
new_min_filter = D3DTEXF_ANISOTROPIC;
|
|
@@ -270,6 +259,39 @@ apply_texture(int i, TextureContext *tc) {
|
|
|
_d3d_device->SetTexture(i, dtc->get_d3d_texture());
|
|
_d3d_device->SetTexture(i, dtc->get_d3d_texture());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+// Function: DXGraphicsStateGuardian8::upload_texture
|
|
|
|
|
+// Access: Public
|
|
|
|
|
+// Description: Creates a texture surface on the graphics card and
|
|
|
|
|
+// fills it with its pixel data.
|
|
|
|
|
+////////////////////////////////////////////////////////////////////
|
|
|
|
|
+bool DXGraphicsStateGuardian8::
|
|
|
|
|
+upload_texture(DXTextureContext8 *dtc) {
|
|
|
|
|
+ Texture *tex = dtc->get_texture();
|
|
|
|
|
+ if (!get_supports_compressed_texture_format(tex->get_ram_image_compression())) {
|
|
|
|
|
+ dxgsg8_cat.error()
|
|
|
|
|
+ << *tex << " is stored in an unsupported compressed format.\n";
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (_incomplete_render &&
|
|
|
|
|
+ !tex->has_ram_image() && tex->might_have_ram_image() &&
|
|
|
|
|
+ tex->has_simple_ram_image() &&
|
|
|
|
|
+ !_loader.is_null()) {
|
|
|
|
|
+ // If we don't have the texture data right now, go get it, but in
|
|
|
|
|
+ // the meantime load a temporary simple image in its place.
|
|
|
|
|
+ async_reload_texture(dtc);
|
|
|
|
|
+ if (!tex->has_ram_image()) {
|
|
|
|
|
+ if (dtc->was_simple_image_modified()) {
|
|
|
|
|
+ return dtc->create_simple_texture(*_screen);
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return dtc->create_texture(*_screen);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
////////////////////////////////////////////////////////////////////
|
|
////////////////////////////////////////////////////////////////////
|
|
|
// Function: DXGraphicsStateGuardian8::release_texture
|
|
// Function: DXGraphicsStateGuardian8::release_texture
|
|
|
// Access: Public, Virtual
|
|
// Access: Public, Virtual
|