gallium/swr: Fix compilation warnings
In some places in SWR cod objects are initialized using memset/memcpy. This is usually done to enable allocating those objects in aligned memory. It generates compilation warnings though, which are worked around by casting the pointers to void* before calling memset/memcpy. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5777>
This commit is contained in:
@@ -106,7 +106,7 @@ void BucketManager::PrintBucket(
|
||||
std::string str = arrows[level];
|
||||
str += desc.name;
|
||||
char hier[80];
|
||||
strcpy_s(hier, sizeof(hier), str.c_str());
|
||||
strcpy_s(hier, sizeof(hier)-1, str.c_str());
|
||||
|
||||
// print out
|
||||
fprintf(f,
|
||||
|
@@ -142,8 +142,8 @@ HANDLE SwrCreateContext(SWR_CREATECONTEXT_INFO* pCreateInfo)
|
||||
pContext->workerPrivateState = *pCreateInfo->pWorkerPrivateState;
|
||||
}
|
||||
|
||||
memset(&pContext->WaitLock, 0, sizeof(pContext->WaitLock));
|
||||
memset(&pContext->FifosNotEmpty, 0, sizeof(pContext->FifosNotEmpty));
|
||||
memset((void*)&pContext->WaitLock, 0, sizeof(pContext->WaitLock));
|
||||
memset((void*)&pContext->FifosNotEmpty, 0, sizeof(pContext->FifosNotEmpty));
|
||||
new (&pContext->WaitLock) std::mutex();
|
||||
new (&pContext->FifosNotEmpty) std::condition_variable();
|
||||
|
||||
@@ -230,7 +230,7 @@ HANDLE SwrCreateContext(SWR_CREATECONTEXT_INFO* pCreateInfo)
|
||||
|
||||
void CopyState(DRAW_STATE& dst, const DRAW_STATE& src)
|
||||
{
|
||||
memcpy(&dst.state, &src.state, sizeof(API_STATE));
|
||||
memcpy((void*)&dst.state, (void*)&src.state, sizeof(API_STATE));
|
||||
}
|
||||
|
||||
template <bool IsDraw>
|
||||
@@ -489,7 +489,7 @@ void SWR_API SwrRestoreState(HANDLE hContext, const void* pStateBlock, size_t me
|
||||
auto pDst = GetDrawState(pContext);
|
||||
assert(pStateBlock && memSize >= sizeof(*pDst));
|
||||
|
||||
memcpy(pDst, pStateBlock, sizeof(*pDst));
|
||||
memcpy((void*)pDst, (void*)pStateBlock, sizeof(*pDst));
|
||||
}
|
||||
|
||||
void SetupDefaultState(SWR_CONTEXT* pContext)
|
||||
@@ -748,7 +748,7 @@ void SwrSetRastState(HANDLE hContext, const SWR_RASTSTATE* pRastState)
|
||||
SWR_CONTEXT* pContext = GetContext(hContext);
|
||||
API_STATE* pState = GetDrawState(pContext);
|
||||
|
||||
memcpy(&pState->rastState, pRastState, sizeof(SWR_RASTSTATE));
|
||||
memcpy((void*)&pState->rastState, (void*)pRastState, sizeof(SWR_RASTSTATE));
|
||||
}
|
||||
|
||||
void SwrSetViewports(HANDLE hContext,
|
||||
|
@@ -1243,7 +1243,7 @@ static void AllocateTessellationData(SWR_CONTEXT* pContext)
|
||||
{
|
||||
gt_pTessellationThreadData =
|
||||
(TessellationThreadLocalData*)AlignedMalloc(sizeof(TessellationThreadLocalData), 64);
|
||||
memset(gt_pTessellationThreadData, 0, sizeof(*gt_pTessellationThreadData));
|
||||
memset((void*)gt_pTessellationThreadData, 0, sizeof(*gt_pTessellationThreadData));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -46,7 +46,7 @@ public:
|
||||
mNumEntries = numEntries;
|
||||
mpRingBuffer = (T*)AlignedMalloc(sizeof(T) * numEntries, 64);
|
||||
SWR_ASSERT(mpRingBuffer != nullptr);
|
||||
memset(mpRingBuffer, 0, sizeof(T) * numEntries);
|
||||
memset((void*)mpRingBuffer, 0, sizeof(T) * numEntries);
|
||||
}
|
||||
|
||||
void Destroy()
|
||||
|
@@ -108,45 +108,6 @@ namespace SwrJit
|
||||
return (uint16_t)tmpVal;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Convert an IEEE 754 16-bit float to an 32-bit single precision
|
||||
/// float
|
||||
/// @param val - 16-bit float
|
||||
/// @todo Maybe move this outside of this file into a header?
|
||||
static float ConvertFloat16ToFloat32(uint32_t val)
|
||||
{
|
||||
uint32_t result;
|
||||
if ((val & 0x7fff) == 0)
|
||||
{
|
||||
result = ((uint32_t)(val & 0x8000)) << 16;
|
||||
}
|
||||
else if ((val & 0x7c00) == 0x7c00)
|
||||
{
|
||||
result = ((val & 0x3ff) == 0) ? 0x7f800000 : 0x7fc00000;
|
||||
result |= ((uint32_t)val & 0x8000) << 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t sign = (val & 0x8000) << 16;
|
||||
uint32_t mant = (val & 0x3ff) << 13;
|
||||
uint32_t exp = (val >> 10) & 0x1f;
|
||||
if ((exp == 0) && (mant != 0)) // Adjust exponent and mantissa for denormals
|
||||
{
|
||||
mant <<= 1;
|
||||
while (mant < (0x400 << 13))
|
||||
{
|
||||
exp--;
|
||||
mant <<= 1;
|
||||
}
|
||||
mant &= (0x3ff << 13);
|
||||
}
|
||||
exp = ((exp - 15 + 127) & 0xff) << 23;
|
||||
result = sign | exp | mant;
|
||||
}
|
||||
|
||||
return *(float*)&result;
|
||||
}
|
||||
|
||||
Constant* Builder::C(bool i) { return ConstantInt::get(IRB()->getInt1Ty(), (i ? 1 : 0)); }
|
||||
|
||||
Constant* Builder::C(char i) { return ConstantInt::get(IRB()->getInt8Ty(), i); }
|
||||
|
@@ -347,8 +347,8 @@ struct ConvertPixelsSOAtoAOS
|
||||
{
|
||||
static const uint32_t MAX_RASTER_TILE_BYTES = 16 * 16; // 16 pixels * 16 bytes per pixel
|
||||
|
||||
OSALIGNSIMD16(uint8_t) soaTile[MAX_RASTER_TILE_BYTES];
|
||||
OSALIGNSIMD16(uint8_t) aosTile[MAX_RASTER_TILE_BYTES];
|
||||
OSALIGNSIMD16(uint8_t) soaTile[MAX_RASTER_TILE_BYTES] = {0};
|
||||
OSALIGNSIMD16(uint8_t) aosTile[MAX_RASTER_TILE_BYTES] = {0};
|
||||
|
||||
// Convert from SrcFormat --> DstFormat
|
||||
simd16vector src;
|
||||
|
@@ -491,7 +491,7 @@ swr_create_context(struct pipe_screen *p_screen, void *priv, unsigned flags)
|
||||
{
|
||||
struct swr_context *ctx = (struct swr_context *)
|
||||
AlignedMalloc(sizeof(struct swr_context), KNOB_SIMD_BYTES);
|
||||
memset(ctx, 0, sizeof(struct swr_context));
|
||||
memset((void*)ctx, 0, sizeof(struct swr_context));
|
||||
|
||||
swr_screen(p_screen)->pfnSwrGetInterface(ctx->api);
|
||||
swr_screen(p_screen)->pfnSwrGetTileInterface(ctx->tileApi);
|
||||
|
@@ -189,7 +189,7 @@ swr_generate_fs_key(struct swr_jit_fs_key &key,
|
||||
struct swr_context *ctx,
|
||||
swr_fragment_shader *swr_fs)
|
||||
{
|
||||
memset(&key, 0, sizeof(key));
|
||||
memset((void*)&key, 0, sizeof(key));
|
||||
|
||||
key.nr_cbufs = ctx->framebuffer.nr_cbufs;
|
||||
key.light_twoside = ctx->rasterizer->light_twoside;
|
||||
@@ -221,7 +221,7 @@ swr_generate_vs_key(struct swr_jit_vs_key &key,
|
||||
struct swr_context *ctx,
|
||||
swr_vertex_shader *swr_vs)
|
||||
{
|
||||
memset(&key, 0, sizeof(key));
|
||||
memset((void*)&key, 0, sizeof(key));
|
||||
|
||||
key.clip_plane_mask =
|
||||
swr_vs->info.base.clipdist_writemask ?
|
||||
@@ -235,7 +235,7 @@ void
|
||||
swr_generate_fetch_key(struct swr_jit_fetch_key &key,
|
||||
struct swr_vertex_element_state *velems)
|
||||
{
|
||||
memset(&key, 0, sizeof(key));
|
||||
memset((void*)&key, 0, sizeof(key));
|
||||
|
||||
key.fsState = velems->fsState;
|
||||
}
|
||||
@@ -245,7 +245,7 @@ swr_generate_gs_key(struct swr_jit_gs_key &key,
|
||||
struct swr_context *ctx,
|
||||
swr_geometry_shader *swr_gs)
|
||||
{
|
||||
memset(&key, 0, sizeof(key));
|
||||
memset((void*)&key, 0, sizeof(key));
|
||||
|
||||
struct tgsi_shader_info *pPrevShader = nullptr;
|
||||
|
||||
@@ -270,7 +270,7 @@ swr_generate_tcs_key(struct swr_jit_tcs_key &key,
|
||||
struct swr_context *ctx,
|
||||
swr_tess_control_shader *swr_tcs)
|
||||
{
|
||||
memset(&key, 0, sizeof(key));
|
||||
memset((void*)&key, 0, sizeof(key));
|
||||
|
||||
struct tgsi_shader_info *pPrevShader = &ctx->vs->info.base;
|
||||
|
||||
@@ -294,7 +294,7 @@ swr_generate_tes_key(struct swr_jit_tes_key &key,
|
||||
struct swr_context *ctx,
|
||||
swr_tess_evaluation_shader *swr_tes)
|
||||
{
|
||||
memset(&key, 0, sizeof(key));
|
||||
memset((void*)&key, 0, sizeof(key));
|
||||
|
||||
struct tgsi_shader_info *pPrevShader = nullptr;
|
||||
|
||||
|
@@ -584,7 +584,7 @@ swr_create_vertex_elements_state(struct pipe_context *pipe,
|
||||
assert(num_elements <= PIPE_MAX_ATTRIBS);
|
||||
velems = new swr_vertex_element_state;
|
||||
if (velems) {
|
||||
memset(&velems->fsState, 0, sizeof(velems->fsState));
|
||||
memset((void*)&velems->fsState, 0, sizeof(velems->fsState));
|
||||
velems->fsState.bVertexIDOffsetEnable = true;
|
||||
velems->fsState.numAttribs = num_elements;
|
||||
for (unsigned i = 0; i < num_elements; i++) {
|
||||
|
Reference in New Issue
Block a user