summaryrefslogtreecommitdiffstats
path: root/src/panfrost
diff options
context:
space:
mode:
authorIcecream95 <[email protected]>2020-01-09 15:13:58 +1300
committerTomeu Vizoso <[email protected]>2020-01-10 06:51:42 +0000
commitf2f12776248874b2a689cbba8faeb6e4e2144354 (patch)
tree1358d91e93a6bafe93716654e52b49153ff65f6c /src/panfrost
parentdaf1d5ad4c901f7ffc2d78e0741fa16675ce8150 (diff)
panfrost: Add negative lod bias support
Reviewed-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/panfrost')
-rw-r--r--src/panfrost/include/panfrost-job.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/panfrost/include/panfrost-job.h b/src/panfrost/include/panfrost-job.h
index 49c55f1f93e..dfc5d83a80d 100644
--- a/src/panfrost/include/panfrost-job.h
+++ b/src/panfrost/include/panfrost-job.h
@@ -29,6 +29,7 @@
#define __PANFROST_JOB_H__
#include <stdint.h>
+#include <stdbool.h>
#include <panfrost-misc.h>
enum mali_job_type {
@@ -1253,13 +1254,14 @@ struct mali_texture_descriptor {
#define DECODE_FIXED_16(x) ((float) (x / 256.0))
-static inline uint16_t
-FIXED_16(float x)
+static inline int16_t
+FIXED_16(float x, bool allow_negative)
{
/* Clamp inputs, accounting for float error */
float max_lod = (32.0 - (1.0 / 512.0));
+ float min_lod = allow_negative ? -max_lod : 0.0;
- x = ((x > max_lod) ? max_lod : ((x < 0.0) ? 0.0 : x));
+ x = ((x > max_lod) ? max_lod : ((x < min_lod) ? min_lod : x));
return (int) (x * 256.0);
}
@@ -1267,13 +1269,13 @@ FIXED_16(float x)
struct mali_sampler_descriptor {
uint16_t filter_mode;
- /* Fixed point. Upper 8-bits is before the decimal point, although it
- * caps [0-31]. Lower 8-bits is after the decimal point: int(round(x *
- * 256)) */
+ /* Fixed point, signed.
+ * Upper 7 bits before the decimal point, although it caps [0-31].
+ * Lower 8 bits after the decimal point: int(round(x * 256)) */
- uint16_t lod_bias;
- uint16_t min_lod;
- uint16_t max_lod;
+ int16_t lod_bias;
+ int16_t min_lod;
+ int16_t max_lod;
/* All one word in reality, but packed a bit. Comparisons are flipped
* from OpenGL. */