mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
Fix regressions with Direct3D support. Add sRGB support to DX9 renderer.
This commit is contained in:
parent
26fc5f41d4
commit
7524299de9
@ -492,7 +492,7 @@ if (COMPILER == "MSVC"):
|
||||
LibName(pkg, 'dxerr.lib')
|
||||
else:
|
||||
LibName(pkg, 'dxerrVNUM.lib'.replace("VNUM", vnum))
|
||||
LibName(pkg, 'ddraw.lib')
|
||||
#LibName(pkg, 'ddraw.lib')
|
||||
LibName(pkg, 'dxguid.lib')
|
||||
IncDirectory("ALWAYS", GetThirdpartyDir() + "extras/include")
|
||||
LibName("WINSOCK", "wsock32.lib")
|
||||
|
@ -22,7 +22,7 @@
|
||||
wdxGraphicsPipe8.I wdxGraphicsPipe8.h \
|
||||
wdxGraphicsWindow8.I wdxGraphicsWindow8.h \
|
||||
dxgsg8base.h config_dxgsg8.h dxGraphicsStateGuardian8.I dxGraphicsStateGuardian8.h \
|
||||
dxVertexBufferContext8.h dxVertexbufferContext8.I \
|
||||
dxVertexBufferContext8.h dxVertexBufferContext8.I \
|
||||
dxIndexBufferContext8.h dxIndexBufferContext8.I \
|
||||
dxTextureContext8.h dxTextureContext8.I \
|
||||
dxGeomMunger8.h dxGeomMunger8.I \
|
||||
|
@ -413,7 +413,7 @@ handle_reshape() {
|
||||
GdiFlush();
|
||||
WinGraphicsWindow::handle_reshape();
|
||||
|
||||
if (_dxgsg != NULL) {
|
||||
if (_dxgsg != NULL && _dxgsg->_d3d_device != NULL) {
|
||||
// create the new resized rendertargets
|
||||
WindowProperties props = get_properties();
|
||||
int x_size = props.get_x_size();
|
||||
|
@ -22,7 +22,7 @@
|
||||
wdxGraphicsPipe9.I wdxGraphicsPipe9.h \
|
||||
wdxGraphicsWindow9.I wdxGraphicsWindow9.h \
|
||||
dxgsg9base.h config_dxgsg9.h dxGraphicsStateGuardian9.I dxGraphicsStateGuardian9.h \
|
||||
dxVertexBufferContext9.h dxVertexbufferContext9.I \
|
||||
dxVertexBufferContext9.h dxVertexBufferContext9.I \
|
||||
dxIndexBufferContext9.h dxIndexBufferContext9.I \
|
||||
dxTextureContext9.h dxTextureContext9.I \
|
||||
dxGeomMunger9.h dxGeomMunger9.I \
|
||||
|
@ -224,6 +224,13 @@ apply_texture(int i, TextureContext *tc) {
|
||||
DXTextureContext9 *dtc = DCAST(DXTextureContext9, tc);
|
||||
Texture *tex = tc->get_texture();
|
||||
|
||||
//if (tex->get_color_space() == CS_srgb) {
|
||||
if (Texture::is_srgb(tex->get_format())) {
|
||||
set_sampler_state(i, D3DSAMP_SRGBTEXTURE, TRUE);
|
||||
} else {
|
||||
set_sampler_state(i, D3DSAMP_SRGBTEXTURE, FALSE);
|
||||
}
|
||||
|
||||
Texture::WrapMode wrap_u, wrap_v, wrap_w;
|
||||
|
||||
DWORD address_u;
|
||||
@ -1040,6 +1047,12 @@ begin_frame(Thread *current_thread) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_current_properties->get_srgb_color()) {
|
||||
set_render_state(D3DRS_SRGBWRITEENABLE, TRUE);
|
||||
} else {
|
||||
set_render_state(D3DRS_SRGBWRITEENABLE, FALSE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2618,12 +2631,19 @@ reset() {
|
||||
|
||||
_last_testcooplevel_result = D3D_OK;
|
||||
|
||||
if (dxgsg9_cat.is_debug()) {
|
||||
dxgsg9_cat.debug() << "Supported texture formats:\n";
|
||||
}
|
||||
|
||||
for(int i = 0; i < MAX_POSSIBLE_TEXFMTS; i++) {
|
||||
// look for all possible DX9 texture fmts
|
||||
D3DFORMAT_FLAG fmtflag = D3DFORMAT_FLAG(1 << i);
|
||||
hr = _screen->_d3d9->CheckDeviceFormat(_screen->_card_id, D3DDEVTYPE_HAL, _screen->_display_mode.Format,
|
||||
0x0, D3DRTYPE_TEXTURE, g_D3DFORMATmap[fmtflag]);
|
||||
if (SUCCEEDED(hr)){
|
||||
if (SUCCEEDED(hr)) {
|
||||
if (dxgsg9_cat.is_debug()) {
|
||||
dxgsg9_cat.debug() << " " << D3DFormatStr(g_D3DFORMATmap[fmtflag]) << "\n";
|
||||
}
|
||||
_screen->_supported_tex_formats_mask |= fmtflag;
|
||||
}
|
||||
}
|
||||
@ -2632,7 +2652,7 @@ reset() {
|
||||
#define CHECK_FOR_DXTVERSION(num) \
|
||||
if (_screen->_supported_tex_formats_mask & DXT##num##_FLAG) {\
|
||||
if (dxgsg9_cat.is_debug()) {\
|
||||
dxgsg9_cat.debug() << "Compressed texture format DXT" << #num << " supported \n";\
|
||||
dxgsg9_cat.debug() << "Compressed texture format DXT" << #num << " supported\n";\
|
||||
}\
|
||||
_supports_compressed_texture = true;\
|
||||
_compressed_texture_formats.set_bit(Texture::CM_dxt##num);\
|
||||
@ -5220,7 +5240,7 @@ check_dx_allocation (HRESULT result, int allocation_size, int attempts)
|
||||
// increase the page out size as the number of attempts increases
|
||||
{
|
||||
size_t current_size = _prepared_objects->_graphics_memory_lru.get_total_size();
|
||||
size_t target_size = max(current_size - allocation_size * attempts, 0);
|
||||
size_t target_size = max(current_size - allocation_size * attempts, (size_t) 0);
|
||||
_prepared_objects->_graphics_memory_lru.evict_to(target_size);
|
||||
dxgsg9_cat.info()
|
||||
<< "Evicted " << current_size - _prepared_objects->_graphics_memory_lru.get_total_size() << " bytes of texture memory to make room for more.\n";
|
||||
|
@ -36,9 +36,7 @@
|
||||
#include "vertexElementArray.h"
|
||||
#include "dxShaderContext9.h"
|
||||
|
||||
|
||||
enum GsgPageType
|
||||
{
|
||||
enum GsgPageType {
|
||||
GPT_Texture,
|
||||
GPT_VertexBuffer,
|
||||
GPT_IndexBuffer,
|
||||
@ -52,6 +50,8 @@ class DXTextureContext9;
|
||||
class DXVertexBufferContext9;
|
||||
class DXIndexBufferContext9;
|
||||
|
||||
class wdxGraphicsBuffer9;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : DXGraphicsStateGuardian9
|
||||
// Description : A GraphicsStateGuardian for rendering into DirectX9
|
||||
|
@ -197,7 +197,9 @@ create_texture(DXScreenData &scrn) {
|
||||
|
||||
if ((tex->get_format() == Texture::F_luminance_alpha)||
|
||||
(tex->get_format() == Texture::F_luminance_alphamask) ||
|
||||
(tex->get_format() == Texture::F_luminance)) {
|
||||
(tex->get_format() == Texture::F_luminance) ||
|
||||
(tex->get_format() == Texture::F_sluminance_alpha) ||
|
||||
(tex->get_format() == Texture::F_sluminance)) {
|
||||
needs_luminance = true;
|
||||
}
|
||||
|
||||
@ -1596,7 +1598,7 @@ static UINT calculate_row_byte_length (int width, int num_color_channels, D3DFOR
|
||||
// Access: Private
|
||||
// Description: Called from fill_d3d_texture_pixels, this function
|
||||
// fills a single mipmap with texture data.
|
||||
// Takes care of all necessery conversions and error
|
||||
// Takes care of all necessary conversions and error
|
||||
// handling.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
HRESULT DXTextureContext9::fill_d3d_texture_mipmap_pixels(int mip_level, int depth_index, D3DFORMAT source_format)
|
||||
@ -1645,6 +1647,10 @@ HRESULT DXTextureContext9::fill_d3d_texture_mipmap_pixels(int mip_level, int dep
|
||||
// dithering)??)
|
||||
mip_filter = D3DX_FILTER_LINEAR ; //| D3DX_FILTER_DITHER; //dithering looks ugly on i810 for 4444 textures
|
||||
|
||||
if (Texture::is_srgb(get_texture()->get_format())) {
|
||||
mip_filter |= D3DX_FILTER_SRGB;
|
||||
}
|
||||
|
||||
// D3DXLoadSurfaceFromMemory will load black luminance and we want
|
||||
// full white, so convert to explicit luminance-alpha format
|
||||
if (_d3d_format == D3DFMT_A8) {
|
||||
@ -1888,6 +1894,10 @@ fill_d3d_texture_pixels(DXScreenData &scrn, bool compress_texture) {
|
||||
mip_filter_flags = D3DX_FILTER_TRIANGLE;
|
||||
}
|
||||
|
||||
if (Texture::is_srgb(tex->get_format())) {
|
||||
mip_filter_flags |= D3DX_FILTER_SRGB;
|
||||
}
|
||||
|
||||
// mip_filter_flags |= D3DX_FILTER_DITHER;
|
||||
hr = D3DXFilterTexture(_d3d_texture, (PALETTEENTRY*)NULL, 0,
|
||||
mip_filter_flags);
|
||||
@ -1991,6 +2001,10 @@ fill_d3d_volume_texture_pixels(DXScreenData &scrn) {
|
||||
// dithering)??)
|
||||
level_0_filter = D3DX_FILTER_LINEAR ; //| D3DX_FILTER_DITHER; //dithering looks ugly on i810 for 4444 textures
|
||||
|
||||
if (Texture::is_srgb(tex->get_format())) {
|
||||
level_0_filter |= D3DX_FILTER_SRGB;
|
||||
}
|
||||
|
||||
// D3DXLoadSurfaceFromMemory will load black luminance and we want
|
||||
// full white, so convert to explicit luminance-alpha format
|
||||
if (_d3d_format == D3DFMT_A8) {
|
||||
@ -2070,6 +2084,10 @@ fill_d3d_volume_texture_pixels(DXScreenData &scrn) {
|
||||
mip_filter_flags = D3DX_FILTER_TRIANGLE;
|
||||
}
|
||||
|
||||
if (Texture::is_srgb(tex->get_format())) {
|
||||
mip_filter_flags |= D3DX_FILTER_SRGB;
|
||||
}
|
||||
|
||||
// mip_filter_flags| = D3DX_FILTER_DITHER;
|
||||
|
||||
hr = D3DXFilterTexture(_d3d_texture, (PALETTEENTRY*)NULL, 0,
|
||||
@ -2167,6 +2185,17 @@ get_bits_per_pixel(Texture::Format format, int *alphbits) {
|
||||
case Texture::F_rgba32:
|
||||
*alphbits = 32;
|
||||
return 128;
|
||||
|
||||
case Texture::F_srgb:
|
||||
return 24;
|
||||
case Texture::F_srgb_alpha:
|
||||
*alphbits = 8;
|
||||
return 32;
|
||||
case Texture::F_sluminance:
|
||||
return 8;
|
||||
case Texture::F_sluminance_alpha:
|
||||
*alphbits = 8;
|
||||
return 16;
|
||||
}
|
||||
return 8;
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ make_output(const string &name,
|
||||
// Early failure - if we are sure that this buffer WONT
|
||||
// meet specs, we can bail out early.
|
||||
if ((flags & BF_fb_props_optional) == 0) {
|
||||
if ((fb_prop.get_indexed_color() > 0)||
|
||||
if (fb_prop.get_indexed_color() ||
|
||||
(fb_prop.get_back_buffers() > 0)||
|
||||
(fb_prop.get_accum_bits() > 0)||
|
||||
(fb_prop.get_multisamples() > 0)) {
|
||||
|
@ -421,7 +421,7 @@ handle_reshape() {
|
||||
GdiFlush();
|
||||
WinGraphicsWindow::handle_reshape();
|
||||
|
||||
if (_dxgsg != NULL) {
|
||||
if (_dxgsg != NULL && _dxgsg->_d3d_device != NULL) {
|
||||
// create the new resized rendertargets
|
||||
WindowProperties props = get_properties();
|
||||
int x_size = props.get_x_size();
|
||||
|
@ -170,7 +170,7 @@ make_output(const string &name,
|
||||
_fbo_multisample = 16;
|
||||
}
|
||||
if ((flags & BF_fb_props_optional)==0) {
|
||||
if ((fb_prop.get_indexed_color() > 0)||
|
||||
if (fb_prop.get_indexed_color() ||
|
||||
(fb_prop.get_back_buffers() > 0)||
|
||||
(fb_prop.get_accum_bits() > 0)||
|
||||
(fb_prop.get_multisamples() > _fbo_multisample)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user