void * NinePixelShader9_GetVariant( struct NinePixelShader9 *This ) { /* GetVariant is called from nine_context, thus we can * get pipe directly */ struct pipe_context *pipe = This->base.device->context.pipe; void *cso; uint64_t key; key = This->next_key; if (key == This->last_key) return This->last_cso; cso = nine_shader_variant_get(&This->variant, key); if (!cso) { struct NineDevice9 *device = This->base.device; struct nine_shader_info info; HRESULT hr; info.type = PIPE_SHADER_FRAGMENT; info.const_i_base = NINE_CONST_I_BASE(device->max_ps_const_f) / 16; info.const_b_base = NINE_CONST_B_BASE(device->max_ps_const_f) / 16; info.byte_code = This->byte_code.tokens; info.sampler_mask_shadow = key & 0xffff; info.sampler_ps1xtypes = key; info.fog_enable = device->context.rs[D3DRS_FOGENABLE]; info.fog_mode = device->context.rs[D3DRS_FOGTABLEMODE]; info.force_color_in_centroid = key >> 34 & 1; info.projected = (key >> 48) & 0xffff; info.process_vertices = false; hr = nine_translate_shader(This->base.device, &info, pipe); if (FAILED(hr)) return NULL; nine_shader_variant_add(&This->variant, key, info.cso); cso = info.cso; } This->last_key = key; This->last_cso = cso; return cso; }
void * NinePixelShader9_GetVariant( struct NinePixelShader9 *This, uint32_t key ) { void *cso = nine_shader_variant_get(&This->variant, key); if (!cso) { struct nine_shader_info info; HRESULT hr; info.type = PIPE_SHADER_FRAGMENT; info.byte_code = This->byte_code.tokens; info.sampler_mask_shadow = key & 0xffff; info.sampler_ps1xtypes = key; hr = nine_translate_shader(This->base.device, &info); if (FAILED(hr)) return NULL; nine_shader_variant_add(&This->variant, key, info.cso); cso = info.cso; } return cso; }
void * NineVertexShader9_GetVariant( struct NineVertexShader9 *This ) { void *cso; uint64_t key; key = This->next_key; if (key == This->last_key) return This->last_cso; cso = nine_shader_variant_get(&This->variant, key); if (!cso) { struct NineDevice9 *device = This->base.device; struct nine_shader_info info; HRESULT hr; info.type = PIPE_SHADER_VERTEX; info.const_i_base = NINE_CONST_I_BASE(device->max_vs_const_f) / 16; info.const_b_base = NINE_CONST_B_BASE(device->max_vs_const_f) / 16; info.byte_code = This->byte_code.tokens; info.sampler_mask_shadow = key & 0xf; info.fog_enable = device->state.rs[D3DRS_FOGENABLE]; info.point_size_min = asfloat(device->state.rs[D3DRS_POINTSIZE_MIN]); info.point_size_max = asfloat(device->state.rs[D3DRS_POINTSIZE_MAX]); info.swvp_on = device->swvp; info.process_vertices = false; hr = nine_translate_shader(This->base.device, &info); if (FAILED(hr)) return NULL; nine_shader_variant_add(&This->variant, key, info.cso); cso = info.cso; } This->last_key = key; This->last_cso = cso; return cso; }