VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtTileSpaceLightGrid.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2014 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 #pragma once
10 
11 #include "DtGraphicsUtilsPreReqs.h"
12 #include "DtMatrix4.h"
13 
14 #pragma warning( push )
15 #pragma warning( disable : 4251 )
16 
17 // the maximum number if lights supported, this is limited by constant buffer size,
18 // commonly this is 64kb, but AMD only seem to allow 2048 lights...
19 #define NUM_POSSIBLE_LIGHTS (1024)
20 
21 // Must be a power of two, configure to suit hardware/wishes, also limited at
22 // runtime by glGet GL_MAX_COLOR_TEXTURE_SAMPLES. The smaller value is used.
23 #define MAX_ALLOWED_MSAA_SAMPLES 16
24 
25 #include "DtCameraFwdDeclare.h"
26 #include "DtForwardDeclare.h"
28 #include "DtVector2.h"
29 #include "DtScreenRect.h"
30 #include "DtIntSize.h"
31 
32  namespace makVrv {
33 
34  typedef std::vector<uint32> VectorAreas;
35 
39  {
40  public:
43 
45  virtual ~DtTileSpaceLightGrid();
46 
48 
49  void setTileSize(Vector2_uint32 tileSize);
50  const Vector2_uint32& tileSize(void) const;
52 
53 
55  const Vector2_uint32& gridMaxDims(void) const;
57  uint32 getGridMaxDimsFlattened(void) const;
58 
59 
61 
62  void update(const VectorLights& frustumVisibleLights
63  , const Camera_64* pCamera
64  , const Vector2_uint32& viewportSize);
65 
66  void update(const VectorLights& frustumVisibleLights
67  , const Matrix4_64& view_projection_matrix
68  , const Vector2_uint32& viewportSize);
70 
71 
73 
74  int tileLightCount(uint32 x, uint32 y) const;
75  const int *tileLightIndexList(uint32 x, uint32 y) const;
77 
78 
79 
81 
82  const int *tileDataPtr() const
83  {
84  return myGridOffsets;
85  }
86  const int *tileCountsDataPtr() const
87  {
88  return myGridCounts;
89  }
90  const int *tileLightIndexListsPtr() const
91  {
92  return &myTileLightIndexLists[0];
93  }
94 
95  uint32 totalTileLightIndexListLength() const
96  {
97  return uint32(myTileLightIndexLists.size());
98  }
100 
101 
103 
104  void setScreenAreaCullSize(uint32 val);
105  uint32 screenAreaCullSize(void) const;
107 
108  private:
109  void updateScreenSpaceRectangles(const VectorLights& frustumVisibleLights
110  , const Matrix4_64& view_projection_matrix
111  , const Vector2_uint32& viewportSize
112  , const Vector2_uint32& tileSize);
113 
115 
116 #if 0
117  const Vector2_32 getTileMinMax(uint32 x, uint32 y) const
118  {
119  return m_minMaxGridValid ?
120  m_gridMinMaxZ[x + y * m_gridDim.x]
121  : chag::make_vector(0.0f, 0.0f);
122  }
123  std::vector<chag::float2> m_gridMinMaxZ;
124 #endif
125 
128  void updateToAccountForScreenRes(const Vector2_uint32& viewport_size);
129 
131 
134 
135  std::vector<int> myTileLightIndexLists;
138 
139  ConstVectorLights myViewSpaceLights;
141 
143 
144  int& GridOffset(int x, int y)
145  {
146  return myGridOffsets[x + y * myGridMaxDims.x];
147  }
148  int& GridCount(int x, int y)
149  {
150  return myGridCounts[x + y * myGridMaxDims.x];
151  }
152 
154  };
155 
156 } //namespace makVrv
157 
158 #pragma warning(pop)

Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)