• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef sw_Config_hpp
16 #define sw_Config_hpp
17 
18 #include "Common/Types.hpp"
19 
20 #define PERF_HUD 0       // Display time spent on vertex, setup and pixel processing for each thread
21 #define PERF_PROFILE 0   // Profile various pipeline stages and display the timing in SwiftConfig
22 
23 // Worker thread count when not set by SwiftConfig
24 // 0 = process affinity count (recommended)
25 // 1 = rendering on main thread (no worker threads), useful for debugging
26 #ifndef DEFAULT_THREAD_COUNT
27 #define DEFAULT_THREAD_COUNT 0
28 #endif
29 
30 namespace sw
31 {
32 	enum
33 	{
34 		PERF_PIXEL,
35 		PERF_PIPE,
36 		PERF_INTERP,
37 		PERF_SHADER,
38 		PERF_TEX,
39 		PERF_ROP,
40 
41 		PERF_TIMERS
42 	};
43 
44 	struct Profiler
45 	{
46 		Profiler();
47 
48 		void reset();
49 		void nextFrame();
50 
51 		int framesSec;
52 		int framesTotal;
53 		double FPS;
54 
55 		#if PERF_PROFILE
56 		double cycles[PERF_TIMERS];
57 
58 		int64_t ropOperations;
59 		int64_t ropOperationsTotal;
60 		int64_t ropOperationsFrame;
61 
62 		int64_t texOperations;
63 		int64_t texOperationsTotal;
64 		int64_t texOperationsFrame;
65 
66 		int64_t compressedTex;
67 		int64_t compressedTexTotal;
68 		int64_t compressedTexFrame;
69 		#endif
70 	};
71 
72 	extern Profiler profiler;
73 
74 	enum
75 	{
76 		OUTLINE_RESOLUTION = 8192,   // Maximum vertical resolution of the render target
77 		MIPMAP_LEVELS = 14,
78 		TEXTURE_IMAGE_UNITS = 16,
79 		VERTEX_TEXTURE_IMAGE_UNITS = 16,
80 		TOTAL_IMAGE_UNITS = TEXTURE_IMAGE_UNITS + VERTEX_TEXTURE_IMAGE_UNITS,
81 		FRAGMENT_UNIFORM_VECTORS = 264,
82 		VERTEX_UNIFORM_VECTORS = 259,
83 		MAX_VERTEX_INPUTS = 32,
84 		MAX_VERTEX_OUTPUTS = 34,
85 		MAX_FRAGMENT_INPUTS = 32,
86 		MAX_FRAGMENT_UNIFORM_BLOCKS = 12,
87 		MAX_VERTEX_UNIFORM_BLOCKS = 12,
88 		MAX_UNIFORM_BUFFER_BINDINGS = MAX_FRAGMENT_UNIFORM_BLOCKS + MAX_VERTEX_UNIFORM_BLOCKS,   // Limited to 127 by SourceParameter.bufferIndex in Shader.hpp
89 		MAX_UNIFORM_BLOCK_SIZE = 16384,
90 		MAX_CLIP_PLANES = 6,
91 		MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS = 64,
92 		MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS = 64,
93 		MIN_PROGRAM_TEXEL_OFFSET = -8,
94 		MAX_PROGRAM_TEXEL_OFFSET = 7,
95 		MAX_TEXTURE_LOD = MIPMAP_LEVELS - 2,   // Trilinear accesses lod+1
96 		RENDERTARGETS = 8,
97 		NUM_TEMPORARY_REGISTERS = 4096,
98 		MAX_SHADER_CALL_STACK_SIZE = 64,
99 		MAX_SHADER_ENABLE_STACK_SIZE = 1 + 24,
100 	};
101 }
102 
103 #endif   // sw_Config_hpp
104