Files
Gleb Mazovetskiy 44ed0296d8 dun_render: Overhaul mask handling
We notice that masks can be described by 2 parameters:

1. Whether they have 0 or 1 as their high bits.
2. Whether they shift to the left or to the right on the next line.

Describing masks this way allows us to lift them to template variables and simplify the code.
We also avoid handling the mask in the `RenderLine` loop entirely.

Also fixes a foliage rendering bug: Transparent foliage pixels were previously blended but they should have been simply skipped.
2022-12-04 21:53:52 +01:00

65 lines
1.6 KiB
C

/**
* @file attributes.h
*
* Macros for attributes on functions, variables, etc.
*/
#pragma once
#ifdef __has_attribute
#define DVL_HAVE_ATTRIBUTE(x) __has_attribute(x)
#else
#define DVL_HAVE_ATTRIBUTE(x) 0
#endif
#if DVL_HAVE_ATTRIBUTE(format) || (defined(__GNUC__) && !defined(__clang__))
#define DVL_PRINTF_ATTRIBUTE(fmtargnum, firstarg) \
__attribute__((__format__(__printf__, fmtargnum, firstarg)))
#else
#define DVL_PRINTF_ATTRIBUTE(fmtargnum, firstarg)
#endif
#if DVL_HAVE_ATTRIBUTE(always_inline)
#define DVL_ALWAYS_INLINE inline __attribute__((always_inline))
#elif defined(_MSC_VER)
#define DVL_ALWAYS_INLINE __forceinline
#else
#define DVL_ALWAYS_INLINE inline
#endif
#if DVL_HAVE_ATTRIBUTE(hot)
#define DVL_ATTRIBUTE_HOT __attribute__((hot))
#else
#define DVL_ATTRIBUTE_HOT
#endif
// Any global data used by tests must be marked with `DVL_API_FOR_TEST`.
#if defined(_MSC_VER) && defined(BUILD_TESTING)
#ifdef _DVL_EXPORTING
#define DVL_API_FOR_TEST __declspec(dllexport)
#else
#define DVL_API_FOR_TEST __declspec(dllimport)
#endif
#else
#define DVL_API_FOR_TEST
#endif
#if defined(__clang__)
#define DVL_REINITIALIZES [[clang::reinitializes]]
#elif DVL_HAVE_ATTRIBUTE(reinitializes)
#define DVL_REINITIALIZES __attribute__((reinitializes))
#else
#define DVL_REINITIALIZES
#endif
#if ((defined(__GNUC__) || defined(__clang__)) && !defined(__EXCEPTIONS)) || defined(_MSC_VER) && !_HAS_EXCEPTIONS
#define DVL_EXCEPTIONS 0
#else
#define DVL_EXCEPTIONS 1
#endif
#if defined(_MSC_VER)
#define DVL_RESTRICT __restrict
#else
#define DVL_RESTRICT __restrict__
#endif