aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorjzielins <[email protected]>2020-07-06 17:38:02 +0200
committerJan Zielinski <[email protected]>2020-07-07 09:24:47 +0000
commit53e204dc26ec89ddc22de864711c844684fb67a8 (patch)
treed6f5df4b51c6672fea28bf917beec7ee0138732e /src/gallium/drivers
parent846f4f95dd8b0e514592074aa18d797afe914463 (diff)
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>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/swr/rasterizer/common/rdtsc_buckets.cpp2
-rw-r--r--src/gallium/drivers/swr/rasterizer/core/api.cpp10
-rw-r--r--src/gallium/drivers/swr/rasterizer/core/frontend.cpp2
-rw-r--r--src/gallium/drivers/swr/rasterizer/core/ringbuffer.h2
-rw-r--r--src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp39
-rw-r--r--src/gallium/drivers/swr/rasterizer/memory/StoreTile.h36
-rw-r--r--src/gallium/drivers/swr/swr_context.cpp2
-rw-r--r--src/gallium/drivers/swr/swr_shader.cpp12
-rw-r--r--src/gallium/drivers/swr/swr_state.cpp2
9 files changed, 34 insertions, 73 deletions
diff --git a/src/gallium/drivers/swr/rasterizer/common/rdtsc_buckets.cpp b/src/gallium/drivers/swr/rasterizer/common/rdtsc_buckets.cpp
index 2404ae7590d..e2076e8fc44 100644
--- a/src/gallium/drivers/swr/rasterizer/common/rdtsc_buckets.cpp
+++ b/src/gallium/drivers/swr/rasterizer/common/rdtsc_buckets.cpp
@@ -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,
diff --git a/src/gallium/drivers/swr/rasterizer/core/api.cpp b/src/gallium/drivers/swr/rasterizer/core/api.cpp
index 04f03c78f42..31f9fe2c2bb 100644
--- a/src/gallium/drivers/swr/rasterizer/core/api.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/api.cpp
@@ -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,
diff --git a/src/gallium/drivers/swr/rasterizer/core/frontend.cpp b/src/gallium/drivers/swr/rasterizer/core/frontend.cpp
index 63beac180d9..13aa89ed5dd 100644
--- a/src/gallium/drivers/swr/rasterizer/core/frontend.cpp
+++ b/src/gallium/drivers/swr/rasterizer/core/frontend.cpp
@@ -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));
}
}
diff --git a/src/gallium/drivers/swr/rasterizer/core/ringbuffer.h b/src/gallium/drivers/swr/rasterizer/core/ringbuffer.h
index 133420e6f3d..2e758f43753 100644
--- a/src/gallium/drivers/swr/rasterizer/core/ringbuffer.h
+++ b/src/gallium/drivers/swr/rasterizer/core/ringbuffer.h
@@ -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()
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp b/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp
index 3ac11a8f11e..0ee727cc8d8 100644
--- a/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp
+++ b/src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp
@@ -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); }
diff --git a/src/gallium/drivers/swr/rasterizer/memory/StoreTile.h b/src/gallium/drivers/swr/rasterizer/memory/StoreTile.h
index 2d32e90330e..1b7698cc5b8 100644
--- a/src/gallium/drivers/swr/rasterizer/memory/StoreTile.h
+++ b/src/gallium/drivers/swr/rasterizer/memory/StoreTile.h
@@ -19,11 +19,11 @@
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
-*
+*
* @file StoreTile.h
-*
+*
* @brief Functionality for Store.
-*
+*
******************************************************************************/
#pragma once
@@ -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;
@@ -580,10 +580,10 @@ INLINE static void FlatConvert(const uint8_t* pSrc, uint8_t* pDst, uint8_t* pDst
static const uint32_t offset = sizeof(simdscalar);
// swizzle rgba -> bgra while we load
- simdscalar vComp0 = _simd_load_ps((const float*)(pSrc + (FormatTraits<DstFormat>::swizzle(0))*offset)); // float32 rrrrrrrr
+ simdscalar vComp0 = _simd_load_ps((const float*)(pSrc + (FormatTraits<DstFormat>::swizzle(0))*offset)); // float32 rrrrrrrr
simdscalar vComp1 = _simd_load_ps((const float*)(pSrc + (FormatTraits<DstFormat>::swizzle(1))*offset)); // float32 gggggggg
- simdscalar vComp2 = _simd_load_ps((const float*)(pSrc + (FormatTraits<DstFormat>::swizzle(2))*offset)); // float32 bbbbbbbb
- simdscalar vComp3 = _simd_load_ps((const float*)(pSrc + (FormatTraits<DstFormat>::swizzle(3))*offset)); // float32 aaaaaaaa
+ simdscalar vComp2 = _simd_load_ps((const float*)(pSrc + (FormatTraits<DstFormat>::swizzle(2))*offset)); // float32 bbbbbbbb
+ simdscalar vComp3 = _simd_load_ps((const float*)(pSrc + (FormatTraits<DstFormat>::swizzle(3))*offset)); // float32 aaaaaaaa
// clamp
vComp0 = _simd_max_ps(vComp0, _simd_setzero_ps());
@@ -607,15 +607,15 @@ INLINE static void FlatConvert(const uint8_t* pSrc, uint8_t* pDst, uint8_t* pDst
}
// convert float components from 0.0f .. 1.0f to correct scale for 0 .. 255 dest format
- vComp0 = _simd_mul_ps(vComp0, _simd_set1_ps(FormatTraits<DstFormat>::fromFloat(0)));
+ vComp0 = _simd_mul_ps(vComp0, _simd_set1_ps(FormatTraits<DstFormat>::fromFloat(0)));
vComp1 = _simd_mul_ps(vComp1, _simd_set1_ps(FormatTraits<DstFormat>::fromFloat(1)));
vComp2 = _simd_mul_ps(vComp2, _simd_set1_ps(FormatTraits<DstFormat>::fromFloat(2)));
vComp3 = _simd_mul_ps(vComp3, _simd_set1_ps(FormatTraits<DstFormat>::fromFloat(3)));
// moving to 8 wide integer vector types
simdscalari src0 = _simd_cvtps_epi32(vComp0); // padded byte rrrrrrrr
- simdscalari src1 = _simd_cvtps_epi32(vComp1); // padded byte gggggggg
- simdscalari src2 = _simd_cvtps_epi32(vComp2); // padded byte bbbbbbbb
+ simdscalari src1 = _simd_cvtps_epi32(vComp1); // padded byte gggggggg
+ simdscalari src2 = _simd_cvtps_epi32(vComp2); // padded byte bbbbbbbb
simdscalari src3 = _simd_cvtps_epi32(vComp3); // padded byte aaaaaaaa
#if KNOB_ARCH <= KNOB_ARCH_AVX
@@ -743,9 +743,9 @@ INLINE static void FlatConvertNoAlpha(const uint8_t* pSrc, uint8_t* pDst, uint8_
static const uint32_t offset = sizeof(simdscalar);
// swizzle rgba -> bgra while we load
- simdscalar vComp0 = _simd_load_ps((const float*)(pSrc + (FormatTraits<DstFormat>::swizzle(0))*offset)); // float32 rrrrrrrr
+ simdscalar vComp0 = _simd_load_ps((const float*)(pSrc + (FormatTraits<DstFormat>::swizzle(0))*offset)); // float32 rrrrrrrr
simdscalar vComp1 = _simd_load_ps((const float*)(pSrc + (FormatTraits<DstFormat>::swizzle(1))*offset)); // float32 gggggggg
- simdscalar vComp2 = _simd_load_ps((const float*)(pSrc + (FormatTraits<DstFormat>::swizzle(2))*offset)); // float32 bbbbbbbb
+ simdscalar vComp2 = _simd_load_ps((const float*)(pSrc + (FormatTraits<DstFormat>::swizzle(2))*offset)); // float32 bbbbbbbb
// clamp
vComp0 = _simd_max_ps(vComp0, _simd_setzero_ps());
vComp0 = _simd_min_ps(vComp0, _simd_set1_ps(1.0f));
@@ -771,8 +771,8 @@ INLINE static void FlatConvertNoAlpha(const uint8_t* pSrc, uint8_t* pDst, uint8_
// moving to 8 wide integer vector types
simdscalari src0 = _simd_cvtps_epi32(vComp0); // padded byte rrrrrrrr
- simdscalari src1 = _simd_cvtps_epi32(vComp1); // padded byte gggggggg
- simdscalari src2 = _simd_cvtps_epi32(vComp2); // padded byte bbbbbbbb
+ simdscalari src1 = _simd_cvtps_epi32(vComp1); // padded byte gggggggg
+ simdscalari src2 = _simd_cvtps_epi32(vComp2); // padded byte bbbbbbbb
#if KNOB_ARCH <= KNOB_ARCH_AVX
@@ -1062,13 +1062,13 @@ struct OptStoreRasterTile< TilingTraits<SWR_TILE_NONE, 8>, SrcFormat, DstFormat>
return GenericStoreTile::Store(pSrc, pDstSurface, x, y, sampleNum, renderTargetArrayIndex);
}
- uint8_t *pDst = (uint8_t*)ComputeSurfaceAddress<false, false>(x, y, pDstSurface->arrayIndex + renderTargetArrayIndex,
+ uint8_t *pDst = (uint8_t*)ComputeSurfaceAddress<false, false>(x, y, pDstSurface->arrayIndex + renderTargetArrayIndex,
pDstSurface->arrayIndex + renderTargetArrayIndex, sampleNum, pDstSurface->lod, pDstSurface);
const uint32_t dx = SIMD16_TILE_X_DIM * DST_BYTES_PER_PIXEL;
const uint32_t dy = SIMD16_TILE_Y_DIM * pDstSurface->pitch - KNOB_TILE_X_DIM * DST_BYTES_PER_PIXEL;
- uint8_t* ppDsts[] =
+ uint8_t* ppDsts[] =
{
pDst, // row 0, col 0
pDst + pDstSurface->pitch, // row 1, col 0
@@ -1127,7 +1127,7 @@ struct OptStoreRasterTile< TilingTraits<SWR_TILE_NONE, 16>, SrcFormat, DstFormat
return GenericStoreTile::Store(pSrc, pDstSurface, x, y, sampleNum, renderTargetArrayIndex);
}
- uint8_t *pDst = (uint8_t*)ComputeSurfaceAddress<false, false>(x, y, pDstSurface->arrayIndex + renderTargetArrayIndex,
+ uint8_t *pDst = (uint8_t*)ComputeSurfaceAddress<false, false>(x, y, pDstSurface->arrayIndex + renderTargetArrayIndex,
pDstSurface->arrayIndex + renderTargetArrayIndex, sampleNum, pDstSurface->lod, pDstSurface);
const uint32_t dx = SIMD16_TILE_X_DIM * DST_BYTES_PER_PIXEL;
diff --git a/src/gallium/drivers/swr/swr_context.cpp b/src/gallium/drivers/swr/swr_context.cpp
index 83ea856ecd7..e552bc6bd0e 100644
--- a/src/gallium/drivers/swr/swr_context.cpp
+++ b/src/gallium/drivers/swr/swr_context.cpp
@@ -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);
diff --git a/src/gallium/drivers/swr/swr_shader.cpp b/src/gallium/drivers/swr/swr_shader.cpp
index 5f4ba348629..ab8b00a5d96 100644
--- a/src/gallium/drivers/swr/swr_shader.cpp
+++ b/src/gallium/drivers/swr/swr_shader.cpp
@@ -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;
diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp
index 4e9a25345a3..01758f5f910 100644
--- a/src/gallium/drivers/swr/swr_state.cpp
+++ b/src/gallium/drivers/swr/swr_state.cpp
@@ -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++) {