| 195 | } |
| 196 | |
| 197 | void Pipeline::create(u16 width, u16 height, const RenderSettings &render_settings) |
| 198 | { |
| 199 | _render_settings = render_settings; |
| 200 | |
| 201 | reset(width, height); |
| 202 | |
| 203 | _color_map = bgfx::createUniform("s_color_map", bgfx::UniformType::Sampler); |
| 204 | _depth_map = bgfx::createUniform("s_depth_map", bgfx::UniformType::Sampler); |
| 205 | |
| 206 | _selection_map = bgfx::createUniform("s_selection_map", bgfx::UniformType::Sampler); |
| 207 | _selection_depth_map = bgfx::createUniform("s_selection_depth_map", bgfx::UniformType::Sampler); |
| 208 | |
| 209 | _outline_color_map = bgfx::createUniform("s_color_map", bgfx::UniformType::Sampler); |
| 210 | _outline_color = bgfx::createUniform("u_outline_color", bgfx::UniformType::Vec4); |
| 211 | _unit_id = bgfx::createUniform("u_unit_id", bgfx::UniformType::Vec4); |
| 212 | _outline_msaa_samples = bgfx::createUniform("u_outline_msaa_samples", bgfx::UniformType::Vec4); |
| 213 | |
| 214 | _u_cascaded_shadow_map = bgfx::createUniform("u_cascaded_shadow_map", bgfx::UniformType::Sampler); |
| 215 | _u_cascaded_lights = bgfx::createUniform("u_cascaded_lights", bgfx::UniformType::Mat4, MAX_NUM_CASCADES); |
| 216 | _u_shadow_maps_texel_sizes = bgfx::createUniform("u_shadow_maps_texel_sizes", bgfx::UniformType::Vec4); |
| 217 | |
| 218 | // Create cascaded shadow map resources. |
| 219 | if (bgfx::isValid(_sun_shadow_map_texture)) |
| 220 | bgfx::destroy(_sun_shadow_map_texture); |
| 221 | _sun_shadow_map_texture = bgfx::createTexture2D((u16)_render_settings.sun_shadow_map_size.x |
| 222 | , (u16)_render_settings.sun_shadow_map_size.y |
| 223 | , false |
| 224 | , 1 |
| 225 | , bgfx::TextureFormat::D32F |
| 226 | , BGFX_TEXTURE_RT | BGFX_SAMPLER_COMPARE_LEQUAL |
| 227 | ); |
| 228 | const bgfx::TextureHandle fbtextures[] = |
| 229 | { |
| 230 | _sun_shadow_map_texture |
| 231 | }; |
| 232 | if (bgfx::isValid(_sun_shadow_map_frame_buffer)) |
| 233 | bgfx::destroy(_sun_shadow_map_frame_buffer); |
| 234 | _sun_shadow_map_frame_buffer = bgfx::createFrameBuffer(countof(fbtextures), fbtextures); |
| 235 | |
| 236 | // Create local-lights shadow map resources. |
| 237 | if (bgfx::isValid(_local_lights_shadow_map_texture)) |
| 238 | bgfx::destroy(_local_lights_shadow_map_texture); |
| 239 | _local_lights_shadow_map_texture = bgfx::createTexture2D((u16)_render_settings.local_lights_shadow_map_size.x |
| 240 | , (u16)_render_settings.local_lights_shadow_map_size.y |
| 241 | , false |
| 242 | , 1 |
| 243 | , bgfx::TextureFormat::D24S8 |
| 244 | , BGFX_TEXTURE_RT | BGFX_SAMPLER_COMPARE_LEQUAL |
| 245 | ); |
| 246 | const bgfx::TextureHandle llfbtextures[] = |
| 247 | { |
| 248 | _local_lights_shadow_map_texture |
| 249 | }; |
| 250 | if (bgfx::isValid(_local_lights_shadow_map_frame_buffer)) |
| 251 | bgfx::destroy(_local_lights_shadow_map_frame_buffer); |
| 252 | _local_lights_shadow_map_frame_buffer = bgfx::createFrameBuffer(countof(llfbtextures), llfbtextures); |
| 253 | |
| 254 | // FIXME: this is a pretty dumb allocation scheme but it's fine for now. |
no test coverage detected