本文整理汇总了C++中MIN2函数的典型用法代码示例。如果您正苦于以下问题:C++ MIN2函数的具体用法?C++ MIN2怎么用?C++ MIN2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MIN2函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: assert
void ASPSYoungGen::resize_spaces(size_t requested_eden_size,
size_t requested_survivor_size) {
assert(UseAdaptiveSizePolicy, "sanity check");
assert(requested_eden_size > 0 && requested_survivor_size > 0,
"just checking");
space_invariants();
// We require eden and to space to be empty
if ((!eden_space()->is_empty()) || (!to_space()->is_empty())) {
return;
}
if (PrintAdaptiveSizePolicy && Verbose) {
gclog_or_tty->print_cr("PSYoungGen::resize_spaces(requested_eden_size: "
SIZE_FORMAT
", requested_survivor_size: " SIZE_FORMAT ")",
requested_eden_size, requested_survivor_size);
gclog_or_tty->print_cr(" eden: [" PTR_FORMAT ".." PTR_FORMAT ") "
SIZE_FORMAT,
eden_space()->bottom(),
eden_space()->end(),
pointer_delta(eden_space()->end(),
eden_space()->bottom(),
sizeof(char)));
gclog_or_tty->print_cr(" from: [" PTR_FORMAT ".." PTR_FORMAT ") "
SIZE_FORMAT,
from_space()->bottom(),
from_space()->end(),
pointer_delta(from_space()->end(),
from_space()->bottom(),
sizeof(char)));
gclog_or_tty->print_cr(" to: [" PTR_FORMAT ".." PTR_FORMAT ") "
SIZE_FORMAT,
to_space()->bottom(),
to_space()->end(),
pointer_delta( to_space()->end(),
to_space()->bottom(),
sizeof(char)));
}
// There's nothing to do if the new sizes are the same as the current
if (requested_survivor_size == to_space()->capacity_in_bytes() &&
requested_survivor_size == from_space()->capacity_in_bytes() &&
requested_eden_size == eden_space()->capacity_in_bytes()) {
if (PrintAdaptiveSizePolicy && Verbose) {
gclog_or_tty->print_cr(" capacities are the right sizes, returning");
}
return;
}
char* eden_start = (char*)virtual_space()->low();
char* eden_end = (char*)eden_space()->end();
char* from_start = (char*)from_space()->bottom();
char* from_end = (char*)from_space()->end();
char* to_start = (char*)to_space()->bottom();
char* to_end = (char*)to_space()->end();
assert(eden_start < from_start, "Cannot push into from_space");
ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
const size_t alignment = heap->intra_heap_alignment();
const bool maintain_minimum =
(requested_eden_size + 2 * requested_survivor_size) <= min_gen_size();
bool eden_from_to_order = from_start < to_start;
// Check whether from space is below to space
if (eden_from_to_order) {
// Eden, from, to
if (PrintAdaptiveSizePolicy && Verbose) {
gclog_or_tty->print_cr(" Eden, from, to:");
}
// Set eden
// "requested_eden_size" is a goal for the size of eden
// and may not be attainable. "eden_size" below is
// calculated based on the location of from-space and
// the goal for the size of eden. from-space is
// fixed in place because it contains live data.
// The calculation is done this way to avoid 32bit
// overflow (i.e., eden_start + requested_eden_size
// may too large for representation in 32bits).
size_t eden_size;
if (maintain_minimum) {
// Only make eden larger than the requested size if
// the minimum size of the generation has to be maintained.
// This could be done in general but policy at a higher
// level is determining a requested size for eden and that
// should be honored unless there is a fundamental reason.
eden_size = pointer_delta(from_start,
eden_start,
sizeof(char));
} else {
eden_size = MIN2(requested_eden_size,
pointer_delta(from_start, eden_start, sizeof(char)));
}
eden_end = eden_start + eden_size;
assert(eden_end >= eden_start, "addition overflowed")
//.........这里部分代码省略.........
开发者ID:AllenWeb,项目名称:openjdk-1,代码行数:101,代码来源:asPSYoungGen.cpp
示例2: update_tss_binding
static int
update_tss_binding(struct svga_context *svga,
unsigned dirty )
{
unsigned i;
unsigned count = MAX2( svga->curr.num_textures,
svga->state.hw_draw.num_views );
unsigned min_lod;
unsigned max_lod;
struct {
struct {
unsigned unit;
struct svga_hw_view_state *view;
} bind[PIPE_MAX_SAMPLERS];
unsigned bind_count;
} queue;
queue.bind_count = 0;
for (i = 0; i < count; i++) {
const struct svga_sampler_state *s = svga->curr.sampler[i];
struct svga_hw_view_state *view = &svga->state.hw_draw.views[i];
/* get min max lod */
if (svga->curr.texture[i]) {
min_lod = MAX2(s->view_min_lod, 0);
max_lod = MIN2(s->view_max_lod, svga->curr.texture[i]->last_level);
} else {
min_lod = 0;
max_lod = 0;
}
if (view->texture != svga->curr.texture[i] ||
view->min_lod != min_lod ||
view->max_lod != max_lod) {
svga_sampler_view_reference(&view->v, NULL);
pipe_texture_reference( &view->texture, svga->curr.texture[i] );
view->dirty = TRUE;
view->min_lod = min_lod;
view->max_lod = max_lod;
if (svga->curr.texture[i])
view->v = svga_get_tex_sampler_view(&svga->pipe,
svga->curr.texture[i],
min_lod,
max_lod);
}
if (view->dirty) {
queue.bind[queue.bind_count].unit = i;
queue.bind[queue.bind_count].view = view;
queue.bind_count++;
}
else if (view->v) {
svga_validate_sampler_view(svga, view->v);
}
}
svga->state.hw_draw.num_views = svga->curr.num_textures;
if (queue.bind_count) {
SVGA3dTextureState *ts;
if (SVGA3D_BeginSetTextureState( svga->swc,
&ts,
queue.bind_count ) != PIPE_OK)
goto fail;
for (i = 0; i < queue.bind_count; i++) {
ts[i].stage = queue.bind[i].unit;
ts[i].name = SVGA3D_TS_BIND_TEXTURE;
if (queue.bind[i].view->v) {
svga->swc->surface_relocation(svga->swc,
&ts[i].value,
queue.bind[i].view->v->handle,
PIPE_BUFFER_USAGE_GPU_READ);
}
else {
ts[i].value = SVGA3D_INVALID_ID;
}
queue.bind[i].view->dirty = FALSE;
}
SVGA_FIFOCommitAll( svga->swc );
}
return 0;
fail:
return PIPE_ERROR_OUT_OF_MEMORY;
}
开发者ID:MttDs,项目名称:new-rexeno-tindpe,代码行数:98,代码来源:svga_state_tss.c
示例3: r100CreateContext
//.........这里部分代码省略.........
ctx->Const.StripTextureBorder = GL_TRUE;
i = driQueryOptioni( &rmesa->radeon.optionCache, "allow_large_textures");
/* FIXME: When no memory manager is available we should set this
* to some reasonable value based on texture memory pool size */
ctx->Const.MaxTextureLevels = 12;
ctx->Const.Max3DTextureLevels = 9;
ctx->Const.MaxCubeTextureLevels = 12;
ctx->Const.MaxTextureRectSize = 2048;
ctx->Const.MaxTextureMaxAnisotropy = 16.0;
/* No wide points.
*/
ctx->Const.MinPointSize = 1.0;
ctx->Const.MinPointSizeAA = 1.0;
ctx->Const.MaxPointSize = 1.0;
ctx->Const.MaxPointSizeAA = 1.0;
ctx->Const.MinLineWidth = 1.0;
ctx->Const.MinLineWidthAA = 1.0;
ctx->Const.MaxLineWidth = 10.0;
ctx->Const.MaxLineWidthAA = 10.0;
ctx->Const.LineWidthGranularity = 0.0625;
/* Set maxlocksize (and hence vb size) small enough to avoid
* fallbacks in radeon_tcl.c. ie. guarentee that all vertices can
* fit in a single dma buffer for indexed rendering of quad strips,
* etc.
*/
ctx->Const.MaxArrayLockSize =
MIN2( ctx->Const.MaxArrayLockSize,
RADEON_BUFFER_SIZE / RADEON_MAX_TCL_VERTSIZE );
rmesa->boxes = 0;
ctx->Const.MaxDrawBuffers = 1;
ctx->Const.MaxColorAttachments = 1;
ctx->Const.MaxRenderbufferSize = 2048;
_mesa_set_mvp_with_dp4( ctx, GL_TRUE );
/* Initialize the software rasterizer and helper modules.
*/
_swrast_CreateContext( ctx );
_vbo_CreateContext( ctx );
_tnl_CreateContext( ctx );
_swsetup_CreateContext( ctx );
_ae_create_context( ctx );
/* Install the customized pipeline:
*/
_tnl_destroy_pipeline( ctx );
_tnl_install_pipeline( ctx, radeon_pipeline );
/* Try and keep materials and vertices separate:
*/
/* _tnl_isolate_materials( ctx, GL_TRUE ); */
/* Configure swrast and T&L to match hardware characteristics:
*/
_swrast_allow_pixel_fog( ctx, GL_FALSE );
_swrast_allow_vertex_fog( ctx, GL_TRUE );
_tnl_allow_pixel_fog( ctx, GL_FALSE );
开发者ID:UIKit0,项目名称:mesa,代码行数:67,代码来源:radeon_context.c
示例4: brw_initialize_context_constants
static void
brw_initialize_context_constants(struct brw_context *brw)
{
struct gl_context *ctx = &brw->ctx;
ctx->Const.QueryCounterBits.Timestamp = 36;
ctx->Const.StripTextureBorder = true;
ctx->Const.MaxDualSourceDrawBuffers = 1;
ctx->Const.MaxDrawBuffers = BRW_MAX_DRAW_BUFFERS;
ctx->Const.FragmentProgram.MaxTextureImageUnits = BRW_MAX_TEX_UNIT;
ctx->Const.MaxTextureCoordUnits = 8; /* Mesa limit */
ctx->Const.MaxTextureUnits =
MIN2(ctx->Const.MaxTextureCoordUnits,
ctx->Const.FragmentProgram.MaxTextureImageUnits);
ctx->Const.VertexProgram.MaxTextureImageUnits = BRW_MAX_TEX_UNIT;
if (brw->gen >= 7)
ctx->Const.GeometryProgram.MaxTextureImageUnits = BRW_MAX_TEX_UNIT;
else
ctx->Const.GeometryProgram.MaxTextureImageUnits = 0;
ctx->Const.MaxCombinedTextureImageUnits =
ctx->Const.VertexProgram.MaxTextureImageUnits +
ctx->Const.FragmentProgram.MaxTextureImageUnits +
ctx->Const.GeometryProgram.MaxTextureImageUnits;
ctx->Const.MaxTextureLevels = 14; /* 8192 */
if (ctx->Const.MaxTextureLevels > MAX_TEXTURE_LEVELS)
ctx->Const.MaxTextureLevels = MAX_TEXTURE_LEVELS;
ctx->Const.Max3DTextureLevels = 9;
ctx->Const.MaxCubeTextureLevels = 12;
if (brw->gen >= 7)
ctx->Const.MaxArrayTextureLayers = 2048;
else
ctx->Const.MaxArrayTextureLayers = 512;
ctx->Const.MaxTextureRectSize = 1 << 12;
ctx->Const.MaxTextureMaxAnisotropy = 16.0;
ctx->Const.MaxRenderbufferSize = 8192;
/* Hardware only supports a limited number of transform feedback buffers.
* So we need to override the Mesa default (which is based only on software
* limits).
*/
ctx->Const.MaxTransformFeedbackBuffers = BRW_MAX_SOL_BUFFERS;
/* On Gen6, in the worst case, we use up one binding table entry per
* transform feedback component (see comments above the definition of
* BRW_MAX_SOL_BINDINGS, in brw_context.h), so we need to advertise a value
* for MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS equal to
* BRW_MAX_SOL_BINDINGS.
*
* In "separate components" mode, we need to divide this value by
* BRW_MAX_SOL_BUFFERS, so that the total number of binding table entries
* used up by all buffers will not exceed BRW_MAX_SOL_BINDINGS.
*/
ctx->Const.MaxTransformFeedbackInterleavedComponents = BRW_MAX_SOL_BINDINGS;
ctx->Const.MaxTransformFeedbackSeparateComponents =
BRW_MAX_SOL_BINDINGS / BRW_MAX_SOL_BUFFERS;
ctx->Const.AlwaysUseGetTransformFeedbackVertexCount = true;
const int max_samples = brw_supported_msaa_modes(brw)[0];
ctx->Const.MaxSamples = max_samples;
ctx->Const.MaxColorTextureSamples = max_samples;
ctx->Const.MaxDepthTextureSamples = max_samples;
ctx->Const.MaxIntegerSamples = max_samples;
if (brw->gen >= 7)
ctx->Const.MaxProgramTextureGatherComponents = 4;
ctx->Const.MinLineWidth = 1.0;
ctx->Const.MinLineWidthAA = 1.0;
ctx->Const.MaxLineWidth = 5.0;
ctx->Const.MaxLineWidthAA = 5.0;
ctx->Const.LineWidthGranularity = 0.5;
ctx->Const.MinPointSize = 1.0;
ctx->Const.MinPointSizeAA = 1.0;
ctx->Const.MaxPointSize = 255.0;
ctx->Const.MaxPointSizeAA = 255.0;
ctx->Const.PointSizeGranularity = 1.0;
if (brw->gen >= 5 || brw->is_g4x)
ctx->Const.MaxClipPlanes = 8;
ctx->Const.VertexProgram.MaxNativeInstructions = 16 * 1024;
ctx->Const.VertexProgram.MaxAluInstructions = 0;
ctx->Const.VertexProgram.MaxTexInstructions = 0;
ctx->Const.VertexProgram.MaxTexIndirections = 0;
ctx->Const.VertexProgram.MaxNativeAluInstructions = 0;
ctx->Const.VertexProgram.MaxNativeTexInstructions = 0;
ctx->Const.VertexProgram.MaxNativeTexIndirections = 0;
ctx->Const.VertexProgram.MaxNativeAttribs = 16;
ctx->Const.VertexProgram.MaxNativeTemps = 256;
ctx->Const.VertexProgram.MaxNativeAddressRegs = 1;
ctx->Const.VertexProgram.MaxNativeParameters = 1024;
//.........这里部分代码省略.........
开发者ID:haiku,项目名称:mesa_legacy,代码行数:101,代码来源:brw_context.c
示例5: _swrast_write_zoomed_stencil_span
/*
* As above, but write stencil values.
*/
void
_swrast_write_zoomed_stencil_span( GLcontext *ctx,
GLuint n, GLint x, GLint y,
const GLstencil stencil[], GLint y0,
GLint skipPixels )
{
GLint m;
GLint r0, r1, row, r;
GLint i, j, skipcol;
GLstencil zstencil[MAX_WIDTH]; /* zoomed stencil values */
GLint maxwidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH );
(void) skipPixels; /* XXX this shouldn't be ignored */
/* compute width of output row */
m = (GLint) FABSF( n * ctx->Pixel.ZoomX );
if (m==0) {
return;
}
if (ctx->Pixel.ZoomX<0.0) {
/* adjust x coordinate for left/right mirroring */
x = x - m;
}
/* compute which rows to draw */
row = y - y0;
r0 = y0 + (GLint) (row * ctx->Pixel.ZoomY);
r1 = y0 + (GLint) ((row+1) * ctx->Pixel.ZoomY);
if (r0==r1) {
return;
}
else if (r1<r0) {
GLint rtmp = r1;
r1 = r0;
r0 = rtmp;
}
/* return early if r0...r1 is above or below window */
if (r0<0 && r1<0) {
/* below window */
return;
}
if (r0 >= (GLint) ctx->DrawBuffer->Height &&
r1 >= (GLint) ctx->DrawBuffer->Height) {
/* above window */
return;
}
/* check if left edge is outside window */
skipcol = 0;
if (x<0) {
skipcol = -x;
m += x;
}
/* make sure span isn't too long or short */
if (m>maxwidth) {
m = maxwidth;
}
else if (m<=0) {
return;
}
ASSERT( m <= MAX_WIDTH );
/* zoom the span horizontally */
if (ctx->Pixel.ZoomX==-1.0F) {
/* n==m */
for (j=0;j<m;j++) {
i = n - (j+skipcol) - 1;
zstencil[j] = stencil[i];
}
}
else {
GLfloat xscale = 1.0F / ctx->Pixel.ZoomX;
for (j=0;j<m;j++) {
i = (GLint) ((j+skipcol) * xscale);
if (i<0) i = n + i - 1;
zstencil[j] = stencil[i];
}
}
/* write the span */
for (r=r0; r<r1; r++) {
_swrast_write_stencil_span( ctx, m, x+skipcol, r, zstencil );
}
}
开发者ID:Ionic,项目名称:nx-libs,代码行数:89,代码来源:s_zoom.c
示例6: execute_posetree
//.........这里部分代码省略.........
/* compute rest basis and its inverse */
copy_m3_m3(rest_basis, bone->bone_mat);
copy_m3_m3(irest_basis, bone->bone_mat);
transpose_m3(irest_basis);
/* compute basis with rest_basis removed */
invert_m3_m3(iR_parmat, R_parmat);
mul_m3_m3m3(full_basis, iR_parmat, R_bonemat);
mul_m3_m3m3(basis, irest_basis, full_basis);
/* basis must be pure rotation */
normalize_m3(basis);
/* transform offset into local bone space */
normalize_m3(iR_parmat);
mul_m3_v3(iR_parmat, start);
IK_SetTransform(seg, start, rest_basis, basis, length);
if (pchan->ikflag & BONE_IK_XLIMIT)
IK_SetLimit(seg, IK_X, pchan->limitmin[0], pchan->limitmax[0]);
if (pchan->ikflag & BONE_IK_YLIMIT)
IK_SetLimit(seg, IK_Y, pchan->limitmin[1], pchan->limitmax[1]);
if (pchan->ikflag & BONE_IK_ZLIMIT)
IK_SetLimit(seg, IK_Z, pchan->limitmin[2], pchan->limitmax[2]);
IK_SetStiffness(seg, IK_X, pchan->stiffness[0]);
IK_SetStiffness(seg, IK_Y, pchan->stiffness[1]);
IK_SetStiffness(seg, IK_Z, pchan->stiffness[2]);
if(tree->stretch && (pchan->ikstretch > 0.0)) {
float ikstretch = pchan->ikstretch*pchan->ikstretch;
IK_SetStiffness(seg, IK_TRANS_Y, MIN2(1.0-ikstretch, 0.99));
IK_SetLimit(seg, IK_TRANS_Y, 0.001, 1e10);
}
}
solver= IK_CreateSolver(iktree[0]);
/* set solver goals */
/* first set the goal inverse transform, assuming the root of tree was done ok! */
pchan= tree->pchan[0];
if (pchan->parent)
/* transform goal by parent mat, so this rotation is not part of the
segment's basis. otherwise rotation limits do not work on the
local transform of the segment itself. */
copy_m4_m4(rootmat, pchan->parent->pose_mat);
else
unit_m4(rootmat);
VECCOPY(rootmat[3], pchan->pose_head);
mul_m4_m4m4(imat, rootmat, ob->obmat);
invert_m4_m4(goalinv, imat);
for (target=tree->targets.first; target; target=target->next) {
float polepos[3];
int poleconstrain= 0;
data= (bKinematicConstraint*)target->con->data;
/* 1.0=ctime, we pass on object for auto-ik (owner-type here is object, even though
* strictly speaking, it is a posechannel)
*/
get_constraint_target_matrix(scene, target->con, 0, CONSTRAINT_OBTYPE_OBJECT, ob, rootmat, 1.0);
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:67,代码来源:iksolver_plugin.c
示例7: set_super
void Klass::initialize_supers(Klass* k, TRAPS) {
if (FastSuperclassLimit == 0) {
// None of the other machinery matters.
set_super(k);
return;
}
if (k == NULL) {
set_super(NULL);
_primary_supers[0] = this;
assert(super_depth() == 0, "Object must already be initialized properly");
} else if (k != super() || k == SystemDictionary::Object_klass()) {
assert(super() == NULL || super() == SystemDictionary::Object_klass(),
"initialize this only once to a non-trivial value");
set_super(k);
Klass* sup = k;
int sup_depth = sup->super_depth();
juint my_depth = MIN2(sup_depth + 1, (int)primary_super_limit());
if (!can_be_primary_super_slow())
my_depth = primary_super_limit();
for (juint i = 0; i < my_depth; i++) {
_primary_supers[i] = sup->_primary_supers[i];
}
Klass* *super_check_cell;
if (my_depth < primary_super_limit()) {
_primary_supers[my_depth] = this;
super_check_cell = &_primary_supers[my_depth];
} else {
// Overflow of the primary_supers array forces me to be secondary.
super_check_cell = &_secondary_super_cache;
}
set_super_check_offset((address)super_check_cell - (address) this);
#ifdef ASSERT
{
juint j = super_depth();
assert(j == my_depth, "computed accessor gets right answer");
Klass* t = this;
while (!t->can_be_primary_super()) {
t = t->super();
j = t->super_depth();
}
for (juint j1 = j+1; j1 < primary_super_limit(); j1++) {
assert(primary_super_of_depth(j1) == NULL, "super list padding");
}
while (t != NULL) {
assert(primary_super_of_depth(j) == t, "super list initialization");
t = t->super();
--j;
}
assert(j == (juint)-1, "correct depth count");
}
#endif
}
if (secondary_supers() == NULL) {
KlassHandle this_kh (THREAD, this);
// Now compute the list of secondary supertypes.
// Secondaries can occasionally be on the super chain,
// if the inline "_primary_supers" array overflows.
int extras = 0;
Klass* p;
for (p = super(); !(p == NULL || p->can_be_primary_super()); p = p->super()) {
++extras;
}
ResourceMark rm(THREAD); // need to reclaim GrowableArrays allocated below
// Compute the "real" non-extra secondaries.
GrowableArray<Klass*>* secondaries = compute_secondary_supers(extras);
if (secondaries == NULL) {
// secondary_supers set by compute_secondary_supers
return;
}
GrowableArray<Klass*>* primaries = new GrowableArray<Klass*>(extras);
for (p = this_kh->super(); !(p == NULL || p->can_be_primary_super()); p = p->super()) {
int i; // Scan for overflow primaries being duplicates of 2nd'arys
// This happens frequently for very deeply nested arrays: the
// primary superclass chain overflows into the secondary. The
// secondary list contains the element_klass's secondaries with
// an extra array dimension added. If the element_klass's
// secondary list already contains some primary overflows, they
// (with the extra level of array-ness) will collide with the
// normal primary superclass overflows.
for( i = 0; i < secondaries->length(); i++ ) {
if( secondaries->at(i) == p )
break;
}
if( i < secondaries->length() )
continue; // It's a dup, don't put it in
primaries->push(p);
}
// Combine the two arrays into a metadata object to pack the array.
// The primaries are added in the reverse order, then the secondaries.
int new_length = primaries->length() + secondaries->length();
Array<Klass*>* s2 = MetadataFactory::new_array<Klass*>(
class_loader_data(), new_length, CHECK);
//.........这里部分代码省略.........
开发者ID:campolake,项目名称:openjdk9,代码行数:101,代码来源:klass.cpp
示例8: intel_calculate_first_last_level
/**
* Compute which mipmap levels that really need to be sent to the hardware.
* This depends on the base image size, GL_TEXTURE_MIN_LOD,
* GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
*/
static void
intel_calculate_first_last_level(struct intel_texture_object *intelObj)
{
struct gl_texture_object *tObj = &intelObj->base;
const struct gl_texture_image *const baseImage =
tObj->Image[0][tObj->BaseLevel];
/* These must be signed values. MinLod and MaxLod can be negative numbers,
* and having firstLevel and lastLevel as signed prevents the need for
* extra sign checks.
*/
int firstLevel;
int lastLevel;
/* Yes, this looks overly complicated, but it's all needed.
*/
switch (tObj->Target) {
case GL_TEXTURE_1D:
case GL_TEXTURE_2D:
case GL_TEXTURE_3D:
case GL_TEXTURE_CUBE_MAP:
if (tObj->MinFilter == GL_NEAREST || tObj->MinFilter == GL_LINEAR) {
/* GL_NEAREST and GL_LINEAR only care about GL_TEXTURE_BASE_LEVEL.
*/
firstLevel = lastLevel = tObj->BaseLevel;
}
else {
#ifdef I915
firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
firstLevel = MAX2(firstLevel, tObj->BaseLevel);
firstLevel = MIN2(firstLevel, tObj->BaseLevel + baseImage->MaxLog2);
lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5);
lastLevel = MAX2(lastLevel, tObj->BaseLevel);
lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2);
lastLevel = MIN2(lastLevel, tObj->MaxLevel);
lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
#else
/* Currently not taking min/max lod into account here, those
* values are programmed as sampler state elsewhere and we
* upload the same mipmap levels regardless. Not sure if
* this makes sense as it means it isn't possible for the app
* to use min/max lod to reduce texture memory pressure:
*/
firstLevel = tObj->BaseLevel;
lastLevel = MIN2(tObj->BaseLevel + baseImage->MaxLog2,
tObj->MaxLevel);
lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
#endif
}
break;
case GL_TEXTURE_RECTANGLE_NV:
case GL_TEXTURE_4D_SGIS:
firstLevel = lastLevel = 0;
break;
default:
return;
}
/* save these values */
intelObj->firstLevel = firstLevel;
intelObj->lastLevel = lastLevel;
}
开发者ID:Multi2Sim,项目名称:m2s-bench-parsec-3.0-src,代码行数:67,代码来源:intel_tex_validate.c
示例9: draw_vbo
/**
* Draw vertex arrays.
* This is the main entrypoint into the drawing module. If drawing an indexed
* primitive, the draw_set_indexes() function should have already been called
* to specify the element/index buffer information.
*/
void
draw_vbo(struct draw_context *draw,
const struct pipe_draw_info *info)
{
unsigned instance;
unsigned index_limit;
unsigned count;
assert(info->instance_count > 0);
if (info->indexed)
assert(draw->pt.user.elts);
draw->pt.user.eltBias = info->index_bias;
draw->pt.user.min_index = info->min_index;
draw->pt.user.max_index = info->max_index;
draw->pt.user.eltSize = info->indexed ? draw->pt.user.eltSizeIB : 0;
if (0)
debug_printf("draw_vbo(mode=%u start=%u count=%u):\n",
info->mode, info->start, info->count);
if (0)
tgsi_dump(draw->vs.vertex_shader->state.tokens, 0);
if (0) {
unsigned int i;
debug_printf("Elements:\n");
for (i = 0; i < draw->pt.nr_vertex_elements; i++) {
debug_printf(" %u: src_offset=%u inst_div=%u vbuf=%u format=%s\n",
i,
draw->pt.vertex_element[i].src_offset,
draw->pt.vertex_element[i].instance_divisor,
draw->pt.vertex_element[i].vertex_buffer_index,
util_format_name(draw->pt.vertex_element[i].src_format));
}
debug_printf("Buffers:\n");
for (i = 0; i < draw->pt.nr_vertex_buffers; i++) {
debug_printf(" %u: stride=%u offset=%u ptr=%p\n",
i,
draw->pt.vertex_buffer[i].stride,
draw->pt.vertex_buffer[i].buffer_offset,
draw->pt.user.vbuffer[i]);
}
}
if (0)
draw_print_arrays(draw, info->mode, info->start, MIN2(info->count, 20));
index_limit = util_draw_max_index(draw->pt.vertex_buffer,
draw->pt.vertex_element,
draw->pt.nr_vertex_elements,
info);
if (index_limit == 0) {
/* one of the buffers is too small to do any valid drawing */
debug_warning("draw: VBO too small to draw anything\n");
return;
}
draw->pt.max_index = index_limit - 1;
count = info->count;
if (count == 0) {
if (info->count_from_stream_output)
count = draw->pt.max_index + 1;
}
/*
* TODO: We could use draw->pt.max_index to further narrow
* the min_index/max_index hints given by the state tracker.
*/
for (instance = 0; instance < info->instance_count; instance++) {
draw->instance_id = instance + info->start_instance;
if (info->primitive_restart) {
draw_pt_arrays_restart(draw, info);
}
else {
draw_pt_arrays(draw, info->mode, info->start, count);
}
}
}
开发者ID:Forzaferrarileo,项目名称:mesa,代码行数:88,代码来源:draw_pt.c
示例10: vc4_simulator_flush
int
vc4_simulator_flush(struct vc4_context *vc4, struct drm_vc4_submit_cl *args)
{
struct vc4_screen *screen = vc4->screen;
struct vc4_surface *csurf = vc4_surface(vc4->framebuffer.cbufs[0]);
struct vc4_resource *ctex = csurf ? vc4_resource(csurf->base.texture) : NULL;
uint32_t winsys_stride = ctex ? ctex->bo->simulator_winsys_stride : 0;
uint32_t sim_stride = ctex ? ctex->slices[0].stride : 0;
uint32_t row_len = MIN2(sim_stride, winsys_stride);
struct vc4_exec_info exec;
struct drm_device local_dev = {
.vc4 = vc4,
.simulator_mem_next = OVERFLOW_SIZE,
};
struct drm_device *dev = &local_dev;
int ret;
memset(&exec, 0, sizeof(exec));
list_inithead(&exec.unref_list);
if (ctex && ctex->bo->simulator_winsys_map) {
#if 0
fprintf(stderr, "%dx%d %d %d %d\n",
ctex->base.b.width0, ctex->base.b.height0,
winsys_stride,
sim_stride,
ctex->bo->size);
#endif
for (int y = 0; y < ctex->base.b.height0; y++) {
memcpy(ctex->bo->map + y * sim_stride,
ctex->bo->simulator_winsys_map + y * winsys_stride,
row_len);
}
}
exec.args = args;
ret = vc4_simulator_pin_bos(dev, &exec);
if (ret)
return ret;
ret = vc4_cl_validate(dev, &exec);
if (ret)
return ret;
if (vc4_debug & VC4_DEBUG_CL) {
fprintf(stderr, "RCL:\n");
vc4_dump_cl(screen->simulator_mem_base + exec.ct1ca,
exec.ct1ea - exec.ct1ca, true);
}
if (exec.ct0ca != exec.ct0ea) {
int bfc = simpenrose_do_binning(exec.ct0ca, exec.ct0ea);
if (bfc != 1) {
fprintf(stderr, "Binning returned %d flushes, should be 1.\n",
bfc);
fprintf(stderr, "Relocated binning command list:\n");
vc4_dump_cl(screen->simulator_mem_base + exec.ct0ca,
exec.ct0ea - exec.ct0ca, false);
abort();
}
}
int rfc = simpenrose_do_rendering(exec.ct1ca, exec.ct1ea);
if (rfc != 1) {
fprintf(stderr, "Rendering returned %d frames, should be 1.\n",
rfc);
fprintf(stderr, "Relocated render command list:\n");
vc4_dump_cl(screen->simulator_mem_base + exec.ct1ca,
exec.ct1ea - exec.ct1ca, true);
abort();
}
ret = vc4_simulator_unpin_bos(&exec);
if (ret)
return ret;
list_for_each_entry_safe(struct drm_vc4_bo, bo, &exec.unref_list,
unref_head) {
list_del(&bo->unref_head);
assert(*(uint32_t *)(bo->base.vaddr + bo->bo->size) ==
BO_SENTINEL);
vc4_bo_unreference(&bo->bo);
free(bo);
}
if (ctex && ctex->bo->simulator_winsys_map) {
for (int y = 0; y < ctex->base.b.height0; y++) {
memcpy(ctex->bo->simulator_winsys_map + y * winsys_stride,
ctex->bo->map + y * sim_stride,
row_len);
}
}
return 0;
}
开发者ID:cjp256,项目名称:mesa,代码行数:96,代码来源:vc4_simulator.c
示例11: view3d_select_loop
static void view3d_select_loop(ViewContext *vc, Scene *scene, View3D *v3d, ARegion *ar, bool use_obedit_skip)
{
short code = 1;
char dt;
short dtx;
if (vc->obedit && vc->obedit->type == OB_MBALL) {
draw_object(scene, ar, v3d, BASACT, DRAW_PICKING | DRAW_CONSTCOLOR);
}
else if ((vc->obedit && vc->obedit->type == OB_ARMATURE)) {
/* if not drawing sketch, draw bones */
if (!BDR_drawSketchNames(vc)) {
draw_object(scene, ar, v3d, BASACT, DRAW_PICKING | DRAW_CONSTCOLOR);
}
}
else {
Base *base;
v3d->xray = true; /* otherwise it postpones drawing */
for (base = scene->base.first; base; base = base->next) {
if (base->lay & v3d->lay) {
if ((base->object->restrictflag & OB_RESTRICT_SELECT) ||
(use_obedit_skip && (scene->obedit->data == base->object->data)))
{
base->selcol = 0;
}
else {
base->selcol = code;
if (GPU_select_load_id(code)) {
draw_object(scene, ar, v3d, base, DRAW_PICKING | DRAW_CONSTCOLOR);
/* we draw duplicators for selection too */
if ((base->object->transflag & OB_DUPLI)) {
ListBase *lb;
DupliObject *dob;
Base tbase;
tbase.flag = OB_FROMDUPLI;
lb = object_duplilist(G.main->eval_ctx, scene, base->object);
for (dob = lb->first; dob; dob = dob->next) {
float omat[4][4];
tbase.object = dob->ob;
copy_m4_m4(omat, dob->ob->obmat);
copy_m4_m4(dob->ob->obmat, dob->mat);
/* extra service: draw the duplicator in drawtype of parent */
/* MIN2 for the drawtype to allow bounding box objects in groups for lods */
dt = tbase.object->dt; tbase.object->dt = MIN2(tbase.object->dt, base->object->dt);
dtx = tbase.object->dtx; tbase.object->dtx = base->object->dtx;
draw_object(scene, ar, v3d, &tbase, DRAW_PICKING | DRAW_CONSTCOLOR);
tbase.object->dt = dt;
tbase.object->dtx = dtx;
copy_m4_m4(dob->ob->obmat, omat);
}
free_object_duplilist(lb);
}
}
code++;
}
}
}
v3d->xray = false; /* restore */
}
}
开发者ID:Bforartists,项目名称:Bforartists,代码行数:71,代码来源:view3d_view.c
示例12: brw_update_sampler_state
static void brw_update_sampler_state( const struct pipe_sampler_state *pipe_sampler,
unsigned sdc_gs_offset,
struct brw_sampler_state *sampler)
{
memset(sampler, 0, sizeof(*sampler));
switch (pipe_sampler->min_mip_filter) {
case PIPE_TEX_FILTER_NEAREST:
sampler->ss0.min_filter = BRW_MAPFILTER_NEAREST;
break;
case PIPE_TEX_FILTER_LINEAR:
sampler->ss0.min_filter = BRW_MAPFILTER_LINEAR;
break;
case PIPE_TEX_FILTER_ANISO:
sampler->ss0.min_filter = BRW_MAPFILTER_ANISOTROPIC;
break;
default:
break;
}
switch (pipe_sampler->min_mip_filter) {
case PIPE_TEX_MIPFILTER_NEAREST:
sampler->ss0.mip_filter = BRW_MIPFILTER_NEAREST;
break;
case PIPE_TEX_MIPFILTER_LINEAR:
sampler->ss0.mip_filter = BRW_MIPFILTER_LINEAR;
break;
case PIPE_TEX_MIPFILTER_NONE:
sampler->ss0.mip_filter = BRW_MIPFILTER_NONE;
break;
default:
break;
}
/* Set Anisotropy:
*/
switch (pipe_sampler->mag_img_filter) {
case PIPE_TEX_FILTER_NEAREST:
sampler->ss0.mag_filter = BRW_MAPFILTER_NEAREST;
break;
case PIPE_TEX_FILTER_LINEAR:
sampler->ss0.mag_filter = BRW_MAPFILTER_LINEAR;
break;
case PIPE_TEX_FILTER_ANISO:
sampler->ss0.mag_filter = BRW_MAPFILTER_LINEAR;
break;
default:
break;
}
if (pipe_sampler->max_anisotropy > 2.0) {
sampler->ss3.max_aniso = MAX2((pipe_sampler->max_anisotropy - 2) / 2,
BRW_ANISORATIO_16);
}
sampler->ss1.s_wrap_mode = translate_wrap_mode(pipe_sampler->wrap_s);
sampler->ss1.r_wrap_mode = translate_wrap_mode(pipe_sampler->wrap_r);
sampler->ss1.t_wrap_mode = translate_wrap_mode(pipe_sampler->wrap_t);
/* Fulsim complains if I don't do this. Hardware doesn't mind:
*/
#if 0
if (texObj->Target == GL_TEXTURE_CUBE_MAP_ARB) {
sampler->ss1.r_wrap_mode = BRW_TEXCOORDMODE_CUBE;
sampler->ss1.s_wrap_mode = BRW_TEXCOORDMODE_CUBE;
sampler->ss1.t_wrap_mode = BRW_TEXCOORDMODE_CUBE;
}
#endif
/* Set shadow function:
*/
if (pipe_sampler->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
/* Shadowing is "enabled" by emitting a particular sampler
* message (sample_c). So need to recompile WM program when
* shadow comparison is enabled on each/any texture unit.
*/
sampler->ss0.shadow_function = intel_translate_shadow_compare_func(pipe_sampler->compare_func);
}
/* Set LOD bias:
*/
sampler->ss0.lod_bias = S_FIXED(CLAMP(pipe_sampler->lod_bias, -16, 15), 6);
sampler->ss0.lod_preclamp = 1; /* OpenGL mode */
sampler->ss0.default_color_mode = 0; /* OpenGL/DX10 mode */
/* Set BaseMipLevel, MaxLOD, MinLOD:
*
* XXX: I don't think that using firstLevel, lastLevel works,
* because we always setup the surface state as if firstLevel ==
* level zero. Probably have to subtract firstLevel from each of
* these:
*/
sampler->ss0.base_level = U_FIXED(0, 1);
sampler->ss1.max_lod = U_FIXED(MIN2(MAX2(pipe_sampler->max_lod, 0), 13), 6);
sampler->ss1.min_lod = U_FIXED(MIN2(MAX2(pipe_sampler->min_lod, 0), 13), 6);
sampler->ss2.default_color_pointer = sdc_gs_offset >> 5;
}
开发者ID:aljen,项目名称:haiku-opengl,代码行数:99,代码来源:brw_wm_sampler_state.c
示例13: piglit_init
void
piglit_init(int argc, char **argv)
{
GLuint vs_spiral, gs_spiral, vs_ref_main, vs_test_main, gs_test_main,
gs_layout, fs_main, vao, element_buf;
GLint max_gs_out_vertices, max_gs_out_components;
int max_testable_vertices;
char *text, *endptr;
/* parse args */
if (argc != 2)
print_usage_and_exit(argv[0]);
endptr = NULL;
num_vertices = strtol(argv[1], &endptr, 0);
if (endptr != argv[1] + strlen(argv[1]))
print_usage_and_exit(argv[0]);
/* Figure out the maximum number of vertices we can test. */
glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES, &max_gs_out_vertices);
glGetIntegerv(GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS,
&max_gs_out_components);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
max_testable_vertices = MIN2(max_gs_out_vertices,
max_gs_out_components / 4);
/* If num_vertices == 0, test the maximum possible number of
* vertices. Otherwise ensure that the requested number is
* supported by the implementation.
*/
if (num_vertices == 0)
num_vertices = max_testable_vertices;
else if (num_vertices > max_testable_vertices) {
printf("Can't test more than %d vertices\n",
max_testable_vertices);
piglit_report_result(PIGLIT_SKIP);
}
/* Compile shaders */
vs_spiral = piglit_compile_shader_text(GL_VERTEX_SHADER, spiral_text);
gs_spiral = piglit_compile_shader_text(GL_GEOMETRY_SHADER,
spiral_text);
vs_ref_main = piglit_compile_shader_text(GL_VERTEX_SHADER,
vs_ref_text);
vs_test_main = piglit_compile_shader_text(GL_VERTEX_SHADER,
vs_test_text);
gs_test_main = piglit_compile_shader_text(GL_GEOMETRY_SHADER,
gs_test_text);
asprintf(&text, gs_layout_template, num_vertices);
gs_layout = piglit_compile_shader_text(GL_GEOMETRY_SHADER, text);
free(text);
fs_main = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_text);
prog_ref = glCreateProgram();
glAttachShader(prog_ref, vs_ref_main);
glAttachShader(prog_ref, vs_spiral);
glAttachShader(prog_ref, fs_main);
glLinkProgram(prog_ref);
if (!piglit_link_check_status(prog_ref))
piglit_report_result(PIGLIT_FAIL);
prog_test = glCreateProgram();
glAttachShader(prog_test, vs_test_main);
glAttachShader(prog_test, gs_test_main);
glAttachShader(prog_test, gs_spiral);
glAttachShader(prog_test, gs_layout);
glAttachShader(prog_test, fs_main);
glLinkProgram(prog_test);
if (!piglit_link_check_status(prog_test))
piglit_report_result(PIGLIT_FAIL);
glDeleteShader(vs_spiral);
glDeleteShader(gs_spiral);
glDeleteShader(vs_ref_main);
glDeleteShader(vs_test_main);
glDeleteShader(gs_test_main);
glDeleteShader(gs_layout);
glDeleteShader(fs_main);
/* Various other GL objects needed by the test */
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glGenBuffers(1, &element_buf);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, element_buf);
if (!piglit_check_gl_error(GL_NO_ERROR))
piglit_report_result(PIGLIT_FAIL);
}
开发者ID:Jul13t,项目名称:piglit,代码行数:88,代码来源:end-primitive.c
示例14: si_blit_decompress_zs_planes_in_place
/* Helper function for si_blit_decompress_zs_in_place.
*/
static void
si_blit_decompress_zs_planes_in_place(struct si_context *sctx,
struct r600_texture *texture,
unsigned planes, unsigned level_mask,
unsigned first_layer, unsigned last_layer)
{
struct pipe_surface *zsurf, surf_tmpl = {{0}};
unsigned layer, max_layer, checked_last_layer;
unsigned fully_decompressed_mask = 0;
if (!level_mask)
return;
if (planes & PIPE_MASK_S)
sctx->db_flush_stencil_inplace = true;
if (planes & PIPE_MASK_Z)
sctx->db_flush_depth_inplace = true;
si_mark_atom_dirty(sctx, &sctx->db_render_state);
surf_tmpl.format = texture->resource.b.b.format;
while (level_mask) {
unsigned level = u_bit_scan(&level_mask);
surf_tmpl.u.tex.level = level;
/* The smaller the mipmap level, the less layers there are
* as far as 3D textures are concerned. */
max_layer = util_max_layer(&texture->resource.b.b, level);
checked_last_layer = MIN2(last_layer, max_layer);
for (layer = first_layer; layer <= checked_last_layer; layer++) {
surf_tmpl.u.tex.first_layer = layer;
surf_tmpl.u.tex.last_layer = layer;
zsurf = sctx->b.b.create_surface(&sctx->b.b, &texture->resource.b.b, &surf_tmpl);
si_blitter_begin(&sctx->b.b, SI_DECOMPRESS);
util_blitter_custom_depth_stencil(sctx->blitter, zsurf, NULL, ~0,
sctx->custom_dsa_flush,
1.0f);
si_blitter_end(&sctx->b.b);
pipe_surface_reference(&zsurf, NULL);
}
/* The texture will always be dirty if some layers aren't flushed.
* I don't think this case occurs often though. */
if (first_layer == 0 && last_layer == max_layer) {
fully_decompressed_mask |= 1u << level;
}
}
if (planes & PIPE_MASK_Z)
texture->dirty_level_mask &= ~fully_decompressed_mask;
if (planes & PIPE_MASK_S)
texture->stencil_dirty_level_mask &= ~fully_decompressed_mask;
sctx->db_flush_depth_inplace = false;
sctx->db_flush_stencil_inplace = false;
si_mark_atom_dirty(sctx, &sctx->db_render_state);
}
开发者ID:BNieuwenhuizen,项目名称:mesa,代码行数:64,代码来源:si_blit.c
示例15: try_setup_point
static boolean
try_setup_point( struct lp_setup_context *setup,
const float (*v0)[4] )
{
struct llvmpipe_context *lp_context = (struct llvmpipe_context *)setup->pipe;
/* x/y positions in fixed point */
const struct lp_setup_variant_key *key = &setup->setup.variant->key;
const int sizeAttr = setup->psize_slo
|
请发表评论