本文整理汇总了C++中STRUCT_OFFSET函数的典型用法代码示例。如果您正苦于以下问题:C++ STRUCT_OFFSET函数的具体用法?C++ STRUCT_OFFSET怎么用?C++ STRUCT_OFFSET使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了STRUCT_OFFSET函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pmcCalcCrc_T02
u_int32_t
pmcCalcCrc_T02 (void *bufp)
{
FLD_TYPE2 *buf = bufp;
u_int32_t crc; /* */
/* */
sbeCrc (
(u_int8_t *) &buf->type,
(u_int32_t) STRUCT_OFFSET (FLD_TYPE2, Crc32),
(u_int32_t) 0,
(u_int32_t *) &crc);
/* */
sbeCrc (
(u_int8_t *) &buf->Id[0],
(u_int32_t) (sizeof (FLD_TYPE2) - STRUCT_OFFSET (FLD_TYPE2, Id)),
(u_int32_t) crc,
(u_int32_t *) &crc);
#ifdef EEPROM_TYPE_DEBUG
pr_info("sbeCrc: crc 2 calculated as %08x\n", crc); /* */
#endif
return crc;
}
示例2: Init
/** Initialization */
void Init(const FArrowVertexBuffer* VertexBuffer)
{
if (IsInRenderingThread())
{
// Initialize the vertex factory's stream components.
FDataType NewData;
NewData.PositionComponent = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FDynamicMeshVertex, Position, VET_Float3);
NewData.TextureCoordinates.Add(
FVertexStreamComponent(VertexBuffer, STRUCT_OFFSET(FDynamicMeshVertex, TextureCoordinate), sizeof(FDynamicMeshVertex), VET_Float2)
);
NewData.TangentBasisComponents[0] = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FDynamicMeshVertex, TangentX, VET_PackedNormal);
NewData.TangentBasisComponents[1] = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FDynamicMeshVertex, TangentZ, VET_PackedNormal);
SetData(NewData);
}
else
{
ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER(
InitArrowVertexFactory,
FArrowVertexFactory*, VertexFactory, this,
const FArrowVertexBuffer*, VertexBuffer, VertexBuffer,
{
// Initialize the vertex factory's stream components.
FDataType NewData;
NewData.PositionComponent = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FDynamicMeshVertex, Position, VET_Float3);
NewData.TextureCoordinates.Add(
FVertexStreamComponent(VertexBuffer, STRUCT_OFFSET(FDynamicMeshVertex, TextureCoordinate), sizeof(FDynamicMeshVertex), VET_Float2)
);
NewData.TangentBasisComponents[0] = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FDynamicMeshVertex, TangentX, VET_PackedNormal);
NewData.TangentBasisComponents[1] = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FDynamicMeshVertex, TangentZ, VET_PackedNormal);
VertexFactory->SetData(NewData);
});
}
示例3: STRUCTMEMBER_VERTEXSTREAMCOMPONENT
void FSsPartsVertexFactory::Init(const FSsPartsVertexBuffer* VertexBuffer)
{
if(IsInRenderingThread())
{
FLocalVertexFactory::DataType Data;
Data.PositionComponent = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FSsPartVertex, Position, VET_Float3);
Data.TextureCoordinates.Add(FVertexStreamComponent(VertexBuffer, STRUCT_OFFSET(FSsPartVertex,TexCoord), sizeof(FSsPartVertex), VET_Float2));
Data.ColorComponent = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FSsPartVertex, Color, VET_Color);
Data.TextureCoordinates.Add(FVertexStreamComponent(VertexBuffer, STRUCT_OFFSET(FSsPartVertex,ColorBlend), sizeof(FSsPartVertex), VET_Float2));
Data.TangentBasisComponents[0] = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FSsPartVertex, TangentX, VET_PackedNormal);
Data.TangentBasisComponents[1] = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FSsPartVertex, TangentZ, VET_PackedNormal);
SetData(Data);
}
else
{
ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER(
FInitSsPartsVertexFactory,
FSsPartsVertexFactory*, VertexFactory, this,
const FSsPartsVertexBuffer*, VertexBuffer, VertexBuffer,
{
DataType Data;
Data.PositionComponent = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FSsPartVertex, Position, VET_Float3);
Data.TextureCoordinates.Add(FVertexStreamComponent(VertexBuffer, STRUCT_OFFSET(FSsPartVertex,TexCoord), sizeof(FSsPartVertex), VET_Float2));
Data.ColorComponent = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FSsPartVertex, Color, VET_Color);
Data.TextureCoordinates.Add(FVertexStreamComponent(VertexBuffer, STRUCT_OFFSET(FSsPartVertex,ColorBlend), sizeof(FSsPartVertex), VET_Float2));
Data.TangentBasisComponents[0] = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FSsPartVertex, TangentX, VET_PackedNormal);
Data.TangentBasisComponents[1] = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FSsPartVertex, TangentZ, VET_PackedNormal);
VertexFactory->SetData(Data);
});
}
示例4: FLandscapeSharedBuffers
void FLandscapeComponentSceneProxyMobile::CreateRenderThreadResources()
{
// Use only Index buffers
SharedBuffers = FLandscapeComponentSceneProxy::SharedBuffersMap.FindRef(SharedBuffersKey);
if (SharedBuffers == nullptr)
{
SharedBuffers = new FLandscapeSharedBuffers(
SharedBuffersKey, SubsectionSizeQuads, NumSubsections,
GetScene().GetFeatureLevel(), false);
FLandscapeComponentSceneProxy::SharedBuffersMap.Add(SharedBuffersKey, SharedBuffers);
}
SharedBuffers->AddRef();
int32 VertexBufferSize = PlatformData.Num();
// Copy platform data into vertex buffer
VertexBuffer = new FLandscapeVertexBufferMobile(PlatformData.GetData(), VertexBufferSize);
FLandscapeVertexFactoryMobile* LandscapeVertexFactory = new FLandscapeVertexFactoryMobile();
LandscapeVertexFactory->MobileData.PositionComponent = FVertexStreamComponent(VertexBuffer, STRUCT_OFFSET(FLandscapeMobileVertex,Position), sizeof(FLandscapeMobileVertex), VET_UByte4N);
for( uint32 Index = 0; Index < LANDSCAPE_MAX_ES_LOD_COMP; ++Index )
{
LandscapeVertexFactory->MobileData.LODHeightsComponent.Add
(FVertexStreamComponent(VertexBuffer, STRUCT_OFFSET(FLandscapeMobileVertex,LODHeights) + sizeof(uint8) * 4 * Index, sizeof(FLandscapeMobileVertex), VET_UByte4N));
}
LandscapeVertexFactory->InitResource();
VertexFactory = LandscapeVertexFactory;
// Assign LandscapeUniformShaderParameters
LandscapeUniformShaderParameters.InitResource();
PlatformData.Empty();
}
示例5: mcc_rpn
static inline void mcc_rpn(int level, uint8_t *ptr, unsigned int len,
long_frame_head *head, mcc_long_frame_head *mcc_head)
{
rpn_msg *rpn = (void *) (ptr - STRUCT_END(rpn_msg, mcc_s_head));
printf("RPN %s: ", CR_STR(mcc_head));
print_rfcomm_hdr(head, ptr, len);
print_mcc(mcc_head);
p_indent(level, 0);
printf("dlci %d ", GET_DLCI(rpn->dlci));
/* Assuming that rpn_val is _declared_ as a member of rpn_msg... */
if (len <= STRUCT_OFFSET(rpn_msg, rpn_val) - STRUCT_END(rpn_msg, mcc_s_head)) {
printf("\n");
return;
}
printf("br %d db %d sb %d p %d pt %d xi %d xo %d\n",
rpn->rpn_val.bit_rate, rpn->rpn_val.data_bits,
rpn->rpn_val.stop_bit, rpn->rpn_val.parity,
rpn->rpn_val.parity_type, rpn->rpn_val.xon_input,
rpn->rpn_val.xon_output);
p_indent(level, 0);
printf("rtri %d rtro %d rtci %d rtco %d xon %d xoff %d pm 0x%04x\n",
rpn->rpn_val.rtr_input, rpn->rpn_val.rtr_output,
rpn->rpn_val.rtc_input, rpn->rpn_val.rtc_output,
rpn->rpn_val.xon, rpn->rpn_val.xoff, btohs(rpn->rpn_val.pm));
}
示例6: SELECT_STATIC_MESH_VERTEX_TYPE
void FSplineMeshSceneProxy::InitVertexFactory(USplineMeshComponent* InComponent, int32 InLODIndex, FColorVertexBuffer* InOverrideColorVertexBuffer)
{
uint32 TangentXOffset = 0;
uint32 TangetnZOffset = 0;
uint32 UVsBaseOffset = 0;
auto& RD = InComponent->StaticMesh->RenderData->LODResources[InLODIndex];
SELECT_STATIC_MESH_VERTEX_TYPE(
RD.VertexBuffer.GetUseHighPrecisionTangentBasis(),
RD.VertexBuffer.GetUseFullPrecisionUVs(),
RD.VertexBuffer.GetNumTexCoords(),
{
TangentXOffset = STRUCT_OFFSET(VertexType, TangentX);
TangetnZOffset = STRUCT_OFFSET(VertexType, TangentZ);
UVsBaseOffset = STRUCT_OFFSET(VertexType, UVs);
});
示例7: transaction_parser
static gboolean transaction_parser(GObject *conn,
GObject *transaction,
gpointer data)
{
#define PREFIX "com.nokia.policy."
(void)conn;
(void)data;
static argdsc_t dspuser_args [] = {
{ argtype_integer , "pid" , STRUCT_OFFSET(user_t, pid) },
{ argtype_invalid , NULL , 0 }
};
static actdsc_t actions[] = {
{ PREFIX "dsp_user", dspuser_action, dspuser_args, sizeof(user_t) },
{ NULL , NULL , NULL , 0 }
};
guint txid;
GSList *entry, *list;
char *name;
actdsc_t *action;
gboolean success;
gchar *signal;
OHM_DEBUG(DBG_ACTION, "got actions");
g_object_get(transaction, "txid" , &txid , NULL);
g_object_get(transaction, "facts" , &list , NULL);
g_object_get(transaction, "signal", &signal, NULL);
success = TRUE;
if (!strcmp(signal, "dsp_actions")) {
OHM_DEBUG(DBG_ACTION, "txid: %d", txid);
memset(users, 0, sizeof(users));
nuser = 0;
for (entry = list; entry != NULL; entry = g_slist_next(entry)) {
name = (char *)entry->data;
for (action = actions; action->name != NULL; action++) {
if (!strcmp(name, action->name))
success &= action_parser(action);
}
}
success = dsp_set_users(users, nuser);
}
g_free(signal);
return success;
#undef PREFIX
}
示例8: ext_or_cmd_new
/** Allocate and return a structure capable of holding an Extended
* ORPort message of body length <b>len</b>. */
ext_or_cmd_t *
ext_or_cmd_new(uint16_t len)
{
size_t size = STRUCT_OFFSET(ext_or_cmd_t, body) + len;
ext_or_cmd_t *cmd = tor_malloc(size);
cmd->len = len;
return cmd;
}
示例9: mp_pool_new
/** Allocate a new memory pool to hold items of size <b>item_size</b>. We'll
* try to fit about <b>chunk_capacity</b> bytes in each chunk. */
mp_pool_t *
mp_pool_new(size_t item_size, size_t chunk_capacity)
{
mp_pool_t *pool;
size_t alloc_size, new_chunk_cap;
tor_assert(item_size < SIZE_T_CEILING);
tor_assert(chunk_capacity < SIZE_T_CEILING);
tor_assert(SIZE_T_CEILING / item_size > chunk_capacity);
pool = ALLOC(sizeof(mp_pool_t));
CHECK_ALLOC(pool);
memset(pool, 0, sizeof(mp_pool_t));
/* First, we figure out how much space to allow per item. We'll want to
* use make sure we have enough for the overhead plus the item size. */
alloc_size = (size_t)(STRUCT_OFFSET(mp_allocated_t, u.mem) + item_size);
/* If the item_size is less than sizeof(next_free), we need to make
* the allocation bigger. */
if (alloc_size < sizeof(mp_allocated_t))
alloc_size = sizeof(mp_allocated_t);
/* If we're not an even multiple of ALIGNMENT, round up. */
if (alloc_size % ALIGNMENT) {
alloc_size = alloc_size + ALIGNMENT - (alloc_size % ALIGNMENT);
}
if (alloc_size < ALIGNMENT)
alloc_size = ALIGNMENT;
ASSERT((alloc_size % ALIGNMENT) == 0);
/* Now we figure out how many items fit in each chunk. We need to fit at
* least 2 items per chunk. No chunk can be more than MAX_CHUNK bytes long,
* or less than MIN_CHUNK. */
if (chunk_capacity > MAX_CHUNK)
chunk_capacity = MAX_CHUNK;
/* Try to be around a power of 2 in size, since that's what allocators like
* handing out. 512K-1 byte is a lot better than 512K+1 byte. */
chunk_capacity = (size_t) round_to_power_of_2(chunk_capacity);
while (chunk_capacity < alloc_size * 2 + CHUNK_OVERHEAD)
chunk_capacity *= 2;
if (chunk_capacity < MIN_CHUNK)
chunk_capacity = MIN_CHUNK;
new_chunk_cap = (chunk_capacity-CHUNK_OVERHEAD) / alloc_size;
tor_assert(new_chunk_cap < INT_MAX);
pool->new_chunk_capacity = (int)new_chunk_cap;
pool->item_alloc_size = alloc_size;
log_debug(LD_MM, "Capacity is %lu, item size is %lu, alloc size is %lu",
(unsigned long)pool->new_chunk_capacity,
(unsigned long)pool->item_alloc_size,
(unsigned long)(pool->new_chunk_capacity*pool->item_alloc_size));
return pool;
}
示例10: FTileVertexFactory
/** Default constructor. */
FTileVertexFactory()
{
FLocalVertexFactory::DataType Data;
// position
Data.PositionComponent = FVertexStreamComponent(
>ileRendererVertexBuffer,STRUCT_OFFSET(FMaterialTileVertex,Position),sizeof(FMaterialTileVertex),VET_Float3);
// tangents
Data.TangentBasisComponents[0] = FVertexStreamComponent(
>ileRendererVertexBuffer,STRUCT_OFFSET(FMaterialTileVertex,TangentX),sizeof(FMaterialTileVertex),VET_PackedNormal);
Data.TangentBasisComponents[1] = FVertexStreamComponent(
>ileRendererVertexBuffer,STRUCT_OFFSET(FMaterialTileVertex,TangentZ),sizeof(FMaterialTileVertex),VET_PackedNormal);
// color
Data.ColorComponent = FVertexStreamComponent(
>ileRendererVertexBuffer,STRUCT_OFFSET(FMaterialTileVertex,Color),sizeof(FMaterialTileVertex),VET_Color);
// UVs
Data.TextureCoordinates.Add(FVertexStreamComponent(
>ileRendererVertexBuffer,STRUCT_OFFSET(FMaterialTileVertex,U),sizeof(FMaterialTileVertex),VET_Float2));
// update the data
SetData(Data);
}
示例11: sizeof
void FSlateVertexDeclaration::InitRHI()
{
FVertexDeclarationElementList Elements;
uint32 Stride = sizeof(FSlateVertex);
Elements.Add(FVertexElement(0, STRUCT_OFFSET(FSlateVertex, TexCoords), VET_Float4, 0, Stride));
Elements.Add(FVertexElement(0, STRUCT_OFFSET(FSlateVertex, Position), VET_Float2, 1, Stride));
Elements.Add(FVertexElement(0, STRUCT_OFFSET(FSlateVertex, ClipRect) + STRUCT_OFFSET(FSlateRotatedClipRectType, TopLeft), VET_Float2, 2, Stride));
Elements.Add(FVertexElement(0, STRUCT_OFFSET(FSlateVertex, ClipRect) + STRUCT_OFFSET(FSlateRotatedClipRectType, ExtentX), VET_Float4, 3, Stride));
Elements.Add(FVertexElement(0, STRUCT_OFFSET(FSlateVertex, Color), VET_Color, 4, Stride));
VertexDeclarationRHI = RHICreateVertexDeclaration(Elements);
}
示例12: Init_RenderThread
/** Init function that should only be called on render thread. */
void Init_RenderThread(const FProcMeshVertexBuffer* VertexBuffer)
{
check(IsInRenderingThread());
// Initialize the vertex factory's stream components.
DataType NewData;
NewData.PositionComponent = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FDynamicMeshVertex, Position, VET_Float3);
NewData.TextureCoordinates.Add(
FVertexStreamComponent(VertexBuffer, STRUCT_OFFSET(FDynamicMeshVertex, TextureCoordinate), sizeof(FDynamicMeshVertex), VET_Float2)
);
NewData.TangentBasisComponents[0] = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FDynamicMeshVertex, TangentX, VET_PackedNormal);
NewData.TangentBasisComponents[1] = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FDynamicMeshVertex, TangentZ, VET_PackedNormal);
NewData.ColorComponent = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VertexBuffer, FDynamicMeshVertex, Color, VET_Color);
SetData(NewData);
}
示例13: InitRHI
virtual void InitRHI() override
{
uint16 Stride = sizeof(FDistortionVertex);
FVertexDeclarationElementList Elements;
Elements.Add(FVertexElement(0, STRUCT_OFFSET(FDistortionVertex, Position),VET_Float2,0, Stride));
Elements.Add(FVertexElement(0, STRUCT_OFFSET(FDistortionVertex, TexR), VET_Float2, 1, Stride));
Elements.Add(FVertexElement(0, STRUCT_OFFSET(FDistortionVertex, TexG), VET_Float2, 2, Stride));
Elements.Add(FVertexElement(0, STRUCT_OFFSET(FDistortionVertex, TexB), VET_Float2, 3, Stride));
Elements.Add(FVertexElement(0, STRUCT_OFFSET(FDistortionVertex, VignetteFactor), VET_Float1, 4, Stride));
Elements.Add(FVertexElement(0, STRUCT_OFFSET(FDistortionVertex, TimewarpFactor), VET_Float1, 5, Stride));
VertexDeclarationRHI = RHICreateVertexDeclaration(Elements);
}
示例14: pmcCalcCrc_T01
u_int32_t
pmcCalcCrc_T01 (void *bufp)
{
FLD_TYPE2 *buf = bufp;
u_int32_t crc; /* */
/* */
sbeCrc (
(u_int8_t *) &buf->type,
(u_int32_t) STRUCT_OFFSET (FLD_TYPE1, Crc32),
(u_int32_t) 0,
(u_int32_t *) &crc);
#ifdef EEPROM_TYPE_DEBUG
pr_info("sbeCrc: crc 1 calculated as %08x\n", crc); /* */
#endif
return ~crc;
}
示例15: check
void FPaperSpriteVertexFactory::Init(const FPaperSpriteVertexBuffer* InVertexBuffer)
{
check(!IsInRenderingThread());
ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER(
InitPaperSpriteVertexFactory,
FPaperSpriteVertexFactory*,VertexFactory,this,
const FPaperSpriteVertexBuffer*,VB,InVertexBuffer,
{
// Initialize the vertex factory's stream components.
DataType NewData;
NewData.PositionComponent = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VB,FPaperSpriteVertex,Position,VET_Float3);
NewData.TangentBasisComponents[0] = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VB,FPaperSpriteVertex,TangentX,VET_PackedNormal);
NewData.TangentBasisComponents[1] = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VB,FPaperSpriteVertex,TangentZ,VET_PackedNormal);
NewData.ColorComponent = STRUCTMEMBER_VERTEXSTREAMCOMPONENT(VB,FPaperSpriteVertex,Color,VET_Color);
NewData.TextureCoordinates.Add(FVertexStreamComponent(VB, STRUCT_OFFSET(FPaperSpriteVertex,TexCoords), sizeof(FPaperSpriteVertex), VET_Float2));
VertexFactory->SetData(NewData);
});