| 2290 | } |
| 2291 | |
| 2292 | s32 compile_variant(FileBuffer &fb |
| 2293 | , Vector<UniformMetadata> *meta |
| 2294 | , Vector<ShaderResource::Sampler> *sampler_meta |
| 2295 | , const DynamicString &shader |
| 2296 | , const Vector<DynamicString> &defines |
| 2297 | , bool metadata_only |
| 2298 | ) |
| 2299 | { |
| 2300 | BinaryWriter bw(fb); |
| 2301 | |
| 2302 | const StringId32 shader_name = shader_variant_id(shader.c_str(), defines); |
| 2303 | const ShaderPermutation sp_default(default_allocator()); |
| 2304 | const ShaderPermutation &sp = hash_map::get(_shaders, shader, sp_default); |
| 2305 | const DynamicString &bgfx_shader = sp._bgfx_shader; |
| 2306 | const DynamicString &render_state = sp._render_state; |
| 2307 | |
| 2308 | RETURN_IF_FALSE(SHADER_RESOURCE, hash_map::has(_bgfx_shaders, sp._bgfx_shader) |
| 2309 | , _opts |
| 2310 | , "Unknown bgfx shader: '%s'" |
| 2311 | , bgfx_shader.c_str() |
| 2312 | ); |
| 2313 | RETURN_IF_FALSE(SHADER_RESOURCE, hash_map::has(_render_states, sp._render_state) |
| 2314 | , _opts |
| 2315 | , "Unknown render state: '%s'" |
| 2316 | , render_state.c_str() |
| 2317 | ); |
| 2318 | |
| 2319 | RenderState::State state; |
| 2320 | s32 err = compile_render_state(state, render_state.c_str(), defines); |
| 2321 | ENSURE_OR_RETURN(SHADER_RESOURCE, err == 0, _opts); |
| 2322 | |
| 2323 | u32 stencil_front; |
| 2324 | u32 stencil_back; |
| 2325 | state.encode_stencil(stencil_front, stencil_back); |
| 2326 | |
| 2327 | bw.write(shader_name._id); // Shader name |
| 2328 | bw.write(state.encode()); // Render state |
| 2329 | bw.write(stencil_front); // Stencil |
| 2330 | bw.write(stencil_back); // |
| 2331 | return compile_bgfx_shader(fb, meta, sampler_meta, shader, bgfx_shader.c_str(), defines, metadata_only); // Sampler states and shader code |
| 2332 | } |
| 2333 | |
| 2334 | s32 compile() |
| 2335 | { |
no test coverage detected