int glsl_type::sampler_coordinate_components() const { assert(is_sampler()); int size; switch (sampler_dimensionality) { case GLSL_SAMPLER_DIM_1D: case GLSL_SAMPLER_DIM_BUF: size = 1; break; case GLSL_SAMPLER_DIM_2D: case GLSL_SAMPLER_DIM_RECT: case GLSL_SAMPLER_DIM_MS: case GLSL_SAMPLER_DIM_EXTERNAL: size = 2; break; case GLSL_SAMPLER_DIM_3D: case GLSL_SAMPLER_DIM_CUBE: size = 3; break; default: assert(!"Should not get here."); size = 1; break; } /* Array textures need an additional component for the array index. */ if (sampler_array) size += 1; return size; }
static void dx9_fill_constant_table(ShaderConstantTable& out_constants, ShaderConstantTable& out_samplers, ID3DXConstantTable* constant_table) { out_constants.clear(); out_samplers.clear(); if( constant_table ) { HRESULT hr = S_OK; D3DXCONSTANTTABLE_DESC ct_desc; hr = constant_table->GetDesc(&ct_desc); validate_d3d_result(hr, true); for( uint32 i=0; i<ct_desc.Constants; ++i ) { D3DXHANDLE handle = constant_table->GetConstant(NULL, i); D3DXCONSTANT_DESC d3dx_constant_desc; UINT count = 1; hr = constant_table->GetConstantDesc(handle, &d3dx_constant_desc, &count); validate_d3d_result(hr, true); ShaderConstantDescr scd; scd.name = String(d3dx_constant_desc.Name); scd.register_index = d3dx_constant_desc.RegisterIndex; scd.register_count = d3dx_constant_desc.RegisterCount; if( is_sampler(d3dx_constant_desc.Type) ) { out_samplers.push_back(scd); } else { out_constants.push_back(scd); } } } }