Skip to content
Browse files

Fix inference of pixel-format and pixel-type for unsigned/integer for…

  • Loading branch information...
Shinmera committed Aug 19, 2019
1 parent 80627c6 commit 3a8359688710343163dd5f6b9641beae98ba9d63
Showing with 28 additions and 7 deletions.
  1. +2 −2 resources/texture.lisp
  2. +26 −5 toolkit.lisp
@@ -63,10 +63,10 @@
(not (getf args :pixel-format))
(not (slot-boundp texture 'pixel-format)))
(setf (getf args :pixel-format) (texture-internal-format->pixel-format (getf args :internal-format))))
(when (and (getf args :pixel-format)
(when (and (getf args :internal-format)
(not (getf args :pixel-type))
(not (slot-boundp texture 'pixel-type)))
(setf (getf args :pixel-type) (pixel-format->pixel-type (getf args :pixel-format))))
(setf (getf args :pixel-type) (texture-internal-format->pixel-type (getf args :internal-format))))
(apply #'call-next-method texture slots args))

(defmethod shared-initialize :before ((texture texture) slots &rest initargs)
@@ -449,16 +449,22 @@
((:depth-stencil :depth32f-stencil8 :depth24-stencil8)
((:red :r8 :r8-snorm :r16 :r16-snorm :r16f :r32f :r8i :r8ui :r16i :r16ui :r32i :r32ui :compressed-red :compressed-red-rgtc1 :compressed-signed-red-rgtc1)
((:r8i :r8ui :r16i :r16ui :r32i :r32ui)
((:rgb8i :rgb8ui :rgb16i :rgb16ui :rgb32i :rgb32ui)
((:rgba8i :rgba8ui :rgba16i :rgba16ui :rgba32i :rgba32ui)
((:red :r8 :r8-snorm :r16 :r16-snorm :r16f :r32f :compressed-red :compressed-red-rgtc1 :compressed-signed-red-rgtc1)
((:rg :rg8 :rg8-snorm :rg16 :rg16-snorm :rg16f :rg32f :rg8i :rg8ui :rg16i :rg16ui :rg32i :rg32ui :compressed-rg :compressed-rg-rgtc2 :compressed-signed-rg-rgtc2)
((:rg :rg8 :rg8-snorm :rg16 :rg16-snorm :rg16f :rg32f :compressed-rg :compressed-rg-rgtc2 :compressed-signed-rg-rgtc2)
((:rgb :r3-g3-b2 :rgb4 :rgb5 :rgb8 :rgb8-snorm :rgb10 :rgb12 :rgb16-snorm :rgba2 :rgba4 :rgb16f :rgb32f
:r11f-g11f-b10f :rgb9-e5 :rgb8i :rgb8ui :rgb16i :rgb16ui :rgb32i :rgb32ui :srgb :srgb8
:r11f-g11f-b10f :rgb9-e5 :srgb :srgb8
:compressed-rgb :compressed-srgb :compressed-rgb-bptc-signed-float :compressed-rgb-bptc-unsigned-float)
((:rgba :rgb5-a1 :rgba8 :rgba8-snorm :rgb10-a2 :rgb10-a2ui :rgba12 :rgba16 :srgb-alpha :srgb8-alpha8
:rgba16f :rgba32f :rgba8i :rgba8ui :rgba16i :rgba16ui :rgba32i :rgba32ui
:rgba16f :rgba32f
:compressed-rgba :compressed-srgb-alpha :compressed-rgba-bptc-unorm :compressed-srgb-alpha-bptc-unorm)

@@ -469,6 +475,21 @@
(:depth32f-stencil8 :unsigned-int-32-8)
(T :unsigned-byte)))

(defun texture-internal-format->pixel-type (format)
(case format
(:depth-stencil :unsigned-int-24-8)
(:depth24-stencil8 :unsigned-int-24-8)
(:depth32f-stencil8 :unsigned-int-32-8)
((:r8i :rg8i :rgb8i :rgba8i) :byte)
((:r16i :rg16i :rgb16i :rgba16i) :short)
((:r32i :rg32i :rgb32i :rgba32i) :int)
((:r8ui :rg8ui :rgb8ui :rgba8ui) :unsigned-byte)
((:r16ui :rg16ui :rgb16ui :rgba16ui) :unsigned-short)
((:r32ui :rg32ui :rgb32ui :rgba32ui) :unsigned-int)
((:r16f :rg16f :rgb16f :rgba16f) :half-float)
((:r32f :rg32f :rgb32f :rgba32f) :float)
(T :unsigned-byte)))

(define-enum-check texture-target
:texture-1d :texture-2d :texture-3d
:texture-1d-array :texture-2d-array
@@ -520,7 +541,7 @@
:unsigned-byte :byte
:unsigned-short :short
:unsigned-int :int
:half-float :float
:unsigned-byte-3-3-2 :unsigned-byte-2-3-3-rev
:unsigned-short-5-6-5 :unsigned-short-5-6-5-rev
:unsigned-short-4-4-4-4 :unsigned-short-4-4-4-4-rev

0 comments on commit 3a83596

Please sign in to comment.
You can’t perform that action at this time.