本文整理匯總了C++中Elements函數的典型用法代碼示例。如果您正苦於以下問題:C++ Elements函數的具體用法?C++ Elements怎麽用?C++ Elements使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Elements函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: vbo_exec_vtx_init
void vbo_exec_vtx_init( struct vbo_exec_context *exec )
{
struct gl_context *ctx = exec->ctx;
struct vbo_context *vbo = vbo_context(ctx);
GLuint i;
/* Allocate a buffer object. Will just reuse this object
* continuously, unless vbo_use_buffer_objects() is called to enable
* use of real VBOs.
*/
_mesa_reference_buffer_object(ctx,
&exec->vtx.bufferobj,
ctx->Shared->NullBufferObj);
ASSERT(!exec->vtx.buffer_map);
exec->vtx.buffer_map = _mesa_align_malloc(VBO_VERT_BUFFER_SIZE, 64);
exec->vtx.buffer_ptr = exec->vtx.buffer_map;
vbo_exec_vtxfmt_init( exec );
_mesa_noop_vtxfmt_init(&exec->vtxfmt_noop);
for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) {
ASSERT(i < Elements(exec->vtx.attrsz));
exec->vtx.attrsz[i] = 0;
ASSERT(i < Elements(exec->vtx.attrtype));
exec->vtx.attrtype[i] = GL_FLOAT;
ASSERT(i < Elements(exec->vtx.active_sz));
exec->vtx.active_sz[i] = 0;
}
for (i = 0 ; i < VERT_ATTRIB_MAX; i++) {
ASSERT(i < Elements(exec->vtx.inputs));
ASSERT(i < Elements(exec->vtx.arrays));
exec->vtx.inputs[i] = &exec->vtx.arrays[i];
}
{
struct gl_client_array *arrays = exec->vtx.arrays;
unsigned i;
memcpy(arrays, &vbo->currval[VBO_ATTRIB_POS],
VERT_ATTRIB_FF_MAX * sizeof(arrays[0]));
for (i = 0; i < VERT_ATTRIB_FF_MAX; ++i) {
struct gl_client_array *array;
array = &arrays[VERT_ATTRIB_FF(i)];
array->BufferObj = NULL;
_mesa_reference_buffer_object(ctx, &array->BufferObj,
vbo->currval[VBO_ATTRIB_POS+i].BufferObj);
}
memcpy(arrays + VERT_ATTRIB_GENERIC(0),
&vbo->currval[VBO_ATTRIB_GENERIC0],
VERT_ATTRIB_GENERIC_MAX * sizeof(arrays[0]));
for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; ++i) {
struct gl_client_array *array;
array = &arrays[VERT_ATTRIB_GENERIC(i)];
array->BufferObj = NULL;
_mesa_reference_buffer_object(ctx, &array->BufferObj,
vbo->currval[VBO_ATTRIB_GENERIC0+i].BufferObj);
}
}
exec->vtx.vertex_size = 0;
exec->begin_vertices_flags = FLUSH_UPDATE_CURRENT;
}
示例2: drm_create_adapter
static HRESULT WINAPI
drm_create_adapter( int fd,
ID3DAdapter9 **ppAdapter )
{
struct d3dadapter9drm_context *ctx = CALLOC_STRUCT(d3dadapter9drm_context);
HRESULT hr;
int i, different_device;
const char *paths[] = {
getenv("D3D9_DRIVERS_PATH"),
getenv("D3D9_DRIVERS_DIR"),
PIPE_SEARCH_DIR
};
if (!ctx) { return E_OUTOFMEMORY; }
ctx->base.destroy = drm_destroy;
fd = loader_get_user_preferred_fd(fd, &different_device);
ctx->base.linear_framebuffer = !!different_device;
/* use pipe-loader to dlopen appropriate drm driver */
if (!pipe_loader_drm_probe_fd(&ctx->dev, fd, FALSE)) {
DBG("Failed to probe drm fd %d.\n", fd);
FREE(ctx);
close(fd);
return D3DERR_DRIVERINTERNALERROR;
}
/* use pipe-loader to create a drm screen (hal) */
ctx->base.hal = NULL;
for (i = 0; !ctx->base.hal && i < Elements(paths); ++i) {
if (!paths[i]) { continue; }
ctx->base.hal = pipe_loader_create_screen(ctx->dev, paths[i]);
}
if (!ctx->base.hal) {
DBG("Unable to load requested driver.\n");
pipe_loader_release(&ctx->dev, 1);
FREE(ctx);
return D3DERR_DRIVERINTERNALERROR;
}
/* wrap it to create a software screen that can share resources */
if (pipe_loader_sw_probe_wrapped(&ctx->swdev, ctx->base.hal)) {
ctx->base.ref = NULL;
for (i = 0; !ctx->base.ref && i < Elements(paths); ++i) {
if (!paths[i]) { continue; }
ctx->base.ref = pipe_loader_create_screen(ctx->swdev, paths[i]);
}
}
if (!ctx->base.ref) {
DBG("Couldn't wrap drm screen to swrast screen. Software devices "
"will be unavailable.\n");
}
/* read out PCI info */
read_descriptor(&ctx->base, fd);
/* create and return new ID3DAdapter9 */
hr = NineAdapter9_new(&ctx->base, (struct NineAdapter9 **)ppAdapter);
if (FAILED(hr)) {
if (ctx->swdev) { pipe_loader_release(&ctx->swdev, 1); }
pipe_loader_release(&ctx->dev, 1);
FREE(ctx);
return hr;
}
return D3D_OK;
}
示例3: arb_input_attrib_string
//.........這裏部分代碼省略.........
"vertex.texcoord[2]",
"vertex.texcoord[3]",
"vertex.texcoord[4]",
"vertex.texcoord[5]",
"vertex.texcoord[6]",
"vertex.texcoord[7]",
"vertex.(sixteen)", /* VERT_ATTRIB_POINT_SIZE */
"vertex.attrib[0]",
"vertex.attrib[1]",
"vertex.attrib[2]",
"vertex.attrib[3]",
"vertex.attrib[4]",
"vertex.attrib[5]",
"vertex.attrib[6]",
"vertex.attrib[7]",
"vertex.attrib[8]",
"vertex.attrib[9]",
"vertex.attrib[10]",
"vertex.attrib[11]",
"vertex.attrib[12]",
"vertex.attrib[13]",
"vertex.attrib[14]",
"vertex.attrib[15]" /* MAX_VARYING = 16 */
};
static const char *const fragAttribs[] = {
"fragment.position",
"fragment.color.primary",
"fragment.color.secondary",
"fragment.fogcoord",
"fragment.texcoord[0]",
"fragment.texcoord[1]",
"fragment.texcoord[2]",
"fragment.texcoord[3]",
"fragment.texcoord[4]",
"fragment.texcoord[5]",
"fragment.texcoord[6]",
"fragment.texcoord[7]",
"fragment.(twelve)", /* VARYING_SLOT_PSIZ */
"fragment.(thirteen)", /* VARYING_SLOT_BFC0 */
"fragment.(fourteen)", /* VARYING_SLOT_BFC1 */
"fragment.(fifteen)", /* VARYING_SLOT_EDGE */
"fragment.(sixteen)", /* VARYING_SLOT_CLIP_VERTEX */
"fragment.(seventeen)", /* VARYING_SLOT_CLIP_DIST0 */
"fragment.(eighteen)", /* VARYING_SLOT_CLIP_DIST1 */
"fragment.(nineteen)", /* VARYING_SLOT_PRIMITIVE_ID */
"fragment.(twenty)", /* VARYING_SLOT_LAYER */
"fragment.(twenty-one)", /* VARYING_SLOT_FACE */
"fragment.(twenty-two)", /* VARYING_SLOT_PNTC */
"fragment.varying[0]",
"fragment.varying[1]",
"fragment.varying[2]",
"fragment.varying[3]",
"fragment.varying[4]",
"fragment.varying[5]",
"fragment.varying[6]",
"fragment.varying[7]",
"fragment.varying[8]",
"fragment.varying[9]",
"fragment.varying[10]",
"fragment.varying[11]",
"fragment.varying[12]",
"fragment.varying[13]",
"fragment.varying[14]",
"fragment.varying[15]",
"fragment.varying[16]",
"fragment.varying[17]",
"fragment.varying[18]",
"fragment.varying[19]",
"fragment.varying[20]",
"fragment.varying[21]",
"fragment.varying[22]",
"fragment.varying[23]",
"fragment.varying[24]",
"fragment.varying[25]",
"fragment.varying[26]",
"fragment.varying[27]",
"fragment.varying[28]",
"fragment.varying[29]",
"fragment.varying[30]",
"fragment.varying[31]", /* MAX_VARYING = 32 */
};
/* sanity checks */
STATIC_ASSERT(Elements(vertAttribs) == VERT_ATTRIB_MAX);
STATIC_ASSERT(Elements(fragAttribs) == VARYING_SLOT_MAX);
assert(strcmp(vertAttribs[VERT_ATTRIB_TEX0], "vertex.texcoord[0]") == 0);
assert(strcmp(vertAttribs[VERT_ATTRIB_GENERIC15], "vertex.attrib[15]") == 0);
assert(strcmp(fragAttribs[VARYING_SLOT_TEX0], "fragment.texcoord[0]") == 0);
assert(strcmp(fragAttribs[VARYING_SLOT_VAR0+15], "fragment.varying[15]") == 0);
if (progType == GL_VERTEX_PROGRAM_ARB) {
assert(index < Elements(vertAttribs));
return vertAttribs[index];
}
else {
assert(progType == GL_FRAGMENT_PROGRAM_ARB);
assert(index < Elements(fragAttribs));
return fragAttribs[index];
}
}
示例4: st_create_context_priv
static struct st_context *
st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
const struct st_config_options *options)
{
struct pipe_screen *screen = pipe->screen;
uint i;
struct st_context *st = ST_CALLOC_STRUCT( st_context );
st->options = *options;
ctx->st = st;
st->ctx = ctx;
st->pipe = pipe;
/* XXX: this is one-off, per-screen init: */
st_debug_init();
/* state tracker needs the VBO module */
_vbo_CreateContext(ctx);
st->dirty.mesa = ~0;
st->dirty.st = ~0;
/* Create upload manager for vertex data for glBitmap, glDrawPixels,
* glClear, etc.
*/
st->uploader = u_upload_create(st->pipe, 65536, 4, PIPE_BIND_VERTEX_BUFFER);
if (!screen->get_param(screen, PIPE_CAP_USER_INDEX_BUFFERS)) {
st->indexbuf_uploader = u_upload_create(st->pipe, 128 * 1024, 4,
PIPE_BIND_INDEX_BUFFER);
}
if (!screen->get_param(screen, PIPE_CAP_USER_CONSTANT_BUFFERS)) {
unsigned alignment =
screen->get_param(screen, PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT);
st->constbuf_uploader = u_upload_create(pipe, 128 * 1024, alignment,
PIPE_BIND_CONSTANT_BUFFER);
}
st->cso_context = cso_create_context(pipe);
st_init_atoms( st );
st_init_bitmap(st);
st_init_clear(st);
st_init_draw( st );
/* Choose texture target for glDrawPixels, glBitmap, renderbuffers */
if (pipe->screen->get_param(pipe->screen, PIPE_CAP_NPOT_TEXTURES))
st->internal_target = PIPE_TEXTURE_2D;
else
st->internal_target = PIPE_TEXTURE_RECT;
/* Vertex element objects used for drawing rectangles for glBitmap,
* glDrawPixels, glClear, etc.
*/
for (i = 0; i < Elements(st->velems_util_draw); i++) {
memset(&st->velems_util_draw[i], 0, sizeof(struct pipe_vertex_element));
st->velems_util_draw[i].src_offset = i * 4 * sizeof(float);
st->velems_util_draw[i].instance_divisor = 0;
st->velems_util_draw[i].vertex_buffer_index =
cso_get_aux_vertex_buffer_slot(st->cso_context);
st->velems_util_draw[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
}
/* we want all vertex data to be placed in buffer objects */
vbo_use_buffer_objects(ctx);
/* make sure that no VBOs are left mapped when we're drawing. */
vbo_always_unmap_buffers(ctx);
/* Need these flags:
*/
st->ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
st->ctx->VertexProgram._MaintainTnlProgram = GL_TRUE;
st->pixel_xfer.cache = _mesa_new_program_cache();
st->has_stencil_export =
screen->get_param(screen, PIPE_CAP_SHADER_STENCIL_EXPORT);
st->has_shader_model3 = screen->get_param(screen, PIPE_CAP_SM3);
st->has_etc1 = screen->is_format_supported(screen, PIPE_FORMAT_ETC1_RGB8,
PIPE_TEXTURE_2D, 0,
PIPE_BIND_SAMPLER_VIEW);
st->prefer_blit_based_texture_transfer = screen->get_param(screen,
PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER);
st->needs_texcoord_semantic =
screen->get_param(screen, PIPE_CAP_TGSI_TEXCOORD);
st->apply_texture_swizzle_to_border_color =
!!(screen->get_param(screen, PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK) &
(PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 |
PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_R600));
st->has_time_elapsed =
screen->get_param(screen, PIPE_CAP_QUERY_TIME_ELAPSED);
//.........這裏部分代碼省略.........
示例5: NS_ADDREF
NS_IMETHODIMP
HTMLFieldSetElement::GetElements(nsIDOMHTMLCollection** aElements)
{
NS_ADDREF(*aElements = Elements());
return NS_OK;
}
示例6: parse_declaration
static boolean parse_declaration( struct translate_ctx *ctx )
{
struct tgsi_full_declaration decl;
uint file;
struct parsed_dcl_bracket brackets[2];
int num_brackets;
uint writemask;
const char *cur;
uint advance;
boolean is_vs_input;
boolean is_imm_array;
assert(Elements(semantic_names) == TGSI_SEMANTIC_COUNT);
assert(Elements(interpolate_names) == TGSI_INTERPOLATE_COUNT);
if (!eat_white( &ctx->cur )) {
report_error( ctx, "Syntax error" );
return FALSE;
}
if (!parse_register_dcl( ctx, &file, brackets, &num_brackets))
return FALSE;
if (!parse_opt_writemask( ctx, &writemask ))
return FALSE;
decl = tgsi_default_full_declaration();
decl.Declaration.File = file;
decl.Declaration.UsageMask = writemask;
if (num_brackets == 1) {
decl.Range.First = brackets[0].first;
decl.Range.Last = brackets[0].last;
} else {
decl.Range.First = brackets[1].first;
decl.Range.Last = brackets[1].last;
decl.Declaration.Dimension = 1;
decl.Dim.Index2D = brackets[0].first;
}
is_vs_input = (file == TGSI_FILE_INPUT &&
ctx->processor == TGSI_PROCESSOR_VERTEX);
is_imm_array = (file == TGSI_FILE_IMMEDIATE_ARRAY);
cur = ctx->cur;
eat_opt_white( &cur );
if (*cur == ',' && !is_vs_input) {
uint i, j;
cur++;
eat_opt_white( &cur );
if (file == TGSI_FILE_RESOURCE) {
for (i = 0; i < TGSI_TEXTURE_COUNT; i++) {
if (str_match_no_case(&cur, texture_names[i])) {
if (!is_digit_alpha_underscore(cur)) {
decl.Resource.Resource = i;
break;
}
}
}
if (i == TGSI_TEXTURE_COUNT) {
report_error(ctx, "Expected texture target");
return FALSE;
}
eat_opt_white( &cur );
if (*cur != ',') {
report_error( ctx, "Expected `,'" );
return FALSE;
}
++cur;
eat_opt_white( &cur );
for (j = 0; j < 4; ++j) {
for (i = 0; i < PIPE_TYPE_COUNT; ++i) {
if (str_match_no_case(&cur, type_names[i])) {
if (!is_digit_alpha_underscore(cur)) {
switch (j) {
case 0:
decl.Resource.ReturnTypeX = i;
break;
case 1:
decl.Resource.ReturnTypeY = i;
break;
case 2:
decl.Resource.ReturnTypeZ = i;
break;
case 3:
decl.Resource.ReturnTypeW = i;
break;
default:
assert(0);
}
break;
}
}
}
if (i == PIPE_TYPE_COUNT) {
if (j == 0 || j > 2) {
report_error(ctx, "Expected type name");
return FALSE;
}
break;
//.........這裏部分代碼省略.........
示例7: Integrate
//.........這裏部分代碼省略.........
bisectdim = region->result[maxcomp].bisectdim;
bL = ®ionL->bounds[bisectdim];
bR = ®ionR->bounds[bisectdim];
bL->upper = bR->lower = .5*(bL->upper + bL->lower);
Sample(&rule, regionL, flags);
Sample(&rule, regionR, flags);
for( comp = 0; comp < ncomp_; ++comp ) {
cResult *r = ®ion->result[comp];
Result *rL = ®ionL->result[comp];
Result *rR = ®ionR->result[comp];
Totals *tot = &totals[comp];
real diff, err, w, avg, sigsq;
tot->lastavg += diff = rL->avg + rR->avg - r->avg;
diff = fabs(.25*diff);
err = rL->err + rR->err;
if( err > 0 ) {
creal c = 1 + 2*diff/err;
rL->err *= c;
rR->err *= c;
}
rL->err += diff;
rR->err += diff;
tot->lasterr += rL->err + rR->err - r->err;
tot->weightsum += w = 1/Max(Sq(tot->lasterr), NOTZERO);
sigsq = 1/tot->weightsum;
tot->avgsum += w*tot->lastavg;
avg = sigsq*tot->avgsum;
tot->chisum += w *= tot->lastavg - tot->guess;
tot->chisqsum += w*tot->lastavg;
tot->chisq = tot->chisqsum - avg*tot->chisum;
if( LAST ) {
tot->avg = tot->lastavg;
tot->err = tot->lasterr;
}
else {
tot->avg = avg;
tot->err = sqrt(sigsq);
}
}
free(region);
region = NULL;
}
for( comp = 0; comp < ncomp_; ++comp ) {
cTotals *tot = &totals[comp];
integral[comp] = tot->avg;
error[comp] = tot->err;
prob[comp] = ChiSquare(tot->chisq, nregions_ - 1);
}
#ifdef MLVERSION
if( REGIONS ) {
MLPutFunction(stdlink, "List", 2);
MLPutFunction(stdlink, "List", nregions_);
for( region = anchor; region; region = region->next ) {
real lower[NDIM], upper[NDIM];
for( dim = 0; dim < ndim_; ++dim ) {
cBounds *b = ®ion->bounds[dim];
lower[dim] = b->lower;
upper[dim] = b->upper;
}
MLPutFunction(stdlink, "Cuba`Cuhre`region", 3);
MLPutRealList(stdlink, lower, ndim_);
MLPutRealList(stdlink, upper, ndim_);
MLPutFunction(stdlink, "List", ncomp_);
for( comp = 0; comp < ncomp_; ++comp ) {
cResult *r = ®ion->result[comp];
real res[] = {r->avg, r->err};
MLPutRealList(stdlink, res, Elements(res));
}
}
}
#endif
#ifdef MLVERSION
abort:
#endif
if( region ) free(region);
while( (region = anchor) ) {
anchor = anchor->next;
free(region);
}
free(rule.x);
RuleFree(&rule);
return fail;
}
示例8: lp_build_sample_mipmap
//.........這裏部分代碼省略.........
lp_build_mipmap_level_sizes(bld, ilevel0,
&size0,
&row_stride0_vec, &img_stride0_vec);
data_ptr0 = lp_build_get_mipmap_level(bld, ilevel0);
if (img_filter == PIPE_TEX_FILTER_NEAREST) {
lp_build_sample_image_nearest(bld,
size0,
row_stride0_vec, img_stride0_vec,
data_ptr0, s, t, r,
&colors0_lo, &colors0_hi);
}
else {
assert(img_filter == PIPE_TEX_FILTER_LINEAR);
lp_build_sample_image_linear(bld,
size0,
row_stride0_vec, img_stride0_vec,
data_ptr0, s, t, r,
&colors0_lo, &colors0_hi);
}
/* Store the first level's colors in the output variables */
LLVMBuildStore(builder, colors0_lo, colors_lo_var);
LLVMBuildStore(builder, colors0_hi, colors_hi_var);
if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) {
LLVMValueRef h16_scale = lp_build_const_float(bld->gallivm, 256.0);
LLVMTypeRef i32_type = LLVMIntTypeInContext(bld->gallivm->context, 32);
struct lp_build_if_state if_ctx;
LLVMValueRef need_lerp;
lod_fpart = LLVMBuildFMul(builder, lod_fpart, h16_scale, "");
lod_fpart = LLVMBuildFPToSI(builder, lod_fpart, i32_type, "lod_fpart.fixed16");
/* need_lerp = lod_fpart > 0 */
need_lerp = LLVMBuildICmp(builder, LLVMIntSGT,
lod_fpart, LLVMConstNull(i32_type),
"need_lerp");
lp_build_if(&if_ctx, bld->gallivm, need_lerp);
{
struct lp_build_context h16_bld;
lp_build_context_init(&h16_bld, bld->gallivm, lp_type_ufixed(16));
/* sample the second mipmap level */
lp_build_mipmap_level_sizes(bld, ilevel1,
&size1,
&row_stride1_vec, &img_stride1_vec);
data_ptr1 = lp_build_get_mipmap_level(bld, ilevel1);
if (img_filter == PIPE_TEX_FILTER_NEAREST) {
lp_build_sample_image_nearest(bld,
size1,
row_stride1_vec, img_stride1_vec,
data_ptr1, s, t, r,
&colors1_lo, &colors1_hi);
}
else {
lp_build_sample_image_linear(bld,
size1,
row_stride1_vec, img_stride1_vec,
data_ptr1, s, t, r,
&colors1_lo, &colors1_hi);
}
/* interpolate samples from the two mipmap levels */
lod_fpart = LLVMBuildTrunc(builder, lod_fpart, h16_bld.elem_type, "");
lod_fpart = lp_build_broadcast_scalar(&h16_bld, lod_fpart);
#if HAVE_LLVM == 0x208
/* This is a work-around for a bug in LLVM 2.8.
* Evidently, something goes wrong in the construction of the
* lod_fpart short[8] vector. Adding this no-effect shuffle seems
* to force the vector to be properly constructed.
* Tested with mesa-demos/src/tests/mipmap_limits.c (press t, f).
*/
{
LLVMValueRef shuffles[8], shuffle;
int i;
assert(h16_bld.type.length <= Elements(shuffles));
for (i = 0; i < h16_bld.type.length; i++)
shuffles[i] = lp_build_const_int32(bld->gallivm, 2 * (i & 1));
shuffle = LLVMConstVector(shuffles, h16_bld.type.length);
lod_fpart = LLVMBuildShuffleVector(builder,
lod_fpart, lod_fpart,
shuffle, "");
}
#endif
colors0_lo = lp_build_lerp(&h16_bld, lod_fpart,
colors0_lo, colors1_lo);
colors0_hi = lp_build_lerp(&h16_bld, lod_fpart,
colors0_hi, colors1_hi);
LLVMBuildStore(builder, colors0_lo, colors_lo_var);
LLVMBuildStore(builder, colors0_hi, colors_hi_var);
}
lp_build_endif(&if_ctx);
}
}
示例9: Length
JSObject*
CryptoBuffer::ToUint8Array(JSContext* aCx) const
{
return Uint8Array::Create(aCx, Length(), Elements());
}
示例10: llvmpipe_update_derived
/**
* Handle state changes.
* Called just prior to drawing anything (pipe::draw_arrays(), etc).
*
* Hopefully this will remain quite simple, otherwise need to pull in
* something like the state tracker mechanism.
*/
void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe )
{
struct llvmpipe_screen *lp_screen = llvmpipe_screen(llvmpipe->pipe.screen);
/* Check for updated textures.
*/
if (llvmpipe->tex_timestamp != lp_screen->timestamp) {
llvmpipe->tex_timestamp = lp_screen->timestamp;
llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW;
}
if (llvmpipe->dirty & (LP_NEW_RASTERIZER |
LP_NEW_FS |
LP_NEW_VS))
compute_vertex_info( llvmpipe );
if (llvmpipe->dirty & (LP_NEW_FS |
LP_NEW_FRAMEBUFFER |
LP_NEW_BLEND |
LP_NEW_SCISSOR |
LP_NEW_DEPTH_STENCIL_ALPHA |
LP_NEW_RASTERIZER |
LP_NEW_SAMPLER |
LP_NEW_SAMPLER_VIEW |
LP_NEW_OCCLUSION_QUERY))
llvmpipe_update_fs( llvmpipe );
if (llvmpipe->dirty & (LP_NEW_FS |
LP_NEW_RASTERIZER))
llvmpipe_update_setup( llvmpipe );
if (llvmpipe->dirty & LP_NEW_BLEND_COLOR)
lp_setup_set_blend_color(llvmpipe->setup,
&llvmpipe->blend_color);
if (llvmpipe->dirty & LP_NEW_SCISSOR)
lp_setup_set_scissors(llvmpipe->setup, llvmpipe->scissors);
if (llvmpipe->dirty & LP_NEW_DEPTH_STENCIL_ALPHA) {
lp_setup_set_alpha_ref_value(llvmpipe->setup,
llvmpipe->depth_stencil->alpha.ref_value);
lp_setup_set_stencil_ref_values(llvmpipe->setup,
llvmpipe->stencil_ref.ref_value);
}
if (llvmpipe->dirty & LP_NEW_CONSTANTS)
lp_setup_set_fs_constants(llvmpipe->setup,
Elements(llvmpipe->constants[PIPE_SHADER_FRAGMENT]),
llvmpipe->constants[PIPE_SHADER_FRAGMENT]);
if (llvmpipe->dirty & (LP_NEW_SAMPLER_VIEW))
lp_setup_set_fragment_sampler_views(llvmpipe->setup,
llvmpipe->num_sampler_views[PIPE_SHADER_FRAGMENT],
llvmpipe->sampler_views[PIPE_SHADER_FRAGMENT]);
if (llvmpipe->dirty & (LP_NEW_SAMPLER))
lp_setup_set_fragment_sampler_state(llvmpipe->setup,
llvmpipe->num_samplers[PIPE_SHADER_FRAGMENT],
llvmpipe->samplers[PIPE_SHADER_FRAGMENT]);
llvmpipe->dirty = 0;
}
示例11: st_translate_geometry_program
//.........這裏部分代碼省略.........
gs_output_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
gs_output_semantic_index[slot] = 0;
break;
case VARYING_SLOT_CLIP_DIST1:
gs_output_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
gs_output_semantic_index[slot] = 1;
break;
case VARYING_SLOT_LAYER:
gs_output_semantic_name[slot] = TGSI_SEMANTIC_LAYER;
gs_output_semantic_index[slot] = 0;
break;
case VARYING_SLOT_PRIMITIVE_ID:
gs_output_semantic_name[slot] = TGSI_SEMANTIC_PRIMID;
gs_output_semantic_index[slot] = 0;
break;
case VARYING_SLOT_VIEWPORT:
gs_output_semantic_name[slot] = TGSI_SEMANTIC_VIEWPORT_INDEX;
gs_output_semantic_index[slot] = 0;
break;
case VARYING_SLOT_TEX0:
case VARYING_SLOT_TEX1:
case VARYING_SLOT_TEX2:
case VARYING_SLOT_TEX3:
case VARYING_SLOT_TEX4:
case VARYING_SLOT_TEX5:
case VARYING_SLOT_TEX6:
case VARYING_SLOT_TEX7:
gs_output_semantic_name[slot] = st->needs_texcoord_semantic ?
TGSI_SEMANTIC_TEXCOORD : TGSI_SEMANTIC_GENERIC;
gs_output_semantic_index[slot] = (attr - VARYING_SLOT_TEX0);
break;
case VARYING_SLOT_VAR0:
default:
assert(slot < Elements(gs_output_semantic_name));
assert(attr >= VARYING_SLOT_VAR0);
gs_output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
gs_output_semantic_index[slot] = st->needs_texcoord_semantic ?
(attr - VARYING_SLOT_VAR0) : (attr - VARYING_SLOT_TEX0);
break;
}
}
}
/* find max output slot referenced to compute gs_num_outputs */
for (attr = 0; attr < VARYING_SLOT_MAX; attr++) {
if (outputMapping[attr] != ~0 && outputMapping[attr] > maxSlot)
maxSlot = outputMapping[attr];
}
gs_num_outputs = maxSlot + 1;
#if 0 /* debug */
{
GLuint i;
printf("outputMapping? %d\n", outputMapping ? 1 : 0);
if (outputMapping) {
printf("attr -> slot\n");
for (i = 0; i < 16; i++) {
printf(" %2d %3d\n", i, outputMapping[i]);
}
}
printf("slot sem_name sem_index\n");
for (i = 0; i < gs_num_outputs; i++) {
printf(" %2d %d %d\n",
i,
gs_output_semantic_name[i],
gs_output_semantic_index[i]);
示例12: Elements
#include "piglit-framework.h"
#include "piglit-util.h"
#include "rg-teximage-common.h"
#define WIDTH 256
#define HEIGHT 256
static float rgba_image[4 * WIDTH * HEIGHT];
static const GLenum internal_formats[] = {
GL_COMPRESSED_RG_RGTC2,
GL_COMPRESSED_SIGNED_RG_RGTC2,
GL_RG,
GL_RGBA,
};
GLuint tex[Elements(internal_formats)];
const unsigned num_tex = Elements(tex);
GLboolean pass = GL_TRUE;
int piglit_width = WIDTH * Elements(tex);
int piglit_height = HEIGHT;
int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
void
piglit_init(int argc, char **argv)
{
unsigned i;
GLfloat result[4 * WIDTH * HEIGHT];
piglit_require_extension("GL_ARB_texture_compression_rgtc");
示例13: vs_add_sampler_params
/**
* Emit instructions to move sampling parameters to the message registers.
*/
static int
vs_add_sampler_params(struct toy_compiler *tc, int msg_type, int base_mrf,
struct toy_src coords, int num_coords,
struct toy_src bias_or_lod, struct toy_src ref_or_si,
struct toy_src ddx, struct toy_src ddy, int num_derivs)
{
const unsigned coords_writemask = (1 << num_coords) - 1;
struct toy_dst m[3];
int num_params, i;
assert(num_coords <= 4);
assert(num_derivs <= 3 && num_derivs <= num_coords);
for (i = 0; i < Elements(m); i++)
m[i] = tdst(TOY_FILE_MRF, base_mrf + i, 0);
switch (msg_type) {
case GEN6_MSG_SAMPLER_SAMPLE_L:
tc_MOV(tc, tdst_writemask(m[0], coords_writemask), coords);
tc_MOV(tc, tdst_writemask(m[1], TOY_WRITEMASK_X), bias_or_lod);
num_params = 5;
break;
case GEN6_MSG_SAMPLER_SAMPLE_D:
tc_MOV(tc, tdst_writemask(m[0], coords_writemask), coords);
tc_MOV(tc, tdst_writemask(m[1], TOY_WRITEMASK_XZ),
tsrc_swizzle(ddx, 0, 0, 1, 1));
tc_MOV(tc, tdst_writemask(m[1], TOY_WRITEMASK_YW),
tsrc_swizzle(ddy, 0, 0, 1, 1));
if (num_derivs > 2) {
tc_MOV(tc, tdst_writemask(m[2], TOY_WRITEMASK_X),
tsrc_swizzle1(ddx, 2));
tc_MOV(tc, tdst_writemask(m[2], TOY_WRITEMASK_Y),
tsrc_swizzle1(ddy, 2));
}
num_params = 4 + num_derivs * 2;
break;
case GEN6_MSG_SAMPLER_SAMPLE_L_C:
tc_MOV(tc, tdst_writemask(m[0], coords_writemask), coords);
tc_MOV(tc, tdst_writemask(m[1], TOY_WRITEMASK_X), ref_or_si);
tc_MOV(tc, tdst_writemask(m[1], TOY_WRITEMASK_Y), bias_or_lod);
num_params = 6;
break;
case GEN6_MSG_SAMPLER_LD:
assert(num_coords <= 3);
tc_MOV(tc, tdst_writemask(tdst_d(m[0]), coords_writemask), coords);
tc_MOV(tc, tdst_writemask(tdst_d(m[0]), TOY_WRITEMASK_W), bias_or_lod);
if (tc->dev->gen >= ILO_GEN(7)) {
num_params = 4;
}
else {
tc_MOV(tc, tdst_writemask(tdst_d(m[1]), TOY_WRITEMASK_X), ref_or_si);
num_params = 5;
}
break;
case GEN6_MSG_SAMPLER_RESINFO:
tc_MOV(tc, tdst_writemask(tdst_d(m[0]), TOY_WRITEMASK_X), bias_or_lod);
num_params = 1;
break;
default:
tc_fail(tc, "unknown sampler opcode");
num_params = 0;
break;
}
return (num_params + 3) / 4;
}
示例14: drm_display_program
static boolean
drm_display_program(struct native_display *ndpy, int crtc_idx,
struct native_surface *nsurf, uint x, uint y,
const struct native_connector **nconns, int num_nconns,
const struct native_mode *nmode)
{
struct drm_display *drmdpy = drm_display(ndpy);
struct drm_surface *drmsurf = drm_surface(nsurf);
const struct drm_mode *drmmode = drm_mode(nmode);
uint32_t connector_ids[32];
uint32_t buffer_id;
drmModeModeInfo mode_tmp, *mode;
int i;
if (num_nconns > Elements(connector_ids)) {
_eglLog(_EGL_WARNING, "too many connectors (%d)", num_nconns);
num_nconns = Elements(connector_ids);
}
if (drmsurf) {
if (!drm_surface_init_framebuffers(&drmsurf->base, FALSE))
return FALSE;
buffer_id = drmsurf->front_fb.buffer_id;
/* the mode argument of drmModeSetCrtc is not constified */
mode_tmp = drmmode->mode;
mode = &mode_tmp;
}
else {
/* disable the CRTC */
buffer_id = 0;
mode = NULL;
num_nconns = 0;
}
for (i = 0; i < num_nconns; i++) {
struct drm_connector *drmconn = drm_connector(nconns[i]);
connector_ids[i] = drmconn->connector->connector_id;
}
if (!drm_display_set_crtc(&drmdpy->base, crtc_idx, buffer_id, x, y,
connector_ids, num_nconns, mode)) {
_eglLog(_EGL_WARNING, "failed to set CRTC %d", crtc_idx);
return FALSE;
}
if (drmdpy->shown_surfaces[crtc_idx])
drmdpy->shown_surfaces[crtc_idx]->is_shown = FALSE;
drmdpy->shown_surfaces[crtc_idx] = drmsurf;
/* remember the settings for buffer swapping */
if (drmsurf) {
uint32_t crtc_id = drmdpy->saved_crtcs[crtc_idx].crtc->crtc_id;
struct drm_crtc *drmcrtc = &drmsurf->current_crtc;
if (drmcrtc->crtc)
drmModeFreeCrtc(drmcrtc->crtc);
drmcrtc->crtc = drmModeGetCrtc(drmdpy->fd, crtc_id);
assert(num_nconns < Elements(drmcrtc->connectors));
memcpy(drmcrtc->connectors, connector_ids,
sizeof(*connector_ids) * num_nconns);
drmcrtc->num_connectors = num_nconns;
drmsurf->is_shown = TRUE;
}
return TRUE;
}
示例15: transform_inst
static void transform_inst(struct tgsi_transform_context *ctx,
struct tgsi_full_instruction *inst)
{
struct vs_transform_context *vsctx = (struct vs_transform_context *) ctx;
struct tgsi_full_instruction new_inst;
unsigned i;
if (!vsctx->first_instruction) {
vsctx->first_instruction = TRUE;
/* Insert the generic output for WPOS. */
emit_output(ctx, TGSI_SEMANTIC_GENERIC, vsctx->last_generic + 1,
TGSI_INTERPOLATE_PERSPECTIVE, vsctx->num_outputs);
/* Find a free temp for POSITION. */
for (i = 0; i < Elements(vsctx->temp_used); i++) {
if (!vsctx->temp_used[i]) {
emit_temp(ctx, i);
vsctx->pos_temp = i;
break;
}
}
}
if (inst->Instruction.Opcode == TGSI_OPCODE_END) {
/* MOV OUT[pos_output], TEMP[pos_temp]; */
new_inst = tgsi_default_full_instruction();
new_inst.Instruction.Opcode = TGSI_OPCODE_MOV;
new_inst.Instruction.NumDstRegs = 1;
new_inst.Dst[0].Register.File = TGSI_FILE_OUTPUT;
new_inst.Dst[0].Register.Index = vsctx->pos_output;
new_inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZW;
new_inst.Instruction.NumSrcRegs = 1;
new_inst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
new_inst.Src[0].Register.Index = vsctx->pos_temp;
ctx->emit_instruction(ctx, &new_inst);
/* MOV OUT[n-1], TEMP[pos_temp]; */
new_inst = tgsi_default_full_instruction();
new_inst.Instruction.Opcode = TGSI_OPCODE_MOV;
new_inst.Instruction.NumDstRegs = 1;
new_inst.Dst[0].Register.File = TGSI_FILE_OUTPUT;
new_inst.Dst[0].Register.Index = vsctx->num_outputs - 1;
new_inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_XYZW;
new_inst.Instruction.NumSrcRegs = 1;
new_inst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
new_inst.Src[0].Register.Index = vsctx->pos_temp;
ctx->emit_instruction(ctx, &new_inst);
vsctx->end_instruction = TRUE;
} else {
/* Not an END instruction. */
/* Fix writes to outputs. */
for (i = 0; i < inst->Instruction.NumDstRegs; i++) {
struct tgsi_full_dst_register *dst = &inst->Dst[i];
if (dst->Register.File == TGSI_FILE_OUTPUT) {
if (dst->Register.Index == vsctx->pos_output) {
/* Replace writes to OUT[pos_output] with TEMP[pos_temp]. */
dst->Register.File = TGSI_FILE_TEMPORARY;
dst->Register.Index = vsctx->pos_temp;
} else {
/* Not a position, good...
* Since we were changing the indices of output decls,
* we must redirect writes into them too. */
dst->Register.Index = vsctx->out_remap[dst->Register.Index];
}
}
}
/* Inserting 2 instructions before the END opcode moves all following
* labels by 2. Subroutines are always after the END opcode so
* they're always moved. */
if (inst->Instruction.Opcode == TGSI_OPCODE_CAL) {
inst->Label.Label += 2;
}
/* The labels of the following opcodes are moved only after
* the END opcode. */
if (vsctx->end_instruction &&
(inst->Instruction.Opcode == TGSI_OPCODE_IF ||
inst->Instruction.Opcode == TGSI_OPCODE_ELSE ||
inst->Instruction.Opcode == TGSI_OPCODE_BGNLOOP ||
inst->Instruction.Opcode == TGSI_OPCODE_ENDLOOP)) {
inst->Label.Label += 2;
}
}
ctx->emit_instruction(ctx, inst);
}