Pārlūkot izejas kodu

fix vertex fogging, more geom pipeline changes to support vertex buffers

cxgeorge 24 gadi atpakaļ
vecāks
revīzija
bb7fa55953

+ 4 - 0
panda/src/dxgsg/config_dxgsg.cxx

@@ -75,11 +75,15 @@ int dx_force_backface_culling = config_dxgsg.GetInt("dx-force-backface-culling",
 bool dx_mipmap_everything = config_dxgsg.GetBool("dx-mipmap-everything", false);
 bool dx_ignore_mipmaps = config_dxgsg.GetBool("dx-ignore-mipmaps", false);
 
+// if this is set, more accurate but more expensive fog computations are performed
+bool dx_use_rangebased_fog = config_dxgsg.GetBool("dx-use-rangebased-fog", false);
+
 #ifdef _DEBUG
 float dx_global_miplevel_bias = config_dxgsg.GetFloat("dx-global-miplevel-bias", 0.0);
 bool dx_debug_view_mipmaps = config_dxgsg.GetBool("dx-debug-view-mipmaps", false);
 bool dx_force_16bpptextures = config_dxgsg.GetBool("dx-force-16bpptextures", false);
 bool dx_force_anisotropic_filtering = config_dxgsg.GetBool("dx-force-anisotropic-filtering", false);
+//int dx_print_texstats = config_dxgsg.GetBool("dx-print-texstats", 0);
 #endif
 
 // set 'retained-mode #t' and this to have prepare_geom concatenate all tristrips within a geom 

+ 1 - 1
panda/src/dxgsg/config_dxgsg.h

@@ -32,7 +32,7 @@ extern bool dx_no_vertex_fog;
 extern bool dx_full_screen_antialiasing;
 extern float dx_fps_meter_update_interval;
 extern bool dx_auto_normalize_lighting;
-
+extern bool dx_use_rangebased_fog;
 extern const bool link_tristrips;
 
 // debug flags

+ 11 - 0
panda/src/dxgsg/dxGeomNodeContext.h

@@ -35,6 +35,11 @@
 #define D3D_OVERLOADS   //  get D3DVECTOR '+' operator, etc from d3dtypes.h
 #include <d3d.h>
 
+typedef struct {
+     DWORD nVerts;
+     D3DPRIMITIVETYPE primtype;
+} DPInfo;
+
 ////////////////////////////////////////////////////////////////////
 //       Class : DXGeomNodeContext
 // Description :
@@ -58,6 +63,12 @@ public:
 
   int _start_index;   // starting offset of this geom's verts within the VB
   int _num_verts;     // number of verts used by this geomcontext within the VB
+  
+  BYTE *_pEndofVertData;  // ptr to end of current vert data in VB (note: only used/valid during setup)
+
+  // for multiple geoms per VB, either will have to regen lengths based on per* flags, or store
+  // per geom vector of perprim vectors lengths
+  vector<DPInfo> _PrimInfo;
 
 public:
   static TypeHandle get_class_type() {

+ 1 - 1
panda/src/dxgsg/dxGraphicsStateGuardian.I

@@ -230,7 +230,7 @@ set_shademode(D3DSHADEMODE val) {
 ////////////////////////////////////////////////////////////////////
 INLINE void DXGraphicsStateGuardian::
 enable_fog(bool val) {
-  if (_fog_enabled != val) {
+  if ((_fog_enabled != val) && (_doFogType!=None)) {
     _fog_enabled = val;
     _d3dDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, (DWORD)val);
   }

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 251 - 185
panda/src/dxgsg/dxGraphicsStateGuardian.cxx


+ 20 - 13
panda/src/dxgsg/dxGraphicsStateGuardian.h

@@ -223,7 +223,6 @@ protected:
   bool              _bTransformIssued;  // decaling needs to tell when a transform has been issued
   D3DMATRIX         _SavedTransform;   
 
-
   RenderBuffer::Type _cur_read_pixel_buffer;  // source for copy_pixel_buffer operation
 
   D3DDEVICEDESC7    _D3DDevDesc;
@@ -283,12 +282,21 @@ protected:
   Normalf   p_normal;
   Vertexf   p_vertex;
   TexCoordf p_texcoord;
-  D3DCOLOR  p_colr;
+  D3DCOLOR  _curD3Dcolor;
+  DWORD     _curFVFflags;
+  short     _perPrim;
+  short     _perVertex;
+  short     _perComp;
+
+  bool  _issued_color_enabled;      // WBD ADDED
+  bool  _enable_all_color;
+  Colorf _issued_color;           // WBD ADDED
+  D3DCOLOR _issued_color_D3DCOLOR;           // WBD ADDED
+
+  D3DSHADEMODE _CurShadeMode;
 
-  int       p_flags;
-  short     perPrim;
-  short     perVertex;
-  short     perComp;
+  bool _bDrawPrimDoSetupVertexBuffer;       // if true, draw methods just copy vertex data into pCurrentGeomContext
+  DXGeomNodeContext *_pCurrentGeomContext;  // used in vertex buffer setup
 
   // iterators for primitives
   Geom::VertexIterator vi;
@@ -317,6 +325,12 @@ protected:
   float _line_width;
   float _point_size;
   bool  _depth_mask;
+
+  typedef enum {None,
+                PerVertexFog=D3DRENDERSTATE_FOGVERTEXMODE,
+                PerPixelFog=D3DRENDERSTATE_FOGTABLEMODE
+               } DxgsgFogType;
+  DxgsgFogType _doFogType;
   int   _fog_mode;
   float _fog_start;
   float _fog_end;
@@ -327,13 +341,6 @@ protected:
   D3DBLEND _blend_source_func;
   D3DBLEND _blend_dest_func;
 
-  bool  _issued_color_enabled;      // WBD ADDED
-  bool  _enable_all_color;
-  Colorf _issued_color;           // WBD ADDED
-  D3DCOLOR _issued_color_D3DCOLOR;           // WBD ADDED
-
-  D3DSHADEMODE _CurShadeMode;
-
   bool _multisample_enabled;
   bool _line_smooth_enabled;
   bool _point_smooth_enabled;

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels