Merge remote branch 'origin/master' into gallium_draw_llvm
This commit is contained in:
commit
b6d052e4fd
13
SConstruct
13
SConstruct
|
@ -159,12 +159,9 @@ if platform in ('posix', 'linux', 'freebsd', 'darwin'):
|
|||
])
|
||||
if platform == 'darwin':
|
||||
env.Append(CPPDEFINES = ['_DARWIN_C_SOURCE'])
|
||||
env.Append(CPPPATH = ['/usr/X11R6/include'])
|
||||
env.Append(LIBPATH = ['/usr/X11R6/lib'])
|
||||
env.Append(LIBS = [
|
||||
'm',
|
||||
'pthread',
|
||||
'expat',
|
||||
'dl',
|
||||
])
|
||||
|
||||
|
@ -182,16 +179,6 @@ if dri:
|
|||
if drawllvm:
|
||||
env.Append(CPPDEFINES = ['DRAW_LLVM'])
|
||||
|
||||
# libGL
|
||||
if platform in ('linux', 'freebsd', 'darwin'):
|
||||
env.Append(LIBS = [
|
||||
'X11',
|
||||
'Xext',
|
||||
'Xxf86vm',
|
||||
'Xdamage',
|
||||
'Xfixes',
|
||||
])
|
||||
|
||||
# for debugging
|
||||
#print env.Dump()
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@ def AddOptions(opts):
|
|||
allowed_values=('generic', 'ppc', 'x86', 'x86_64')))
|
||||
opts.Add(EnumOption('platform', 'target platform', default_platform,
|
||||
allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince', 'darwin', 'embedded')))
|
||||
opts.Add(EnumOption('toolchain', 'compiler toolchain', 'default',
|
||||
allowed_values=('default', 'crossmingw', 'winsdk', 'winddk')))
|
||||
opts.Add('toolchain', 'compiler toolchain', 'default')
|
||||
opts.Add(BoolOption('llvm', 'use LLVM', 'no'))
|
||||
opts.Add(BoolOption('dri', 'build DRI drivers', default_dri))
|
||||
|
|
|
@ -128,6 +128,7 @@ def test(dev):
|
|||
scissor.maxy = height
|
||||
ctx.set_scissor(scissor)
|
||||
|
||||
# clip
|
||||
clip = Clip()
|
||||
clip.nr = 0
|
||||
ctx.set_clip(clip)
|
||||
|
|
|
@ -43,18 +43,9 @@ from gallium import *
|
|||
# Enumerate all pixel formats
|
||||
formats = {}
|
||||
for name, value in globals().items():
|
||||
if name.startswith("PIPE_FORMAT_") and isinstance(value, int):
|
||||
if name.startswith("PIPE_FORMAT_") and isinstance(value, int) and name not in ("PIPE_FORMAT_NONE", "PIPE_FORMAT_COUNT"):
|
||||
formats[value] = name
|
||||
|
||||
def is_depth_stencil_format(format):
|
||||
# FIXME: make and use binding to util_format_is_depth_or_stencil
|
||||
return format in (
|
||||
PIPE_FORMAT_Z32_UNORM,
|
||||
PIPE_FORMAT_S8Z24_UNORM,
|
||||
PIPE_FORMAT_X8Z24_UNORM,
|
||||
PIPE_FORMAT_Z16_UNORM,
|
||||
)
|
||||
|
||||
def make_image(width, height, rgba):
|
||||
import Image
|
||||
outimage = Image.new(
|
||||
|
@ -127,16 +118,16 @@ class Test:
|
|||
self._run(result)
|
||||
result.summary()
|
||||
|
||||
def assert_rgba(self, surface, x, y, w, h, expected_rgba, pixel_tol=4.0/256, surface_tol=0.85):
|
||||
def assert_rgba(self, ctx, surface, x, y, w, h, expected_rgba, pixel_tol=4.0/256, surface_tol=0.85):
|
||||
total = h*w
|
||||
different = surface.compare_tile_rgba(x, y, w, h, expected_rgba, tol=pixel_tol)
|
||||
different = ctx.surface_compare_rgba(surface, x, y, w, h, expected_rgba, tol=pixel_tol)
|
||||
if different:
|
||||
sys.stderr.write("%u out of %u pixels differ\n" % (different, total))
|
||||
|
||||
if float(total - different)/float(total) < surface_tol:
|
||||
if 0:
|
||||
rgba = FloatArray(h*w*4)
|
||||
surface.get_tile_rgba(x, y, w, h, rgba)
|
||||
ctx.surface_read_rgba(surface, x, y, w, h, rgba)
|
||||
show_image(w, h, Result=rgba, Expected=expected_rgba)
|
||||
save_image(w, h, rgba, "result.png")
|
||||
save_image(w, h, expected_rgba, "expected.png")
|
||||
|
|
|
@ -56,6 +56,7 @@ class TextureTest(TestCase):
|
|||
|
||||
def test(self):
|
||||
dev = self.dev
|
||||
ctx = self.ctx
|
||||
|
||||
target = self.target
|
||||
format = self.format
|
||||
|
@ -99,21 +100,16 @@ class TextureTest(TestCase):
|
|||
w = dst_surface.width
|
||||
h = dst_surface.height
|
||||
|
||||
# ???
|
||||
stride = pf_get_stride(texture->format, w)
|
||||
size = pf_get_nblocksy(texture->format) * stride
|
||||
stride = util_format_get_stride(format, w)
|
||||
size = util_format_get_nblocksy(format, h) * stride
|
||||
src_raw = os.urandom(size)
|
||||
|
||||
src_surface.put_tile_raw(0, 0, w, h, src_raw, stride)
|
||||
ctx.surface_write_raw(src_surface, 0, 0, w, h, src_raw, stride)
|
||||
|
||||
ctx = self.dev.context_create()
|
||||
|
||||
ctx.surface_copy(dst_surface, 0, 0,
|
||||
src_surface, 0, 0, w, h)
|
||||
|
||||
ctx.flush()
|
||||
|
||||
dst_raw = dst_surface.get_tile_raw(0, 0, w, h)
|
||||
dst_raw = ctx.surface_read_raw(dst_surface, 0, 0, w, h)
|
||||
|
||||
if dst_raw != src_raw:
|
||||
raise TestFailure
|
||||
|
@ -122,6 +118,7 @@ class TextureTest(TestCase):
|
|||
|
||||
def main():
|
||||
dev = Device()
|
||||
ctx = dev.context_create()
|
||||
suite = TestSuite()
|
||||
|
||||
targets = [
|
||||
|
@ -181,6 +178,7 @@ def main():
|
|||
while zslice < depth >> level:
|
||||
test = TextureTest(
|
||||
dev = dev,
|
||||
ctx = ctx,
|
||||
target = target,
|
||||
format = format,
|
||||
width = size,
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
##########################################################################
|
||||
|
||||
|
||||
import random
|
||||
|
||||
from gallium import *
|
||||
from base import *
|
||||
|
||||
|
@ -115,6 +117,7 @@ class TextureColorSampleTest(TestCase):
|
|||
|
||||
def test(self):
|
||||
dev = self.dev
|
||||
ctx = self.ctx
|
||||
|
||||
target = self.target
|
||||
format = self.format
|
||||
|
@ -125,6 +128,8 @@ class TextureColorSampleTest(TestCase):
|
|||
face = self.face
|
||||
level = self.level
|
||||
zslice = self.zslice
|
||||
minz = 0.0
|
||||
maxz = 1.0
|
||||
|
||||
tex_usage = PIPE_TEXTURE_USAGE_SAMPLER
|
||||
geom_flags = 0
|
||||
|
@ -136,8 +141,6 @@ class TextureColorSampleTest(TestCase):
|
|||
if not dev.is_format_supported(format, target, tex_usage, geom_flags):
|
||||
raise TestSkip
|
||||
|
||||
ctx = self.dev.context_create()
|
||||
|
||||
# disabled blending/masking
|
||||
blend = Blend()
|
||||
blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE
|
||||
|
@ -155,7 +158,6 @@ class TextureColorSampleTest(TestCase):
|
|||
rasterizer = Rasterizer()
|
||||
rasterizer.front_winding = PIPE_WINDING_CW
|
||||
rasterizer.cull_mode = PIPE_WINDING_NONE
|
||||
rasterizer.bypass_vs_clip_and_viewport = 1
|
||||
ctx.set_rasterizer(rasterizer)
|
||||
|
||||
# samplers
|
||||
|
@ -183,14 +185,45 @@ class TextureColorSampleTest(TestCase):
|
|||
)
|
||||
|
||||
expected_rgba = FloatArray(height*width*4)
|
||||
texture.get_surface(
|
||||
surface = texture.get_surface(
|
||||
face = face,
|
||||
level = level,
|
||||
zslice = zslice,
|
||||
).sample_rgba(expected_rgba)
|
||||
)
|
||||
|
||||
ctx.surface_sample_rgba(surface, expected_rgba)
|
||||
|
||||
ctx.set_fragment_sampler_texture(0, texture)
|
||||
|
||||
# viewport
|
||||
viewport = Viewport()
|
||||
scale = FloatArray(4)
|
||||
scale[0] = width
|
||||
scale[1] = height
|
||||
scale[2] = (maxz - minz) / 2.0
|
||||
scale[3] = 1.0
|
||||
viewport.scale = scale
|
||||
translate = FloatArray(4)
|
||||
translate[0] = 0.0
|
||||
translate[1] = 0.0
|
||||
translate[2] = (maxz - minz) / 2.0
|
||||
translate[3] = 0.0
|
||||
viewport.translate = translate
|
||||
ctx.set_viewport(viewport)
|
||||
|
||||
# scissor
|
||||
scissor = Scissor()
|
||||
scissor.minx = 0
|
||||
scissor.miny = 0
|
||||
scissor.maxx = width
|
||||
scissor.maxy = height
|
||||
ctx.set_scissor(scissor)
|
||||
|
||||
# clip
|
||||
clip = Clip()
|
||||
clip.nr = 0
|
||||
ctx.set_clip(clip)
|
||||
|
||||
# framebuffer
|
||||
cbuf_tex = dev.texture_create(
|
||||
PIPE_FORMAT_B8G8R8A8_UNORM,
|
||||
|
@ -265,8 +298,8 @@ class TextureColorSampleTest(TestCase):
|
|||
|
||||
for i in range(0, 4):
|
||||
j = 8*i
|
||||
verts[j + 0] = pos[i][0] # x
|
||||
verts[j + 1] = pos[i][1] # y
|
||||
verts[j + 0] = pos[i][0]/float(width) # x
|
||||
verts[j + 1] = pos[i][1]/float(height) # y
|
||||
verts[j + 2] = 0.0 # z
|
||||
verts[j + 3] = 1.0 # w
|
||||
verts[j + 4] = tex[i][0] # s
|
||||
|
@ -283,7 +316,7 @@ class TextureColorSampleTest(TestCase):
|
|||
|
||||
cbuf = cbuf_tex.get_surface()
|
||||
|
||||
self.assert_rgba(cbuf, x, y, w, h, expected_rgba, 4.0/256, 0.85)
|
||||
self.assert_rgba(ctx, cbuf, x, y, w, h, expected_rgba, 4.0/256, 0.85)
|
||||
|
||||
|
||||
class TextureDepthSampleTest(TestCase):
|
||||
|
@ -302,6 +335,7 @@ class TextureDepthSampleTest(TestCase):
|
|||
|
||||
def test(self):
|
||||
dev = self.dev
|
||||
ctx = self.ctx
|
||||
|
||||
target = self.target
|
||||
format = self.format
|
||||
|
@ -312,6 +346,8 @@ class TextureDepthSampleTest(TestCase):
|
|||
face = self.face
|
||||
level = self.level
|
||||
zslice = self.zslice
|
||||
minz = 0.0
|
||||
maxz = 1.0
|
||||
|
||||
tex_usage = PIPE_TEXTURE_USAGE_SAMPLER
|
||||
geom_flags = 0
|
||||
|
@ -323,8 +359,6 @@ class TextureDepthSampleTest(TestCase):
|
|||
if not dev.is_format_supported(format, target, tex_usage, geom_flags):
|
||||
raise TestSkip
|
||||
|
||||
ctx = self.dev.context_create()
|
||||
|
||||
# disabled blending/masking
|
||||
blend = Blend()
|
||||
blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE
|
||||
|
@ -345,9 +379,24 @@ class TextureDepthSampleTest(TestCase):
|
|||
rasterizer = Rasterizer()
|
||||
rasterizer.front_winding = PIPE_WINDING_CW
|
||||
rasterizer.cull_mode = PIPE_WINDING_NONE
|
||||
rasterizer.bypass_vs_clip_and_viewport = 1
|
||||
ctx.set_rasterizer(rasterizer)
|
||||
|
||||
# viewport
|
||||
viewport = Viewport()
|
||||
scale = FloatArray(4)
|
||||
scale[0] = width
|
||||
scale[1] = height
|
||||
scale[2] = (maxz - minz) / 2.0
|
||||
scale[3] = 1.0
|
||||
viewport.scale = scale
|
||||
translate = FloatArray(4)
|
||||
translate[0] = 0.0
|
||||
translate[1] = 0.0
|
||||
translate[2] = (maxz - minz) / 2.0
|
||||
translate[3] = 0.0
|
||||
viewport.translate = translate
|
||||
ctx.set_viewport(viewport)
|
||||
|
||||
# samplers
|
||||
sampler = Sampler()
|
||||
sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE
|
||||
|
@ -373,14 +422,29 @@ class TextureDepthSampleTest(TestCase):
|
|||
)
|
||||
|
||||
expected_rgba = FloatArray(height*width*4)
|
||||
texture.get_surface(
|
||||
surface = texture.get_surface(
|
||||
face = face,
|
||||
level = level,
|
||||
zslice = zslice,
|
||||
).sample_rgba(expected_rgba)
|
||||
)
|
||||
|
||||
ctx.surface_sample_rgba(surface, expected_rgba)
|
||||
|
||||
ctx.set_fragment_sampler_texture(0, texture)
|
||||
|
||||
# scissor
|
||||
scissor = Scissor()
|
||||
scissor.minx = 0
|
||||
scissor.miny = 0
|
||||
scissor.maxx = width
|
||||
scissor.maxy = height
|
||||
ctx.set_scissor(scissor)
|
||||
|
||||
# clip
|
||||
clip = Clip()
|
||||
clip.nr = 0
|
||||
ctx.set_clip(clip)
|
||||
|
||||
# framebuffer
|
||||
cbuf_tex = dev.texture_create(
|
||||
PIPE_FORMAT_B8G8R8A8_UNORM,
|
||||
|
@ -464,8 +528,8 @@ class TextureDepthSampleTest(TestCase):
|
|||
|
||||
for i in range(0, 4):
|
||||
j = 8*i
|
||||
verts[j + 0] = pos[i][0] # x
|
||||
verts[j + 1] = pos[i][1] # y
|
||||
verts[j + 0] = pos[i][0]/float(width) # x
|
||||
verts[j + 1] = pos[i][1]/float(height) # y
|
||||
verts[j + 2] = 0.0 # z
|
||||
verts[j + 3] = 1.0 # w
|
||||
verts[j + 4] = tex[i][0] # s
|
||||
|
@ -482,12 +546,14 @@ class TextureDepthSampleTest(TestCase):
|
|||
|
||||
zsbuf = zsbuf_tex.get_surface()
|
||||
|
||||
self.assert_rgba(zsbuf, x, y, w, h, expected_rgba, 4.0/256, 0.85)
|
||||
self.assert_rgba(ctx, zsbuf, x, y, w, h, expected_rgba, 4.0/256, 0.85)
|
||||
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
random.seed(0xdead3eef)
|
||||
|
||||
dev = Device()
|
||||
suite = TestSuite()
|
||||
|
||||
|
@ -497,32 +563,9 @@ def main():
|
|||
PIPE_TEXTURE_3D,
|
||||
]
|
||||
|
||||
color_formats = [
|
||||
PIPE_FORMAT_B8G8R8A8_UNORM,
|
||||
PIPE_FORMAT_B8G8R8X8_UNORM,
|
||||
#PIPE_FORMAT_B8G8R8A8_SRGB,
|
||||
PIPE_FORMAT_B5G6R5_UNORM,
|
||||
PIPE_FORMAT_B5G5R5A1_UNORM,
|
||||
PIPE_FORMAT_B4G4R4A4_UNORM,
|
||||
PIPE_FORMAT_A8_UNORM,
|
||||
PIPE_FORMAT_L8_UNORM,
|
||||
PIPE_FORMAT_UYVY,
|
||||
PIPE_FORMAT_DXT1_RGB,
|
||||
#PIPE_FORMAT_DXT1_RGBA,
|
||||
#PIPE_FORMAT_DXT3_RGBA,
|
||||
#PIPE_FORMAT_DXT5_RGBA,
|
||||
]
|
||||
|
||||
depth_formats = [
|
||||
PIPE_FORMAT_Z32_UNORM,
|
||||
PIPE_FORMAT_S8Z24_UNORM,
|
||||
PIPE_FORMAT_X8Z24_UNORM,
|
||||
PIPE_FORMAT_Z16_UNORM,
|
||||
]
|
||||
|
||||
sizes = [64, 32, 16, 8, 4, 2, 1]
|
||||
#sizes = [64, 32, 16, 8, 4, 2, 1]
|
||||
#sizes = [1020, 508, 252, 62, 30, 14, 6, 3]
|
||||
#sizes = [64]
|
||||
sizes = [64]
|
||||
#sizes = [63]
|
||||
|
||||
faces = [
|
||||
|
@ -534,45 +577,48 @@ def main():
|
|||
PIPE_TEX_FACE_NEG_Z,
|
||||
]
|
||||
|
||||
for format in color_formats:
|
||||
for target in targets:
|
||||
for size in sizes:
|
||||
if target == PIPE_TEXTURE_3D:
|
||||
depth = size
|
||||
else:
|
||||
depth = 1
|
||||
for face in faces:
|
||||
if target != PIPE_TEXTURE_CUBE and face:
|
||||
continue
|
||||
levels = lods(size)
|
||||
for last_level in range(levels):
|
||||
for level in range(0, last_level + 1):
|
||||
zslice = 0
|
||||
while zslice < depth >> level:
|
||||
test = TextureColorSampleTest(
|
||||
dev = dev,
|
||||
target = target,
|
||||
format = format,
|
||||
width = size,
|
||||
height = size,
|
||||
depth = depth,
|
||||
last_level = last_level,
|
||||
face = face,
|
||||
level = level,
|
||||
zslice = zslice,
|
||||
)
|
||||
suite.add_test(test)
|
||||
zslice = (zslice + 1)*2 - 1
|
||||
for format in depth_formats:
|
||||
target = PIPE_TEXTURE_2D
|
||||
depth = 1
|
||||
face = 0
|
||||
last_level = 0
|
||||
level = 0
|
||||
zslice = 0
|
||||
for size in sizes:
|
||||
test = TextureDepthSampleTest(
|
||||
ctx = dev.context_create()
|
||||
|
||||
try:
|
||||
n = int(sys.argv[1])
|
||||
except:
|
||||
n = 10000
|
||||
|
||||
for i in range(n):
|
||||
format = random.choice(formats.keys())
|
||||
if not util_format_is_depth_or_stencil(format):
|
||||
is_depth_or_stencil = util_format_is_depth_or_stencil(format)
|
||||
|
||||
if is_depth_or_stencil:
|
||||
target = PIPE_TEXTURE_2D
|
||||
else:
|
||||
target = random.choice(targets)
|
||||
|
||||
size = random.choice(sizes)
|
||||
|
||||
if target == PIPE_TEXTURE_3D:
|
||||
depth = size
|
||||
else:
|
||||
depth = 1
|
||||
|
||||
if target == PIPE_TEXTURE_CUBE:
|
||||
face =random.choice(faces)
|
||||
else:
|
||||
face = PIPE_TEX_FACE_POS_X
|
||||
|
||||
levels = lods(size)
|
||||
last_level = random.randint(0, levels - 1)
|
||||
level = random.randint(0, last_level)
|
||||
zslice = random.randint(0, max(depth >> level, 1) - 1)
|
||||
|
||||
if is_depth_or_stencil:
|
||||
klass = TextureDepthSampleTest
|
||||
else:
|
||||
klass = TextureColorSampleTest
|
||||
|
||||
test = klass(
|
||||
dev = dev,
|
||||
ctx = ctx,
|
||||
target = target,
|
||||
format = format,
|
||||
width = size,
|
|
@ -59,6 +59,7 @@ class TextureTest(TestCase):
|
|||
|
||||
def test(self):
|
||||
dev = self.dev
|
||||
ctx = self.ctx
|
||||
|
||||
target = self.target
|
||||
format = self.format
|
||||
|
@ -86,15 +87,14 @@ class TextureTest(TestCase):
|
|||
|
||||
surface = texture.get_surface(face, level, zslice)
|
||||
|
||||
# ???
|
||||
stride = pf_get_stride(texture->format, w)
|
||||
size = pf_get_nblocksy(texture->format) * stride
|
||||
stride = util_format_get_stride(format, width)
|
||||
size = util_format_get_nblocksy(format, height) * stride
|
||||
|
||||
in_raw = os.urandom(size)
|
||||
|
||||
surface.put_tile_raw(0, 0, surface.width, surface.height, in_raw, stride)
|
||||
ctx.surface_write_raw(surface, 0, 0, surface.width, surface.height, in_raw, stride)
|
||||
|
||||
out_raw = surface.get_tile_raw(0, 0, surface.width, surface.height)
|
||||
out_raw = ctx.surface_read_raw(surface, 0, 0, surface.width, surface.height)
|
||||
|
||||
if in_raw != out_raw:
|
||||
raise TestFailure
|
||||
|
@ -102,6 +102,7 @@ class TextureTest(TestCase):
|
|||
|
||||
def main():
|
||||
dev = Device()
|
||||
ctx = dev.context_create()
|
||||
suite = TestSuite()
|
||||
|
||||
targets = [
|
||||
|
@ -161,6 +162,7 @@ def main():
|
|||
while zslice < depth >> level:
|
||||
test = TextureTest(
|
||||
dev = dev,
|
||||
ctx = ctx,
|
||||
target = target,
|
||||
format = format,
|
||||
width = size,
|
||||
|
|
|
@ -31,17 +31,24 @@
|
|||
|
||||
#include "util/u_format.h"
|
||||
#include "util/u_format_tests.h"
|
||||
#include "util/u_format_pack.h"
|
||||
|
||||
|
||||
static boolean
|
||||
test_format_unpack_4f(const struct util_format_test_case *test)
|
||||
test_format_fetch_float(const struct util_format_description *format_desc,
|
||||
const struct util_format_test_case *test)
|
||||
{
|
||||
float unpacked[4];
|
||||
unsigned i;
|
||||
boolean success;
|
||||
|
||||
util_format_unpack_4f(test->format, unpacked, test->packed);
|
||||
/*
|
||||
* TODO: test block formats too.
|
||||
*/
|
||||
if (format_desc->block.width != 1 && format_desc->block.height != 1) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
format_desc->fetch_float(unpacked, test->packed, 0, 0);
|
||||
|
||||
success = TRUE;
|
||||
for (i = 0; i < 4; ++i)
|
||||
|
@ -58,15 +65,44 @@ test_format_unpack_4f(const struct util_format_test_case *test)
|
|||
|
||||
|
||||
static boolean
|
||||
test_format_pack_4f(const struct util_format_test_case *test)
|
||||
test_format_unpack_float(const struct util_format_description *format_desc,
|
||||
const struct util_format_test_case *test)
|
||||
{
|
||||
float unpacked[4];
|
||||
unsigned i;
|
||||
boolean success;
|
||||
|
||||
format_desc->unpack_float(unpacked, 0, test->packed, 0, 1, 1);
|
||||
|
||||
success = TRUE;
|
||||
for (i = 0; i < 4; ++i)
|
||||
if (test->unpacked[i] != unpacked[i])
|
||||
success = FALSE;
|
||||
|
||||
if (!success) {
|
||||
printf("FAILED: (%f %f %f %f) obtained\n", unpacked[0], unpacked[1], unpacked[2], unpacked[3]);
|
||||
printf(" (%f %f %f %f) expected\n", test->unpacked[0], test->unpacked[1], test->unpacked[2], test->unpacked[3]);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
static boolean
|
||||
test_format_pack_float(const struct util_format_description *format_desc,
|
||||
const struct util_format_test_case *test)
|
||||
{
|
||||
float unpacked[4];
|
||||
uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES];
|
||||
unsigned i;
|
||||
boolean success;
|
||||
|
||||
memset(packed, 0, sizeof packed);
|
||||
|
||||
util_format_pack_4f(test->format, packed, test->unpacked[0], test->unpacked[1], test->unpacked[2], test->unpacked[3]);
|
||||
for (i = 0; i < 4; ++i)
|
||||
unpacked[i] = (float) test->unpacked[i];
|
||||
|
||||
format_desc->pack_float(packed, 0, unpacked, 0, 1, 1);
|
||||
|
||||
success = TRUE;
|
||||
for (i = 0; i < UTIL_FORMAT_MAX_PACKED_BYTES; ++i)
|
||||
|
@ -92,7 +128,7 @@ test_format_pack_4f(const struct util_format_test_case *test)
|
|||
|
||||
|
||||
static boolean
|
||||
convert_4f_to_4ub(uint8_t *dst, const double *src)
|
||||
convert_float_to_8unorm(uint8_t *dst, const double *src)
|
||||
{
|
||||
unsigned i;
|
||||
boolean accurate = TRUE;
|
||||
|
@ -116,16 +152,17 @@ convert_4f_to_4ub(uint8_t *dst, const double *src)
|
|||
|
||||
|
||||
static boolean
|
||||
test_format_unpack_4ub(const struct util_format_test_case *test)
|
||||
test_format_unpack_8unorm(const struct util_format_description *format_desc,
|
||||
const struct util_format_test_case *test)
|
||||
{
|
||||
uint8_t unpacked[4];
|
||||
uint8_t expected[4];
|
||||
unsigned i;
|
||||
boolean success;
|
||||
|
||||
util_format_unpack_4ub(test->format, unpacked, test->packed);
|
||||
format_desc->unpack_8unorm(unpacked, 0, test->packed, 0, 1, 1);
|
||||
|
||||
convert_4f_to_4ub(expected, test->unpacked);
|
||||
convert_float_to_8unorm(expected, test->unpacked);
|
||||
|
||||
success = TRUE;
|
||||
for (i = 0; i < 4; ++i)
|
||||
|
@ -142,14 +179,15 @@ test_format_unpack_4ub(const struct util_format_test_case *test)
|
|||
|
||||
|
||||
static boolean
|
||||
test_format_pack_4ub(const struct util_format_test_case *test)
|
||||
test_format_pack_8unorm(const struct util_format_description *format_desc,
|
||||
const struct util_format_test_case *test)
|
||||
{
|
||||
uint8_t unpacked[4];
|
||||
uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES];
|
||||
unsigned i;
|
||||
boolean success;
|
||||
|
||||
if (!convert_4f_to_4ub(unpacked, test->unpacked)) {
|
||||
if (!convert_float_to_8unorm(unpacked, test->unpacked)) {
|
||||
/*
|
||||
* Skip test cases which cannot be represented by four unorm bytes.
|
||||
*/
|
||||
|
@ -158,7 +196,7 @@ test_format_pack_4ub(const struct util_format_test_case *test)
|
|||
|
||||
memset(packed, 0, sizeof packed);
|
||||
|
||||
util_format_pack_4ub(test->format, packed, unpacked[0], unpacked[1], unpacked[2], unpacked[3]);
|
||||
format_desc->pack_8unorm(packed, 0, unpacked, 0, 1, 1);
|
||||
|
||||
success = TRUE;
|
||||
for (i = 0; i < UTIL_FORMAT_MAX_PACKED_BYTES; ++i)
|
||||
|
@ -184,7 +222,8 @@ test_format_pack_4ub(const struct util_format_test_case *test)
|
|||
|
||||
|
||||
typedef boolean
|
||||
(*test_func_t)(const struct util_format_test_case *test);
|
||||
(*test_func_t)(const struct util_format_description *format_desc,
|
||||
const struct util_format_test_case *test);
|
||||
|
||||
|
||||
static boolean
|
||||
|
@ -196,14 +235,15 @@ test_one(test_func_t func, const char *suffix)
|
|||
|
||||
for (i = 0; i < util_format_nr_test_cases; ++i) {
|
||||
const struct util_format_test_case *test = &util_format_test_cases[i];
|
||||
const struct util_format_description *format_desc;
|
||||
format_desc = util_format_description(test->format);
|
||||
|
||||
if (test->format != last_format) {
|
||||
const struct util_format_description *format_desc;
|
||||
format_desc = util_format_description(test->format);
|
||||
printf("Testing util_format_%s_%s ...\n", format_desc->short_name, suffix);
|
||||
last_format = test->format;
|
||||
}
|
||||
|
||||
if (!func(&util_format_test_cases[i]))
|
||||
if (!func(format_desc, &util_format_test_cases[i]))
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
|
@ -216,16 +256,19 @@ test_all(void)
|
|||
{
|
||||
bool success = TRUE;
|
||||
|
||||
if (!test_one(&test_format_pack_4f, "pack_4f"))
|
||||
if (!test_one(&test_format_fetch_float, "fetch_float"))
|
||||
success = FALSE;
|
||||
|
||||
if (!test_one(&test_format_unpack_4f, "unpack_4f"))
|
||||
if (!test_one(&test_format_pack_float, "pack_float"))
|
||||
success = FALSE;
|
||||
|
||||
if (!test_one(&test_format_pack_4ub, "pack_4ub"))
|
||||
if (!test_one(&test_format_unpack_float, "unpack_float"))
|
||||
success = FALSE;
|
||||
|
||||
if (!test_one(&test_format_unpack_4ub, "unpack_4ub"))
|
||||
if (!test_one(&test_format_pack_8unorm, "pack_8unorm"))
|
||||
success = FALSE;
|
||||
|
||||
if (!test_one(&test_format_unpack_8unorm, "unpack_8unorm"))
|
||||
success = FALSE;
|
||||
|
||||
return success;
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
"""x11
|
||||
|
||||
Tool-specific initialization for X11
|
||||
|
||||
"""
|
||||
|
||||
#
|
||||
# Copyright (c) 2010 VMware, Inc.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
||||
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
||||
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 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.
|
||||
#
|
||||
|
||||
|
||||
def generate(env):
|
||||
env.Append(CPPPATH = ['/usr/X11R6/include'])
|
||||
env.Append(LIBPATH = ['/usr/X11R6/lib'])
|
||||
|
||||
env.Append(LIBS = [
|
||||
'X11',
|
||||
'Xext',
|
||||
'Xxf86vm',
|
||||
'Xdamage',
|
||||
'Xfixes',
|
||||
])
|
||||
|
||||
|
||||
def exists(env):
|
||||
# TODO: actually detect the presence of the headers
|
||||
if env['platform'] in ('linux', 'freebsd', 'darwin'):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
# vim:set ts=4 sw=4 et:
|
|
@ -105,7 +105,8 @@ C_SOURCES = \
|
|||
util/u_cpu_detect.c \
|
||||
util/u_dl.c \
|
||||
util/u_draw_quad.c \
|
||||
util/u_format_access.c \
|
||||
util/u_format.c \
|
||||
util/u_format_s3tc.c \
|
||||
util/u_format_table.c \
|
||||
util/u_format_tests.c \
|
||||
util/u_gen_mipmap.c \
|
||||
|
@ -148,8 +149,6 @@ GALLIVM_SOURCES = \
|
|||
gallivm/lp_bld_debug.c \
|
||||
gallivm/lp_bld_depth.c \
|
||||
gallivm/lp_bld_flow.c \
|
||||
gallivm/lp_bld_format_aos.c \
|
||||
gallivm/lp_bld_format_query.c \
|
||||
gallivm/lp_bld_format_soa.c \
|
||||
gallivm/lp_bld_interp.c \
|
||||
gallivm/lp_bld_intr.c \
|
||||
|
@ -169,8 +168,6 @@ GALLIVM_CPP_SOURCES = \
|
|||
GENERATED_SOURCES = \
|
||||
indices/u_indices_gen.c \
|
||||
indices/u_unfilled_gen.c \
|
||||
util/u_format_access.c \
|
||||
util/u_format_pack.h \
|
||||
util/u_format_table.c
|
||||
|
||||
|
||||
|
@ -194,12 +191,9 @@ indices/u_indices_gen.c: indices/u_indices_gen.py
|
|||
indices/u_unfilled_gen.c: indices/u_unfilled_gen.py
|
||||
python $< > $@
|
||||
|
||||
util/u_format_table.c: util/u_format_table.py util/u_format_parse.py util/u_format.csv
|
||||
util/u_format_table.c: util/u_format_table.py util/u_format_pack.py util/u_format_parse.py util/u_format.csv
|
||||
python util/u_format_table.py util/u_format.csv > $@
|
||||
|
||||
util/u_format_pack.h: util/u_format_pack.py util/u_format_parse.py util/u_format.csv
|
||||
python util/u_format_pack.py util/u_format.csv > $@
|
||||
|
||||
util/u_format_access.c: util/u_format_access.py util/u_format_parse.py util/u_format.csv
|
||||
python util/u_format_access.py util/u_format.csv > $@
|
||||
|
||||
|
|
|
@ -29,20 +29,10 @@ env.CodeGenerate(
|
|||
source = ['util/u_format.csv'],
|
||||
command = 'python $SCRIPT $SOURCE > $TARGET'
|
||||
)
|
||||
|
||||
env.CodeGenerate(
|
||||
target = File('util/u_format_pack.h').srcnode(),
|
||||
script = 'util/u_format_pack.py',
|
||||
source = ['util/u_format.csv'],
|
||||
command = 'python $SCRIPT $SOURCE > $TARGET'
|
||||
)
|
||||
|
||||
env.CodeGenerate(
|
||||
target = 'util/u_format_access.c',
|
||||
script = 'util/u_format_access.py',
|
||||
source = ['util/u_format.csv'],
|
||||
command = 'python $SCRIPT $SOURCE > $TARGET'
|
||||
)
|
||||
env.Depends('util/u_format_table.c', [
|
||||
'util/u_format_parse.py',
|
||||
'util/u_format_pack.py',
|
||||
])
|
||||
|
||||
source = [
|
||||
'cso_cache/cso_context.c',
|
||||
|
@ -149,7 +139,8 @@ source = [
|
|||
'util/u_dump_state.c',
|
||||
'util/u_dl.c',
|
||||
'util/u_draw_quad.c',
|
||||
'util/u_format_access.c',
|
||||
'util/u_format.c',
|
||||
'util/u_format_s3tc.c',
|
||||
'util/u_format_table.c',
|
||||
'util/u_format_tests.c',
|
||||
'util/u_gen_mipmap.c',
|
||||
|
@ -192,8 +183,6 @@ if drawllvm:
|
|||
'gallivm/lp_bld_debug.c',
|
||||
'gallivm/lp_bld_depth.c',
|
||||
'gallivm/lp_bld_flow.c',
|
||||
'gallivm/lp_bld_format_aos.c',
|
||||
'gallivm/lp_bld_format_query.c',
|
||||
'gallivm/lp_bld_format_soa.c',
|
||||
'gallivm/lp_bld_interp.c',
|
||||
'gallivm/lp_bld_intr.c',
|
||||
|
|
|
@ -495,8 +495,8 @@ lp_build_depth_stencil_test(LLVMBuilderRef builder,
|
|||
assert(format_desc->block.height == 1);
|
||||
|
||||
if (stencil[0].enabled) {
|
||||
assert(format_desc->format == PIPE_FORMAT_Z24S8_UNORM ||
|
||||
format_desc->format == PIPE_FORMAT_S8Z24_UNORM);
|
||||
assert(format_desc->format == PIPE_FORMAT_Z24_UNORM_S8_USCALED ||
|
||||
format_desc->format == PIPE_FORMAT_S8_USCALED_Z24_UNORM);
|
||||
}
|
||||
|
||||
assert(z_swizzle < 4);
|
||||
|
|
|
@ -1,383 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2009 VMware, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER 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
|
||||
* AoS pixel format manipulation.
|
||||
*
|
||||
* @author Jose Fonseca <jfonseca@vmware.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "util/u_cpu_detect.h"
|
||||
#include "util/u_format.h"
|
||||
|
||||
#include "lp_bld_type.h"
|
||||
#include "lp_bld_const.h"
|
||||
#include "lp_bld_swizzle.h"
|
||||
#include "lp_bld_format.h"
|
||||
|
||||
|
||||
/**
|
||||
* Unpack a single pixel into its RGBA components.
|
||||
*
|
||||
* @param packed integer.
|
||||
*
|
||||
* @return RGBA in a 4 floats vector.
|
||||
*
|
||||
* XXX: This is mostly for reference and testing -- operating a single pixel at
|
||||
* a time is rarely if ever needed.
|
||||
*/
|
||||
LLVMValueRef
|
||||
lp_build_unpack_rgba_aos(LLVMBuilderRef builder,
|
||||
const struct util_format_description *desc,
|
||||
LLVMValueRef packed)
|
||||
{
|
||||
LLVMTypeRef type;
|
||||
LLVMValueRef shifted, casted, scaled, masked;
|
||||
LLVMValueRef shifts[4];
|
||||
LLVMValueRef masks[4];
|
||||
LLVMValueRef scales[4];
|
||||
LLVMValueRef swizzles[4];
|
||||
LLVMValueRef aux[4];
|
||||
bool normalized;
|
||||
int empty_channel;
|
||||
unsigned shift;
|
||||
unsigned i;
|
||||
|
||||
/* FIXME: Support more formats */
|
||||
assert(desc->layout == UTIL_FORMAT_LAYOUT_PLAIN);
|
||||
assert(desc->block.width == 1);
|
||||
assert(desc->block.height == 1);
|
||||
assert(desc->block.bits <= 32);
|
||||
|
||||
type = LLVMIntType(desc->block.bits);
|
||||
|
||||
/* Do the intermediate integer computations with 32bit integers since it
|
||||
* matches floating point size */
|
||||
if (desc->block.bits < 32)
|
||||
packed = LLVMBuildZExt(builder, packed, LLVMInt32Type(), "");
|
||||
|
||||
/* Broadcast the packed value to all four channels */
|
||||
packed = LLVMBuildInsertElement(builder,
|
||||
LLVMGetUndef(LLVMVectorType(LLVMInt32Type(), 4)),
|
||||
packed,
|
||||
LLVMConstNull(LLVMInt32Type()),
|
||||
"");
|
||||
packed = LLVMBuildShuffleVector(builder,
|
||||
packed,
|
||||
LLVMGetUndef(LLVMVectorType(LLVMInt32Type(), 4)),
|
||||
LLVMConstNull(LLVMVectorType(LLVMInt32Type(), 4)),
|
||||
"");
|
||||
|
||||
/* Initialize vector constants */
|
||||
normalized = FALSE;
|
||||
empty_channel = -1;
|
||||
shift = 0;
|
||||
for (i = 0; i < 4; ++i) {
|
||||
unsigned bits = desc->channel[i].size;
|
||||
|
||||
if (desc->channel[i].type == UTIL_FORMAT_TYPE_VOID) {
|
||||
shifts[i] = LLVMGetUndef(LLVMInt32Type());
|
||||
masks[i] = LLVMConstNull(LLVMInt32Type());
|
||||
scales[i] = LLVMConstNull(LLVMFloatType());
|
||||
empty_channel = i;
|
||||
}
|
||||
else {
|
||||
unsigned mask = (1 << bits) - 1;
|
||||
|
||||
assert(desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED);
|
||||
assert(bits < 32);
|
||||
|
||||
shifts[i] = LLVMConstInt(LLVMInt32Type(), shift, 0);
|
||||
masks[i] = LLVMConstInt(LLVMInt32Type(), mask, 0);
|
||||
|
||||
if (desc->channel[i].normalized) {
|
||||
scales[i] = LLVMConstReal(LLVMFloatType(), 1.0/mask);
|
||||
normalized = TRUE;
|
||||
}
|
||||
else
|
||||
scales[i] = LLVMConstReal(LLVMFloatType(), 1.0);
|
||||
}
|
||||
|
||||
shift += bits;
|
||||
}
|
||||
|
||||
shifted = LLVMBuildLShr(builder, packed, LLVMConstVector(shifts, 4), "");
|
||||
masked = LLVMBuildAnd(builder, shifted, LLVMConstVector(masks, 4), "");
|
||||
/* UIToFP can't be expressed in SSE2 */
|
||||
casted = LLVMBuildSIToFP(builder, masked, LLVMVectorType(LLVMFloatType(), 4), "");
|
||||
|
||||
if (normalized)
|
||||
scaled = LLVMBuildMul(builder, casted, LLVMConstVector(scales, 4), "");
|
||||
else
|
||||
scaled = casted;
|
||||
|
||||
for (i = 0; i < 4; ++i)
|
||||
aux[i] = LLVMGetUndef(LLVMFloatType());
|
||||
|
||||
for (i = 0; i < 4; ++i) {
|
||||
enum util_format_swizzle swizzle = desc->swizzle[i];
|
||||
|
||||
switch (swizzle) {
|
||||
case UTIL_FORMAT_SWIZZLE_X:
|
||||
case UTIL_FORMAT_SWIZZLE_Y:
|
||||
case UTIL_FORMAT_SWIZZLE_Z:
|
||||
case UTIL_FORMAT_SWIZZLE_W:
|
||||
swizzles[i] = LLVMConstInt(LLVMInt32Type(), swizzle, 0);
|
||||
break;
|
||||
case UTIL_FORMAT_SWIZZLE_0:
|
||||
assert(empty_channel >= 0);
|
||||
swizzles[i] = LLVMConstInt(LLVMInt32Type(), empty_channel, 0);
|
||||
break;
|
||||
case UTIL_FORMAT_SWIZZLE_1:
|
||||
swizzles[i] = LLVMConstInt(LLVMInt32Type(), 4, 0);
|
||||
aux[0] = LLVMConstReal(LLVMFloatType(), 1.0);
|
||||
break;
|
||||
case UTIL_FORMAT_SWIZZLE_NONE:
|
||||
swizzles[i] = LLVMGetUndef(LLVMFloatType());
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return LLVMBuildShuffleVector(builder, scaled, LLVMConstVector(aux, 4), LLVMConstVector(swizzles, 4), "");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Take a vector with packed pixels and unpack into a rgba8 vector.
|
||||
*
|
||||
* Formats with bit depth smaller than 32bits are accepted, but they must be
|
||||
* padded to 32bits.
|
||||
*/
|
||||
LLVMValueRef
|
||||
lp_build_unpack_rgba8_aos(LLVMBuilderRef builder,
|
||||
const struct util_format_description *desc,
|
||||
struct lp_type type,
|
||||
LLVMValueRef packed)
|
||||
{
|
||||
struct lp_build_context bld;
|
||||
bool rgba8;
|
||||
LLVMValueRef res;
|
||||
unsigned i;
|
||||
|
||||
lp_build_context_init(&bld, builder, type);
|
||||
|
||||
/* FIXME: Support more formats */
|
||||
assert(desc->layout == UTIL_FORMAT_LAYOUT_PLAIN);
|
||||
assert(desc->block.width == 1);
|
||||
assert(desc->block.height == 1);
|
||||
assert(desc->block.bits <= 32);
|
||||
|
||||
assert(!type.floating);
|
||||
assert(!type.fixed);
|
||||
assert(type.norm);
|
||||
assert(type.width == 8);
|
||||
assert(type.length % 4 == 0);
|
||||
|
||||
rgba8 = TRUE;
|
||||
for(i = 0; i < 4; ++i) {
|
||||
assert(desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED ||
|
||||
desc->channel[i].type == UTIL_FORMAT_TYPE_VOID);
|
||||
if(desc->channel[0].size != 8)
|
||||
rgba8 = FALSE;
|
||||
}
|
||||
|
||||
if(rgba8) {
|
||||
/*
|
||||
* The pixel is already in a rgba8 format variant. All it is necessary
|
||||
* is to swizzle the channels.
|
||||
*/
|
||||
|
||||
unsigned char swizzles[4];
|
||||
boolean zeros[4]; /* bitwise AND mask */
|
||||
boolean ones[4]; /* bitwise OR mask */
|
||||
boolean swizzles_needed = FALSE;
|
||||
boolean zeros_needed = FALSE;
|
||||
boolean ones_needed = FALSE;
|
||||
|
||||
for(i = 0; i < 4; ++i) {
|
||||
enum util_format_swizzle swizzle = desc->swizzle[i];
|
||||
|
||||
/* Initialize with the no-op case */
|
||||
swizzles[i] = util_cpu_caps.little_endian ? 3 - i : i;
|
||||
zeros[i] = TRUE;
|
||||
ones[i] = FALSE;
|
||||
|
||||
switch (swizzle) {
|
||||
case UTIL_FORMAT_SWIZZLE_X:
|
||||
case UTIL_FORMAT_SWIZZLE_Y:
|
||||
case UTIL_FORMAT_SWIZZLE_Z:
|
||||
case UTIL_FORMAT_SWIZZLE_W:
|
||||
if(swizzle != swizzles[i]) {
|
||||
swizzles[i] = swizzle;
|
||||
swizzles_needed = TRUE;
|
||||
}
|
||||
break;
|
||||
case UTIL_FORMAT_SWIZZLE_0:
|
||||
zeros[i] = FALSE;
|
||||
zeros_needed = TRUE;
|
||||
break;
|
||||
case UTIL_FORMAT_SWIZZLE_1:
|
||||
ones[i] = TRUE;
|
||||
ones_needed = TRUE;
|
||||
break;
|
||||
case UTIL_FORMAT_SWIZZLE_NONE:
|
||||
assert(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
res = packed;
|
||||
|
||||
if(swizzles_needed)
|
||||
res = lp_build_swizzle1_aos(&bld, res, swizzles);
|
||||
|
||||
if(zeros_needed) {
|
||||
/* Mask out zero channels */
|
||||
LLVMValueRef mask = lp_build_const_mask_aos(type, zeros);
|
||||
res = LLVMBuildAnd(builder, res, mask, "");
|
||||
}
|
||||
|
||||
if(ones_needed) {
|
||||
/* Or one channels */
|
||||
LLVMValueRef mask = lp_build_const_mask_aos(type, ones);
|
||||
res = LLVMBuildOr(builder, res, mask, "");
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* FIXME */
|
||||
assert(0);
|
||||
res = lp_build_undef(type);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pack a single pixel.
|
||||
*
|
||||
* @param rgba 4 float vector with the unpacked components.
|
||||
*
|
||||
* XXX: This is mostly for reference and testing -- operating a single pixel at
|
||||
* a time is rarely if ever needed.
|
||||
*/
|
||||
LLVMValueRef
|
||||
lp_build_pack_rgba_aos(LLVMBuilderRef builder,
|
||||
const struct util_format_description *desc,
|
||||
LLVMValueRef rgba)
|
||||
{
|
||||
LLVMTypeRef type;
|
||||
LLVMValueRef packed = NULL;
|
||||
LLVMValueRef swizzles[4];
|
||||
LLVMValueRef shifted, casted, scaled, unswizzled;
|
||||
LLVMValueRef shifts[4];
|
||||
LLVMValueRef scales[4];
|
||||
bool normalized;
|
||||
unsigned shift;
|
||||
unsigned i, j;
|
||||
|
||||
assert(desc->layout == UTIL_FORMAT_LAYOUT_PLAIN);
|
||||
assert(desc->block.width == 1);
|
||||
assert(desc->block.height == 1);
|
||||
|
||||
type = LLVMIntType(desc->block.bits);
|
||||
|
||||
/* Unswizzle the color components into the source vector. */
|
||||
for (i = 0; i < 4; ++i) {
|
||||
for (j = 0; j < 4; ++j) {
|
||||
if (desc->swizzle[j] == i)
|
||||
break;
|
||||
}
|
||||
if (j < 4)
|
||||
swizzles[i] = LLVMConstInt(LLVMInt32Type(), j, 0);
|
||||
else
|
||||
swizzles[i] = LLVMGetUndef(LLVMInt32Type());
|
||||
}
|
||||
|
||||
unswizzled = LLVMBuildShuffleVector(builder, rgba,
|
||||
LLVMGetUndef(LLVMVectorType(LLVMFloatType(), 4)),
|
||||
LLVMConstVector(swizzles, 4), "");
|
||||
|
||||
normalized = FALSE;
|
||||
shift = 0;
|
||||
for (i = 0; i < 4; ++i) {
|
||||
unsigned bits = desc->channel[i].size;
|
||||
|
||||
if (desc->channel[i].type == UTIL_FORMAT_TYPE_VOID) {
|
||||
shifts[i] = LLVMGetUndef(LLVMInt32Type());
|
||||
scales[i] = LLVMGetUndef(LLVMFloatType());
|
||||
}
|
||||
else {
|
||||
unsigned mask = (1 << bits) - 1;
|
||||
|
||||
assert(desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED);
|
||||
assert(bits < 32);
|
||||
|
||||
shifts[i] = LLVMConstInt(LLVMInt32Type(), shift, 0);
|
||||
|
||||
if (desc->channel[i].normalized) {
|
||||
scales[i] = LLVMConstReal(LLVMFloatType(), mask);
|
||||
normalized = TRUE;
|
||||
}
|
||||
else
|
||||
scales[i] = LLVMConstReal(LLVMFloatType(), 1.0);
|
||||
}
|
||||
|
||||
shift += bits;
|
||||
}
|
||||
|
||||
if (normalized)
|
||||
scaled = LLVMBuildMul(builder, unswizzled, LLVMConstVector(scales, 4), "");
|
||||
else
|
||||
scaled = unswizzled;
|
||||
|
||||
casted = LLVMBuildFPToSI(builder, scaled, LLVMVectorType(LLVMInt32Type(), 4), "");
|
||||
|
||||
shifted = LLVMBuildShl(builder, casted, LLVMConstVector(shifts, 4), "");
|
||||
|
||||
/* Bitwise or all components */
|
||||
for (i = 0; i < 4; ++i) {
|
||||
if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED) {
|
||||
LLVMValueRef component = LLVMBuildExtractElement(builder, shifted, LLVMConstInt(LLVMInt32Type(), i, 0), "");
|
||||
if (packed)
|
||||
packed = LLVMBuildOr(builder, packed, component, "");
|
||||
else
|
||||
packed = component;
|
||||
}
|
||||
}
|
||||
|
||||
if (!packed)
|
||||
packed = LLVMGetUndef(LLVMInt32Type());
|
||||
|
||||
if (desc->block.bits < 32)
|
||||
packed = LLVMBuildTrunc(builder, packed, type, "");
|
||||
|
||||
return packed;
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2009 VMware, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER 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
|
||||
* Utility functions to make assertions about formats.
|
||||
*
|
||||
* This module centralizes most of logic used when determining what algorithm
|
||||
* is most suitable (i.e., most efficient yet correct) for a given format.
|
||||
*
|
||||
* It might be possible to move some of these functions to u_format module,
|
||||
* but since tiny differences in the format my render it more/less
|
||||
* appropriate to a given algorithm it is impossible to make any long term
|
||||
* guarantee about the semantics of these functions.
|
||||
*
|
||||
* @author Jose Fonseca <jfonseca@vmware.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "util/u_format.h"
|
||||
|
||||
#include "lp_bld_format.h"
|
||||
|
||||
|
||||
/**
|
||||
* Whether this format is a 4 rgba8 variant
|
||||
*/
|
||||
boolean
|
||||
lp_format_is_rgba8(const struct util_format_description *desc)
|
||||
{
|
||||
unsigned chan;
|
||||
|
||||
if(desc->block.width != 1 ||
|
||||
desc->block.height != 1 ||
|
||||
desc->block.bits != 32)
|
||||
return FALSE;
|
||||
|
||||
for(chan = 0; chan < 4; ++chan) {
|
||||
if(desc->channel[chan].type != UTIL_FORMAT_TYPE_UNSIGNED &&
|
||||
desc->channel[chan].type != UTIL_FORMAT_TYPE_SIGNED &&
|
||||
desc->channel[chan].type != UTIL_FORMAT_TYPE_VOID)
|
||||
return FALSE;
|
||||
if(desc->channel[chan].size != 8)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
|
@ -92,14 +92,14 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
|
|||
unsigned chan;
|
||||
|
||||
/* FIXME: Support more formats */
|
||||
assert(format_desc->layout == UTIL_FORMAT_LAYOUT_PLAIN);
|
||||
assert(format_desc->is_bitmask);
|
||||
assert(format_desc->block.width == 1);
|
||||
assert(format_desc->block.height == 1);
|
||||
assert(format_desc->block.bits <= 32);
|
||||
|
||||
/* Decode the input vector components */
|
||||
start = 0;
|
||||
for (chan = 0; chan < 4; ++chan) {
|
||||
for (chan = 0; chan < format_desc->nr_channels; ++chan) {
|
||||
unsigned width = format_desc->channel[chan].size;
|
||||
unsigned stop = start + width;
|
||||
LLVMValueRef input;
|
||||
|
@ -123,7 +123,7 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder,
|
|||
if(format_desc->channel[chan].normalized)
|
||||
input = lp_build_unsigned_norm_to_float(builder, width, type, input);
|
||||
else
|
||||
input = LLVMBuildFPToSI(builder, input, lp_build_vec_type(type), "");
|
||||
input = LLVMBuildSIToFP(builder, input, lp_build_vec_type(type), "");
|
||||
}
|
||||
else {
|
||||
/* FIXME */
|
||||
|
|
|
@ -104,8 +104,15 @@ lp_build_printf(LLVMBuilderRef builder, const char *fmt, ...)
|
|||
params[0] = LLVMBuildGEP(builder, fmtarg, index, 2, "");
|
||||
|
||||
va_start(arglist, fmt);
|
||||
for (i = 1; i <= argcount; i++)
|
||||
params[i] = va_arg(arglist, LLVMValueRef);
|
||||
for (i = 1; i <= argcount; i++) {
|
||||
LLVMValueRef val = va_arg(arglist, LLVMValueRef);
|
||||
LLVMTypeRef type = LLVMTypeOf(val);
|
||||
/* printf wants doubles, so lets convert so that
|
||||
* we can actually print them */
|
||||
if (LLVMGetTypeKind(type) == LLVMFloatTypeKind)
|
||||
val = LLVMBuildFPExt(builder, val, LLVMDoubleType(), "");
|
||||
params[i] = val;
|
||||
}
|
||||
va_end(arglist);
|
||||
|
||||
return LLVMBuildCall(builder, func_printf, params, argcount + 1, "");
|
||||
|
|
|
@ -2037,7 +2037,7 @@ lp_build_sample_soa(LLVMBuilderRef builder,
|
|||
height_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, height);
|
||||
depth_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, depth);
|
||||
|
||||
if (lp_format_is_rgba8(bld.format_desc) &&
|
||||
if (util_format_is_rgba8_variant(bld.format_desc) &&
|
||||
static_state->target == PIPE_TEXTURE_2D &&
|
||||
static_state->min_img_filter == PIPE_TEX_FILTER_LINEAR &&
|
||||
static_state->mag_img_filter == PIPE_TEX_FILTER_LINEAR &&
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#include "util/u_debug.h" /* for assert */
|
||||
|
||||
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED)
|
||||
|
||||
#include <pthread.h> /* POSIX threads headers */
|
||||
#include <stdio.h> /* for perror() */
|
||||
|
@ -257,7 +257,7 @@ typedef unsigned pipe_condvar;
|
|||
* pipe_barrier
|
||||
*/
|
||||
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU)
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED)
|
||||
|
||||
typedef pthread_barrier_t pipe_barrier;
|
||||
|
||||
|
@ -377,7 +377,7 @@ pipe_semaphore_wait(pipe_semaphore *sema)
|
|||
*/
|
||||
|
||||
typedef struct {
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED)
|
||||
pthread_key_t key;
|
||||
#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
|
||||
DWORD key;
|
||||
|
@ -392,7 +392,7 @@ typedef struct {
|
|||
static INLINE void
|
||||
pipe_tsd_init(pipe_tsd *tsd)
|
||||
{
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED)
|
||||
if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) {
|
||||
perror("pthread_key_create(): failed to allocate key for thread specific data");
|
||||
exit(-1);
|
||||
|
@ -409,7 +409,7 @@ pipe_tsd_get(pipe_tsd *tsd)
|
|||
if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) {
|
||||
pipe_tsd_init(tsd);
|
||||
}
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED)
|
||||
return pthread_getspecific(tsd->key);
|
||||
#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
|
||||
assert(0);
|
||||
|
@ -426,7 +426,7 @@ pipe_tsd_set(pipe_tsd *tsd, void *value)
|
|||
if (tsd->initMagic != (int) PIPE_TSD_INIT_MAGIC) {
|
||||
pipe_tsd_init(tsd);
|
||||
}
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU)
|
||||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) || defined(PIPE_OS_HAIKU) || defined(PIPE_OS_EMBEDDED)
|
||||
if (pthread_setspecific(tsd->key, value) != 0) {
|
||||
perror("pthread_set_specific() failed");
|
||||
exit(-1);
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
u_format_access.c
|
||||
u_format_table.c
|
||||
u_format_pack.h
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2010 VMware, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER 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
|
||||
* Pixel format accessor functions.
|
||||
*
|
||||
* @author Jose Fonseca <jfonseca@vmware.com>
|
||||
*/
|
||||
|
||||
#include "u_format.h"
|
||||
|
||||
|
||||
void
|
||||
util_format_read_4f(enum pipe_format format,
|
||||
float *dst, unsigned dst_stride,
|
||||
const void *src, unsigned src_stride,
|
||||
unsigned x, unsigned y, unsigned w, unsigned h)
|
||||
{
|
||||
const struct util_format_description *format_desc;
|
||||
const uint8_t *src_row;
|
||||
float *dst_row;
|
||||
|
||||
format_desc = util_format_description(format);
|
||||
|
||||
assert(x % format_desc->block.width == 0);
|
||||
assert(y % format_desc->block.height == 0);
|
||||
|
||||
src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8);
|
||||
dst_row = dst;
|
||||
|
||||
format_desc->unpack_float(dst_row, dst_stride, src_row, src_stride, w, h);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
util_format_write_4f(enum pipe_format format,
|
||||
const float *src, unsigned src_stride,
|
||||
void *dst, unsigned dst_stride,
|
||||
unsigned x, unsigned y, unsigned w, unsigned h)
|
||||
{
|
||||
const struct util_format_description *format_desc;
|
||||
uint8_t *dst_row;
|
||||
const float *src_row;
|
||||
|
||||
format_desc = util_format_description(format);
|
||||
|
||||
assert(x % format_desc->block.width == 0);
|
||||
assert(y % format_desc->block.height == 0);
|
||||
|
||||
dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8);
|
||||
src_row = src;
|
||||
|
||||
format_desc->pack_float(dst_row, dst_stride, src_row, src_stride, w, h);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
util_format_read_4ub(enum pipe_format format, uint8_t *dst, unsigned dst_stride, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)
|
||||
{
|
||||
const struct util_format_description *format_desc;
|
||||
const uint8_t *src_row;
|
||||
uint8_t *dst_row;
|
||||
|
||||
format_desc = util_format_description(format);
|
||||
|
||||
assert(x % format_desc->block.width == 0);
|
||||
assert(y % format_desc->block.height == 0);
|
||||
|
||||
src_row = (const uint8_t *)src + y*src_stride + x*(format_desc->block.bits/8);
|
||||
dst_row = dst;
|
||||
|
||||
format_desc->unpack_8unorm(dst_row, dst_stride, src_row, src_stride, w, h);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
util_format_write_4ub(enum pipe_format format, const uint8_t *src, unsigned src_stride, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)
|
||||
{
|
||||
const struct util_format_description *format_desc;
|
||||
uint8_t *dst_row;
|
||||
const uint8_t *src_row;
|
||||
|
||||
format_desc = util_format_description(format);
|
||||
|
||||
assert(x % format_desc->block.width == 0);
|
||||
assert(y % format_desc->block.height == 0);
|
||||
|
||||
dst_row = (uint8_t *)dst + y*dst_stride + x*(format_desc->block.bits/8);
|
||||
src_row = src;
|
||||
|
||||
format_desc->pack_8unorm(dst_row, dst_stride, src_row, src_stride, w, h);
|
||||
}
|
||||
|
|
@ -56,14 +56,18 @@
|
|||
# internal formats to base in- ternal formats, and desired component
|
||||
# resolutions for each sized internal format."
|
||||
|
||||
# None
|
||||
# Described as regular uint_8 bytes, i.e. PIPE_FORMAT_R8_USCALED
|
||||
PIPE_FORMAT_NONE , plain, 1, 1, u8 , , , , x001, rgb
|
||||
|
||||
# Typical rendertarget formats
|
||||
PIPE_FORMAT_B8G8R8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, rgb
|
||||
PIPE_FORMAT_B8G8R8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyx1, rgb
|
||||
PIPE_FORMAT_B8G8R8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , x8 , zyx1, rgb
|
||||
PIPE_FORMAT_A8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, rgb
|
||||
PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, rgb
|
||||
PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, x8 , un8 , un8 , un8 , yzw1, rgb
|
||||
PIPE_FORMAT_A8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb
|
||||
PIPE_FORMAT_X8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb
|
||||
PIPE_FORMAT_B5G5R5X1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyx1, rgb
|
||||
PIPE_FORMAT_X8B8G8R8_UNORM , plain, 1, 1, x8 , un8 , un8 , un8 , wzy1, rgb
|
||||
PIPE_FORMAT_B5G5R5X1_UNORM , plain, 1, 1, un5 , un5 , un5 , x1 , zyx1, rgb
|
||||
PIPE_FORMAT_B5G5R5A1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb
|
||||
PIPE_FORMAT_B4G4R4A4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb
|
||||
PIPE_FORMAT_B5G6R5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb
|
||||
|
@ -80,26 +84,28 @@ PIPE_FORMAT_L16_UNORM , plain, 1, 1, un16, , , , xxx1, r
|
|||
PIPE_FORMAT_L8_SRGB , plain, 1, 1, un8 , , , , xxx1, srgb
|
||||
PIPE_FORMAT_L8A8_SRGB , plain, 1, 1, un8 , un8 , , , xxxy, srgb
|
||||
PIPE_FORMAT_R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , , xyz1, srgb
|
||||
PIPE_FORMAT_R8G8B8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , xyzw, srgb
|
||||
PIPE_FORMAT_A8B8G8R8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, srgb
|
||||
PIPE_FORMAT_X8B8G8R8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, srgb
|
||||
PIPE_FORMAT_X8B8G8R8_SRGB , plain, 1, 1, x8 , un8 , un8 , un8 , wzy1, srgb
|
||||
PIPE_FORMAT_B8G8R8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, srgb
|
||||
PIPE_FORMAT_B8G8R8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyx1, srgb
|
||||
PIPE_FORMAT_B8G8R8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , x8 , zyx1, srgb
|
||||
PIPE_FORMAT_A8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, srgb
|
||||
PIPE_FORMAT_X8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, srgb
|
||||
PIPE_FORMAT_X8R8G8B8_SRGB , plain, 1, 1, x8 , un8 , un8 , un8 , yzw1, srgb
|
||||
|
||||
# Mixed-sign formats (typically used for bump map textures)
|
||||
PIPE_FORMAT_R8SG8SB8UX8U_NORM , plain, 1, 1, sn8 , sn8 , un8 , x8 , xyz1, rgb
|
||||
PIPE_FORMAT_R5SG5SB6U_NORM , plain, 1, 1, sn5 , sn5 , un6 , , xyz1, rgb
|
||||
|
||||
# Depth-stencil formats
|
||||
PIPE_FORMAT_S8_UNORM , plain, 1, 1, un8 , , , , _x__, zs
|
||||
PIPE_FORMAT_Z16_UNORM , plain, 1, 1, un16, , , , x___, zs
|
||||
PIPE_FORMAT_Z32_UNORM , plain, 1, 1, un32, , , , x___, zs
|
||||
PIPE_FORMAT_Z32_FLOAT , plain, 1, 1, f32 , , , , x___, zs
|
||||
PIPE_FORMAT_Z24S8_UNORM , plain, 1, 1, un24, un8 , , , xy__, zs
|
||||
PIPE_FORMAT_S8Z24_UNORM , plain, 1, 1, un8 , un24, , , yx__, zs
|
||||
PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un24, un8 , , , x___, zs
|
||||
PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, un8 , un24, , , y___, zs
|
||||
PIPE_FORMAT_S8_USCALED , plain, 1, 1, u8 , , , , _x__, zs
|
||||
PIPE_FORMAT_Z16_UNORM , plain, 1, 1, un16, , , , x___, zs
|
||||
PIPE_FORMAT_Z32_UNORM , plain, 1, 1, un32, , , , x___, zs
|
||||
PIPE_FORMAT_Z32_FLOAT , plain, 1, 1, f32 , , , , x___, zs
|
||||
PIPE_FORMAT_Z24_UNORM_S8_USCALED , plain, 1, 1, un24, u8 , , , xy__, zs
|
||||
PIPE_FORMAT_S8_USCALED_Z24_UNORM , plain, 1, 1, u8 , un24, , , yx__, zs
|
||||
PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un24, x8 , , , x___, zs
|
||||
PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, x8 , un24, , , y___, zs
|
||||
PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED , plain, 1, 1, f32, u8 , x24 , , xy__, zs
|
||||
|
||||
# YUV formats
|
||||
# http://www.fourcc.org/yuv.php#UYVY
|
||||
|
@ -108,6 +114,15 @@ PIPE_FORMAT_UYVY , subsampled, 2, 1, x32 , , , , xyz
|
|||
# XXX: u_tile.c's ycbcr_get_tile_rgba actually interprets it as VYUY but the
|
||||
# intent should be to match D3DFMT_YUY2
|
||||
PIPE_FORMAT_YUYV , subsampled, 2, 1, x32 , , , , xyz1, yuv
|
||||
# same subsampling but with rgb channels
|
||||
PIPE_FORMAT_R8G8_B8G8_UNORM , subsampled, 2, 1, x32 , , , , xyz1, rgb
|
||||
PIPE_FORMAT_G8R8_G8B8_UNORM , subsampled, 2, 1, x32 , , , , xyz1, rgb
|
||||
|
||||
# some special formats not fitting anywhere else
|
||||
PIPE_FORMAT_R10G10B10A2_USCALED , plain, 1, 1, u10 , u10 , u10 , u2 , xyzw, rgb
|
||||
PIPE_FORMAT_R11G11B10_FLOAT , plain, 1, 1, f11 , f11 , f10 , , xyz1, rgb
|
||||
PIPE_FORMAT_R9G9B9E5_FLOAT , other, 1, 1, x32 , , , , xyz1, rgb
|
||||
PIPE_FORMAT_R1_UNORM , other, 8, 1, x8 , , , , x001, rgb
|
||||
|
||||
# Compressed formats
|
||||
# - http://en.wikipedia.org/wiki/S3_Texture_Compression
|
||||
|
@ -123,6 +138,11 @@ PIPE_FORMAT_DXT1_SRGBA , s3tc, 4, 4, x64 , , , , xyzw, sr
|
|||
PIPE_FORMAT_DXT3_SRGBA , s3tc, 4, 4, x128, , , , xyzw, srgb
|
||||
PIPE_FORMAT_DXT5_SRGBA , s3tc, 4, 4, x128, , , , xyzw, srgb
|
||||
|
||||
PIPE_FORMAT_RGTC1_UNORM , rgtc, 4, 4, x64, , , , x001, rgb
|
||||
PIPE_FORMAT_RGTC1_SNORM , rgtc, 4, 4, x64, , , , x001, rgb
|
||||
PIPE_FORMAT_RGTC2_UNORM , rgtc, 4, 4, x128, , , , xy01, rgb
|
||||
PIPE_FORMAT_RGTC2_SNORM , rgtc, 4, 4, x128, , , , xy01, rgb
|
||||
|
||||
# Straightforward D3D10-like formats (also used for
|
||||
# vertex buffer element description)
|
||||
#
|
||||
|
@ -157,6 +177,10 @@ PIPE_FORMAT_R32_FIXED , plain, 1, 1, h32 , , , , x001, r
|
|||
PIPE_FORMAT_R32G32_FIXED , plain, 1, 1, h32 , h32 , , , xy01, rgb
|
||||
PIPE_FORMAT_R32G32B32_FIXED , plain, 1, 1, h32 , h32 , h32 , , xyz1, rgb
|
||||
PIPE_FORMAT_R32G32B32A32_FIXED , plain, 1, 1, h32 , h32 , h32 , h32 , xyzw, rgb
|
||||
PIPE_FORMAT_R16_FLOAT , plain, 1, 1, f16 , , , , x001, rgb
|
||||
PIPE_FORMAT_R16G16_FLOAT , plain, 1, 1, f16 , f16 , , , xy01, rgb
|
||||
PIPE_FORMAT_R16G16B16_FLOAT , plain, 1, 1, f16 , f16 , f16 , , xyz1, rgb
|
||||
PIPE_FORMAT_R16G16B16A16_FLOAT , plain, 1, 1, f16 , f16 , f16 , f16 , xyzw, rgb
|
||||
PIPE_FORMAT_R16_UNORM , plain, 1, 1, un16, , , , x001, rgb
|
||||
PIPE_FORMAT_R16G16_UNORM , plain, 1, 1, un16, un16, , , xy01, rgb
|
||||
PIPE_FORMAT_R16G16B16_UNORM , plain, 1, 1, un16, un16, un16, , xyz1, rgb
|
||||
|
|
Can't render this file because it contains an unexpected character in line 8 and column 3.
|
|
@ -189,6 +189,46 @@ struct util_format_description
|
|||
* Colorspace transformation.
|
||||
*/
|
||||
enum util_format_colorspace colorspace;
|
||||
|
||||
/**
|
||||
* Unpack pixel blocks to R8G8B8A8_UNORM.
|
||||
*/
|
||||
void
|
||||
(*unpack_8unorm)(uint8_t *dst, unsigned dst_stride,
|
||||
const uint8_t *src, unsigned src_stride,
|
||||
unsigned width, unsigned height);
|
||||
|
||||
/**
|
||||
* Pack pixel blocks from R8G8B8A8_UNORM.
|
||||
*/
|
||||
void
|
||||
(*pack_8unorm)(uint8_t *dst, unsigned dst_stride,
|
||||
const uint8_t *src, unsigned src_stride,
|
||||
unsigned width, unsigned height);
|
||||
|
||||
/**
|
||||
* Unpack pixel blocks to R32G32B32A32_FLOAT.
|
||||
*/
|
||||
void
|
||||
(*unpack_float)(float *dst, unsigned dst_stride,
|
||||
const uint8_t *src, unsigned src_stride,
|
||||
unsigned width, unsigned height);
|
||||
|
||||
/**
|
||||
* Pack pixel blocks from R32G32B32A32_FLOAT.
|
||||
*/
|
||||
void
|
||||
(*pack_float)(uint8_t *dst, unsigned dst_stride,
|
||||
const float *src, unsigned src_stride,
|
||||
unsigned width, unsigned height);
|
||||
|
||||
/**
|
||||
* Fetch a single pixel (i, j) from a block.
|
||||
*/
|
||||
void
|
||||
(*fetch_float)(float *dst,
|
||||
const uint8_t *src,
|
||||
unsigned i, unsigned j);
|
||||
};
|
||||
|
||||
|
||||
|
@ -209,8 +249,8 @@ util_format_name(enum pipe_format format)
|
|||
{
|
||||
const struct util_format_description *desc = util_format_description(format);
|
||||
|
||||
assert(format);
|
||||
if (!format) {
|
||||
assert(desc);
|
||||
if (!desc) {
|
||||
return "???";
|
||||
}
|
||||
|
||||
|
@ -222,8 +262,8 @@ util_format_is_s3tc(enum pipe_format format)
|
|||
{
|
||||
const struct util_format_description *desc = util_format_description(format);
|
||||
|
||||
assert(format);
|
||||
if (!format) {
|
||||
assert(desc);
|
||||
if (!desc) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -235,8 +275,8 @@ util_format_is_depth_or_stencil(enum pipe_format format)
|
|||
{
|
||||
const struct util_format_description *desc = util_format_description(format);
|
||||
|
||||
assert(format);
|
||||
if (!format) {
|
||||
assert(desc);
|
||||
if (!desc) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -248,8 +288,8 @@ util_format_is_depth_and_stencil(enum pipe_format format)
|
|||
{
|
||||
const struct util_format_description *desc = util_format_description(format);
|
||||
|
||||
assert(format);
|
||||
if (!format) {
|
||||
assert(desc);
|
||||
if (!desc) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -261,6 +301,34 @@ util_format_is_depth_and_stencil(enum pipe_format format)
|
|||
desc->swizzle[1] != UTIL_FORMAT_SWIZZLE_NONE) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this format is a rgab8 variant.
|
||||
*
|
||||
* That is, any format that matches the
|
||||
*
|
||||
* PIPE_FORMAT_?8?8?8?8_UNORM
|
||||
*/
|
||||
static INLINE boolean
|
||||
util_format_is_rgba8_variant(const struct util_format_description *desc)
|
||||
{
|
||||
unsigned chan;
|
||||
|
||||
if(desc->block.width != 1 ||
|
||||
desc->block.height != 1 ||
|
||||
desc->block.bits != 32)
|
||||
return FALSE;
|
||||
|
||||
for(chan = 0; chan < 4; ++chan) {
|
||||
if(desc->channel[chan].type != UTIL_FORMAT_TYPE_UNSIGNED &&
|
||||
desc->channel[chan].type != UTIL_FORMAT_TYPE_VOID)
|
||||
return FALSE;
|
||||
if(desc->channel[chan].size != 8)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return total bits needed for the pixel format per block.
|
||||
|
@ -270,8 +338,8 @@ util_format_get_blocksizebits(enum pipe_format format)
|
|||
{
|
||||
const struct util_format_description *desc = util_format_description(format);
|
||||
|
||||
assert(format);
|
||||
if (!format) {
|
||||
assert(desc);
|
||||
if (!desc) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -296,8 +364,8 @@ util_format_get_blockwidth(enum pipe_format format)
|
|||
{
|
||||
const struct util_format_description *desc = util_format_description(format);
|
||||
|
||||
assert(format);
|
||||
if (!format) {
|
||||
assert(desc);
|
||||
if (!desc) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -309,8 +377,8 @@ util_format_get_blockheight(enum pipe_format format)
|
|||
{
|
||||
const struct util_format_description *desc = util_format_description(format);
|
||||
|
||||
assert(format);
|
||||
if (!format) {
|
||||
assert(desc);
|
||||
if (!desc) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,341 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
'''
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2009 VMware, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER 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
|
||||
* Pixel format accessor functions.
|
||||
*
|
||||
* @author Jose Fonseca <jfonseca@vmware.com>
|
||||
*/
|
||||
'''
|
||||
|
||||
|
||||
import math
|
||||
import sys
|
||||
|
||||
from u_format_pack import *
|
||||
|
||||
|
||||
def is_format_supported(format):
|
||||
'''Determines whether we actually have the plumbing necessary to generate the
|
||||
to read/write to/from this format.'''
|
||||
|
||||
# FIXME: Ideally we would support any format combination here.
|
||||
|
||||
# XXX: It should be straightforward to support srgb
|
||||
if format.colorspace not in ('rgb', 'zs'):
|
||||
return False
|
||||
|
||||
if format.layout != PLAIN:
|
||||
return False
|
||||
|
||||
for i in range(4):
|
||||
channel = format.channels[i]
|
||||
if channel.type not in (VOID, UNSIGNED, FLOAT):
|
||||
return False
|
||||
|
||||
# We can only read a color from a depth/stencil format if the depth channel is present
|
||||
if format.colorspace == 'zs' and format.swizzles[0] == SWIZZLE_NONE:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def native_type(format):
|
||||
'''Get the native appropriate for a format.'''
|
||||
|
||||
if format.layout == PLAIN:
|
||||
if not format.is_array():
|
||||
# For arithmetic pixel formats return the integer type that matches the whole pixel
|
||||
return 'uint%u_t' % format.block_size()
|
||||
else:
|
||||
# For array pixel formats return the integer type that matches the color channel
|
||||
channel = format.channels[0]
|
||||
if channel.type == UNSIGNED:
|
||||
return 'uint%u_t' % channel.size
|
||||
elif channel.type == SIGNED:
|
||||
return 'int%u_t' % channel.size
|
||||
elif channel.type == FLOAT:
|
||||
if channel.size == 32:
|
||||
return 'float'
|
||||
elif channel.size == 64:
|
||||
return 'double'
|
||||
else:
|
||||
assert False
|
||||
else:
|
||||
assert False
|
||||
else:
|
||||
assert False
|
||||
|
||||
|
||||
def generate_srgb_tables():
|
||||
print 'static ubyte srgb_to_linear[256] = {'
|
||||
for i in range(256):
|
||||
print ' %s,' % (int(math.pow((i / 255.0 + 0.055) / 1.055, 2.4) * 255))
|
||||
print '};'
|
||||
print
|
||||
print 'static ubyte linear_to_srgb[256] = {'
|
||||
print ' 0,'
|
||||
for i in range(1, 256):
|
||||
print ' %s,' % (int((1.055 * math.pow(i / 255.0, 0.41666) - 0.055) * 255))
|
||||
print '};'
|
||||
print
|
||||
|
||||
|
||||
def generate_format_read(format, dst_channel, dst_native_type, dst_suffix):
|
||||
'''Generate the function to read pixels from a particular format'''
|
||||
|
||||
name = format.short_name()
|
||||
|
||||
src_native_type = native_type(format)
|
||||
|
||||
print 'static void'
|
||||
print 'util_format_%s_read_%s(%s *dst, unsigned dst_stride, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, dst_suffix, dst_native_type)
|
||||
print '{'
|
||||
print ' unsigned x, y;'
|
||||
print ' const uint8_t *src_row = src + y0*src_stride;'
|
||||
print ' %s *dst_row = dst;' % dst_native_type
|
||||
print ' for (y = 0; y < h; ++y) {'
|
||||
print ' const %s *src_pixel = (const %s *)(src_row + x0*%u);' % (src_native_type, src_native_type, format.stride())
|
||||
print ' %s *dst_pixel = dst_row;' %dst_native_type
|
||||
print ' for (x = 0; x < w; ++x) {'
|
||||
|
||||
names = ['']*4
|
||||
if format.colorspace == 'rgb':
|
||||
for i in range(4):
|
||||
swizzle = format.swizzles[i]
|
||||
if swizzle < 4:
|
||||
names[swizzle] += 'rgba'[i]
|
||||
elif format.colorspace == 'zs':
|
||||
swizzle = format.swizzles[0]
|
||||
if swizzle < 4:
|
||||
names[swizzle] = 'z'
|
||||
else:
|
||||
assert False
|
||||
else:
|
||||
assert False
|
||||
|
||||
if format.layout == PLAIN:
|
||||
if not format.is_array():
|
||||
print ' %s pixel = *src_pixel++;' % src_native_type
|
||||
shift = 0;
|
||||
for i in range(4):
|
||||
src_channel = format.channels[i]
|
||||
width = src_channel.size
|
||||
if names[i]:
|
||||
value = 'pixel'
|
||||
mask = (1 << width) - 1
|
||||
if shift:
|
||||
value = '(%s >> %u)' % (value, shift)
|
||||
if shift + width < format.block_size():
|
||||
value = '(%s & 0x%x)' % (value, mask)
|
||||
value = conversion_expr(src_channel, dst_channel, dst_native_type, value)
|
||||
print ' %s %s = %s;' % (dst_native_type, names[i], value)
|
||||
shift += width
|
||||
else:
|
||||
for i in range(4):
|
||||
src_channel = format.channels[i]
|
||||
if names[i]:
|
||||
value = 'src_pixel[%u]' % i
|
||||
value = conversion_expr(src_channel, dst_channel, dst_native_type, value)
|
||||
print ' %s %s = %s;' % (dst_native_type, names[i], value)
|
||||
print ' src_pixel += %u;' % (format.nr_channels())
|
||||
else:
|
||||
assert False
|
||||
|
||||
for i in range(4):
|
||||
if format.colorspace == 'rgb':
|
||||
swizzle = format.swizzles[i]
|
||||
if swizzle < 4:
|
||||
value = names[swizzle]
|
||||
elif swizzle == SWIZZLE_0:
|
||||
value = '0'
|
||||
elif swizzle == SWIZZLE_1:
|
||||
value = get_one(dst_channel)
|
||||
else:
|
||||
assert False
|
||||
elif format.colorspace == 'zs':
|
||||
if i < 3:
|
||||
value = 'z'
|
||||
else:
|
||||
value = get_one(dst_channel)
|
||||
else:
|
||||
assert False
|
||||
print ' *dst_pixel++ = %s; /* %s */' % (value, 'rgba'[i])
|
||||
|
||||
print ' }'
|
||||
print ' src_row += src_stride;'
|
||||
print ' dst_row += dst_stride/sizeof(*dst_row);'
|
||||
print ' }'
|
||||
print '}'
|
||||
print
|
||||
|
||||
|
||||
def generate_format_write(format, src_channel, src_native_type, src_suffix):
|
||||
'''Generate the function to write pixels to a particular format'''
|
||||
|
||||
name = format.short_name()
|
||||
|
||||
dst_native_type = native_type(format)
|
||||
|
||||
print 'static void'
|
||||
print 'util_format_%s_write_%s(const %s *src, unsigned src_stride, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, src_suffix, src_native_type)
|
||||
print '{'
|
||||
print ' unsigned x, y;'
|
||||
print ' uint8_t *dst_row = dst + y0*dst_stride;'
|
||||
print ' const %s *src_row = src;' % src_native_type
|
||||
print ' for (y = 0; y < h; ++y) {'
|
||||
print ' %s *dst_pixel = (%s *)(dst_row + x0*%u);' % (dst_native_type, dst_native_type, format.stride())
|
||||
print ' const %s *src_pixel = src_row;' %src_native_type
|
||||
print ' for (x = 0; x < w; ++x) {'
|
||||
|
||||
inv_swizzle = format.inv_swizzles()
|
||||
|
||||
if format.layout == PLAIN:
|
||||
if not format.is_array():
|
||||
print ' %s pixel = 0;' % dst_native_type
|
||||
shift = 0;
|
||||
for i in range(4):
|
||||
dst_channel = format.channels[i]
|
||||
width = dst_channel.size
|
||||
if inv_swizzle[i] is not None:
|
||||
value = 'src_pixel[%u]' % inv_swizzle[i]
|
||||
value = conversion_expr(src_channel, dst_channel, dst_native_type, value)
|
||||
if shift:
|
||||
value = '(%s << %u)' % (value, shift)
|
||||
print ' pixel |= %s;' % value
|
||||
shift += width
|
||||
print ' *dst_pixel++ = pixel;'
|
||||
else:
|
||||
for i in range(4):
|
||||
dst_channel = format.channels[i]
|
||||
if inv_swizzle[i] is not None:
|
||||
value = 'src_pixel[%u]' % inv_swizzle[i]
|
||||
value = conversion_expr(src_channel, dst_channel, dst_native_type, value)
|
||||
print ' *dst_pixel++ = %s;' % value
|
||||
else:
|
||||
assert False
|
||||
print ' src_pixel += 4;'
|
||||
|
||||
print ' }'
|
||||
print ' dst_row += dst_stride;'
|
||||
print ' src_row += src_stride/sizeof(*src_row);'
|
||||
print ' }'
|
||||
print '}'
|
||||
print
|
||||
|
||||
|
||||
def generate_read(formats, dst_channel, dst_native_type, dst_suffix):
|
||||
'''Generate the dispatch function to read pixels from any format'''
|
||||
|
||||
for format in formats:
|
||||
if is_format_supported(format):
|
||||
generate_format_read(format, dst_channel, dst_native_type, dst_suffix)
|
||||
|
||||
print 'void'
|
||||
print 'util_format_read_%s(enum pipe_format format, %s *dst, unsigned dst_stride, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type)
|
||||
print '{'
|
||||
print ' void (*func)(%s *dst, unsigned dst_stride, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % dst_native_type
|
||||
print ' switch(format) {'
|
||||
for format in formats:
|
||||
if is_format_supported(format):
|
||||
print ' case %s:' % format.name
|
||||
print ' func = &util_format_%s_read_%s;' % (format.short_name(), dst_suffix)
|
||||
print ' break;'
|
||||
print ' default:'
|
||||
print ' debug_printf("unsupported format\\n");'
|
||||
print ' return;'
|
||||
print ' }'
|
||||
print ' func(dst, dst_stride, (const uint8_t *)src, src_stride, x, y, w, h);'
|
||||
print '}'
|
||||
print
|
||||
|
||||
|
||||
def generate_write(formats, src_channel, src_native_type, src_suffix):
|
||||
'''Generate the dispatch function to write pixels to any format'''
|
||||
|
||||
for format in formats:
|
||||
if is_format_supported(format):
|
||||
generate_format_write(format, src_channel, src_native_type, src_suffix)
|
||||
|
||||
print 'void'
|
||||
print 'util_format_write_%s(enum pipe_format format, const %s *src, unsigned src_stride, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type)
|
||||
|
||||
print '{'
|
||||
print ' void (*func)(const %s *src, unsigned src_stride, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % src_native_type
|
||||
print ' switch(format) {'
|
||||
for format in formats:
|
||||
if is_format_supported(format):
|
||||
print ' case %s:' % format.name
|
||||
print ' func = &util_format_%s_write_%s;' % (format.short_name(), src_suffix)
|
||||
print ' break;'
|
||||
print ' default:'
|
||||
print ' debug_printf("unsupported format\\n");'
|
||||
print ' return;'
|
||||
print ' }'
|
||||
print ' func(src, src_stride, (uint8_t *)dst, dst_stride, x, y, w, h);'
|
||||
print '}'
|
||||
print
|
||||
|
||||
|
||||
def main():
|
||||
formats = []
|
||||
for arg in sys.argv[1:]:
|
||||
formats.extend(parse(arg))
|
||||
|
||||
print '/* This file is autogenerated by u_format_access.py from u_format.csv. Do not edit directly. */'
|
||||
print
|
||||
# This will print the copyright message on the top of this file
|
||||
print __doc__.strip()
|
||||
print
|
||||
print '#include "pipe/p_compiler.h"'
|
||||
print '#include "u_math.h"'
|
||||
print '#include "u_format_pack.h"'
|
||||
print
|
||||
|
||||
generate_srgb_tables()
|
||||
|
||||
type = Channel(FLOAT, False, 32)
|
||||
native_type = 'float'
|
||||
suffix = '4f'
|
||||
|
||||
generate_read(formats, type, native_type, suffix)
|
||||
generate_write(formats, type, native_type, suffix)
|
||||
|
||||
type = Channel(UNSIGNED, True, 8)
|
||||
native_type = 'uint8_t'
|
||||
suffix = '4ub'
|
||||
|
||||
generate_read(formats, type, native_type, suffix)
|
||||
generate_write(formats, type, native_type, suffix)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -38,19 +38,59 @@
|
|||
|
||||
|
||||
import sys
|
||||
import math
|
||||
|
||||
from u_format_parse import *
|
||||
|
||||
|
||||
def generate_f16_to_f32():
|
||||
'''Naive implementation, need something faster that operates on bits'''
|
||||
|
||||
print '''
|
||||
static float
|
||||
f16_to_f32(uint16_t h)
|
||||
{
|
||||
unsigned mantissa = h & 0x3ff;
|
||||
unsigned exponent = (h >> 10) & 0x1f;
|
||||
float sign = (h & 0x8000) ? -1.0f : 1.0f;
|
||||
|
||||
if (exponent == 0) {
|
||||
if (mantissa == 0) {
|
||||
return sign * 0.0f;
|
||||
}
|
||||
return sign * powf(2.0f, -14.0f) * (float)mantissa / 1024.0f;
|
||||
}
|
||||
if (exponent == 31) {
|
||||
if (mantissa == 0) {
|
||||
/* XXX: infinity */
|
||||
return sign * 100000.0f;
|
||||
}
|
||||
/* XXX: NaN */
|
||||
return 1000.0f;
|
||||
}
|
||||
return sign * powf(2.0f, (float)exponent - 15.0f) * (1.0f + (float)mantissa / 1024.0f);
|
||||
}
|
||||
'''
|
||||
|
||||
def generate_f32_to_f16():
|
||||
print '''
|
||||
static uint16_t
|
||||
f32_to_f16(float f)
|
||||
{
|
||||
/* TODO */
|
||||
return 0;
|
||||
}
|
||||
'''
|
||||
|
||||
def generate_format_type(format):
|
||||
'''Generate a structure that describes the format.'''
|
||||
|
||||
print 'union util_format_%s {' % format.short_name()
|
||||
if format.is_bitmask():
|
||||
if format.is_bitmask() or format.short_name() == "r11g11b10_float":
|
||||
print ' uint%u_t value;' % (format.block_size(),)
|
||||
print ' struct {'
|
||||
for channel in format.channels:
|
||||
if format.is_bitmask() and not format.is_array():
|
||||
if (format.is_bitmask() or format.is_mixed()) and not format.is_array() or format.short_name() == "r11g11b10_float":
|
||||
if channel.type == VOID:
|
||||
if channel.size:
|
||||
print ' unsigned %s:%u;' % (channel.name, channel.size)
|
||||
|
@ -58,6 +98,11 @@ def generate_format_type(format):
|
|||
print ' unsigned %s:%u;' % (channel.name, channel.size)
|
||||
elif channel.type == SIGNED:
|
||||
print ' int %s:%u;' % (channel.name, channel.size)
|
||||
elif channel.type == FLOAT:
|
||||
if channel.size == 32:
|
||||
print ' float %s;' % (channel.name)
|
||||
else:
|
||||
print ' unsigned %s:%u;' % (channel.name, channel.size)
|
||||
else:
|
||||
assert 0
|
||||
else:
|
||||
|
@ -85,6 +130,20 @@ def generate_format_type(format):
|
|||
print
|
||||
|
||||
|
||||
def generate_srgb_tables():
|
||||
print 'static ubyte srgb_to_linear[256] = {'
|
||||
for i in range(256):
|
||||
print ' %s,' % (int(math.pow((i / 255.0 + 0.055) / 1.055, 2.4) * 255))
|
||||
print '};'
|
||||
print
|
||||
print 'static ubyte linear_to_srgb[256] = {'
|
||||
print ' 0,'
|
||||
for i in range(1, 256):
|
||||
print ' %s,' % (int((1.055 * math.pow(i / 255.0, 0.41666) - 0.055) * 255))
|
||||
print '};'
|
||||
print
|
||||
|
||||
|
||||
def bswap_format(format):
|
||||
'''Generate a structure that describes the format.'''
|
||||
|
||||
|
@ -124,15 +183,17 @@ def native_type(format):
|
|||
return 'uint%u_t' % format.block_size()
|
||||
else:
|
||||
# For array pixel formats return the integer type that matches the color channel
|
||||
type = format.channels[0]
|
||||
if type.type == UNSIGNED:
|
||||
return 'uint%u_t' % type.size
|
||||
elif type.type == SIGNED:
|
||||
return 'int%u_t' % type.size
|
||||
elif type.type == FLOAT:
|
||||
if type.size == 32:
|
||||
channel = format.channels[0]
|
||||
if channel.type in (UNSIGNED, VOID):
|
||||
return 'uint%u_t' % channel.size
|
||||
elif channel.type == SIGNED:
|
||||
return 'int%u_t' % channel.size
|
||||
elif channel.type == FLOAT:
|
||||
if channel.size == 16:
|
||||
return 'uint16_t'
|
||||
elif channel.size == 32:
|
||||
return 'float'
|
||||
elif type.size == 64:
|
||||
elif channel.size == 64:
|
||||
return 'double'
|
||||
else:
|
||||
assert False
|
||||
|
@ -179,31 +240,6 @@ def get_one(type):
|
|||
return (1 << get_one_shift(type)) - 1
|
||||
|
||||
|
||||
def generate_clamp():
|
||||
'''Code generate the clamping functions for each type.
|
||||
|
||||
We don't use a macro so that arguments with side effects,
|
||||
like *src_pixel++ are correctly handled.
|
||||
'''
|
||||
|
||||
for suffix, native_type in [
|
||||
('', 'double'),
|
||||
('f', 'float'),
|
||||
('ui', 'unsigned int'),
|
||||
('si', 'int'),
|
||||
]:
|
||||
print 'static INLINE %s' % native_type
|
||||
print 'clamp%s(%s value, %s lbound, %s ubound)' % (suffix, native_type, native_type, native_type)
|
||||
print '{'
|
||||
print ' if(value < lbound)'
|
||||
print ' return lbound;'
|
||||
print ' if(value > ubound)'
|
||||
print ' return ubound;'
|
||||
print ' return value;'
|
||||
print '}'
|
||||
print
|
||||
|
||||
|
||||
def clamp_expr(src_channel, dst_channel, dst_native_type, value):
|
||||
'''Generate the expression to clamp the value in the source type to the
|
||||
destination type range.'''
|
||||
|
@ -211,21 +247,6 @@ def clamp_expr(src_channel, dst_channel, dst_native_type, value):
|
|||
if src_channel == dst_channel:
|
||||
return value
|
||||
|
||||
# Pick the approriate clamp function
|
||||
if src_channel.type == FLOAT:
|
||||
if src_channel.size == 32:
|
||||
func = 'clampf'
|
||||
elif src_channel.size == 64:
|
||||
func = 'clamp'
|
||||
else:
|
||||
assert False
|
||||
elif src_channel.type == UNSIGNED:
|
||||
func = 'clampui'
|
||||
elif src_channel.type == SIGNED:
|
||||
func = 'clampsi'
|
||||
else:
|
||||
assert False
|
||||
|
||||
src_min = src_channel.min()
|
||||
src_max = src_channel.max()
|
||||
dst_min = dst_channel.min()
|
||||
|
@ -250,7 +271,17 @@ def conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=True
|
|||
return value
|
||||
|
||||
if src_channel.type == FLOAT and dst_channel.type == FLOAT:
|
||||
return '(%s)%s' % (dst_native_type, value)
|
||||
if src_channel.size == dst_channel.size:
|
||||
return value
|
||||
if src_channel.size == 64:
|
||||
value = '(float)%s' % (value)
|
||||
elif src_channel.size == 16:
|
||||
value = 'f16_to_f32(%s)' % (value)
|
||||
if dst_channel.size == 16:
|
||||
value = 'f32_to_f16(%s)' % (value)
|
||||
elif dst_channel.size == 64:
|
||||
value = '(double)%s' % (value)
|
||||
return value
|
||||
|
||||
if clamp:
|
||||
value = clamp_expr(src_channel, dst_channel, dst_native_type, value)
|
||||
|
@ -301,33 +332,29 @@ def conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=True
|
|||
assert False
|
||||
|
||||
|
||||
def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix):
|
||||
'''Generate the function to unpack pixels from a particular format'''
|
||||
def generate_unpack_kernel(format, dst_channel, dst_native_type):
|
||||
|
||||
if not is_format_supported(format):
|
||||
return
|
||||
|
||||
assert format.layout == PLAIN
|
||||
|
||||
name = format.short_name()
|
||||
|
||||
src_native_type = native_type(format)
|
||||
|
||||
print 'static INLINE void'
|
||||
print 'util_format_%s_unpack_%s(%s *dst, const void *src)' % (name, dst_suffix, dst_native_type)
|
||||
print '{'
|
||||
|
||||
if format.is_bitmask():
|
||||
depth = format.block_size()
|
||||
print ' uint%u_t value = *(uint%u_t *)src;' % (depth, depth)
|
||||
print ' uint%u_t value = *(uint%u_t *)src;' % (depth, depth)
|
||||
|
||||
# Declare the intermediate variables
|
||||
for i in range(format.nr_channels()):
|
||||
src_channel = format.channels[i]
|
||||
if src_channel.type == UNSIGNED:
|
||||
print ' uint%u_t %s;' % (depth, src_channel.name)
|
||||
print ' uint%u_t %s;' % (depth, src_channel.name)
|
||||
elif src_channel.type == SIGNED:
|
||||
print ' int%u_t %s;' % (depth, src_channel.name)
|
||||
print ' int%u_t %s;' % (depth, src_channel.name)
|
||||
|
||||
print '#ifdef PIPE_ARCH_BIG_ENDIAN'
|
||||
print ' value = util_bswap%u(value);' % depth
|
||||
print ' value = util_bswap%u(value);' % depth
|
||||
print '#endif'
|
||||
|
||||
# Compute the intermediate unshifted values
|
||||
|
@ -355,7 +382,7 @@ def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix):
|
|||
value = None
|
||||
|
||||
if value is not None:
|
||||
print ' %s = %s;' % (src_channel.name, value)
|
||||
print ' %s = %s;' % (src_channel.name, value)
|
||||
|
||||
shift += src_channel.size
|
||||
|
||||
|
@ -379,11 +406,11 @@ def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix):
|
|||
value = get_one(dst_channel)
|
||||
elif i >= 1:
|
||||
value = 'dst[0]'
|
||||
print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
|
||||
print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
|
||||
|
||||
else:
|
||||
print ' union util_format_%s pixel;' % format.short_name()
|
||||
print ' memcpy(&pixel, src, sizeof pixel);'
|
||||
print ' union util_format_%s pixel;' % format.short_name()
|
||||
print ' memcpy(&pixel, src, sizeof pixel);'
|
||||
bswap_format(format)
|
||||
|
||||
for i in range(4):
|
||||
|
@ -405,36 +432,29 @@ def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix):
|
|||
value = get_one(dst_channel)
|
||||
elif i >= 1:
|
||||
value = 'dst[0]'
|
||||
print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
|
||||
|
||||
print '}'
|
||||
print
|
||||
print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
|
||||
|
||||
|
||||
def generate_format_pack(format, src_channel, src_native_type, src_suffix):
|
||||
'''Generate the function to pack pixels to a particular format'''
|
||||
|
||||
name = format.short_name()
|
||||
def generate_pack_kernel(format, src_channel, src_native_type):
|
||||
|
||||
if not is_format_supported(format):
|
||||
return
|
||||
|
||||
dst_native_type = native_type(format)
|
||||
|
||||
assert format.layout == PLAIN
|
||||
|
||||
inv_swizzle = format.inv_swizzles()
|
||||
|
||||
print 'static INLINE void'
|
||||
print 'util_format_%s_pack_%s(void *dst, %s r, %s g, %s b, %s a)' % (name, src_suffix, src_native_type, src_native_type, src_native_type, src_native_type)
|
||||
print '{'
|
||||
|
||||
|
||||
if format.is_bitmask():
|
||||
depth = format.block_size()
|
||||
print ' uint%u_t value = 0;' % depth
|
||||
print ' uint%u_t value = 0;' % depth
|
||||
|
||||
shift = 0
|
||||
for i in range(4):
|
||||
dst_channel = format.channels[i]
|
||||
if inv_swizzle[i] is not None:
|
||||
value = 'rgba'[inv_swizzle[i]]
|
||||
value ='src[%u]' % inv_swizzle[i]
|
||||
value = conversion_expr(src_channel, dst_channel, dst_native_type, value)
|
||||
if format.colorspace == ZS:
|
||||
if i == 3:
|
||||
|
@ -452,138 +472,141 @@ def generate_format_pack(format, src_channel, src_native_type, src_suffix):
|
|||
else:
|
||||
value = None
|
||||
if value is not None:
|
||||
print ' value |= %s;' % (value)
|
||||
print ' value |= %s;' % (value)
|
||||
|
||||
shift += dst_channel.size
|
||||
|
||||
print '#ifdef PIPE_ARCH_BIG_ENDIAN'
|
||||
print ' value = util_bswap%u(value);' % depth
|
||||
print ' value = util_bswap%u(value);' % depth
|
||||
print '#endif'
|
||||
|
||||
print ' *(uint%u_t *)dst = value;' % depth
|
||||
print ' *(uint%u_t *)dst = value;' % depth
|
||||
|
||||
else:
|
||||
print ' union util_format_%s pixel;' % format.short_name()
|
||||
print ' union util_format_%s pixel;' % format.short_name()
|
||||
|
||||
for i in range(4):
|
||||
dst_channel = format.channels[i]
|
||||
width = dst_channel.size
|
||||
if inv_swizzle[i] is None:
|
||||
continue
|
||||
value = 'rgba'[inv_swizzle[i]]
|
||||
value ='src[%u]' % inv_swizzle[i]
|
||||
value = conversion_expr(src_channel, dst_channel, dst_native_type, value)
|
||||
if format.colorspace == ZS:
|
||||
if i == 3:
|
||||
value = get_one(dst_channel)
|
||||
elif i >= 1:
|
||||
value = '0'
|
||||
print ' pixel.chan.%s = %s;' % (dst_channel.name, value)
|
||||
print ' pixel.chan.%s = %s;' % (dst_channel.name, value)
|
||||
|
||||
bswap_format(format)
|
||||
print ' memcpy(dst, &pixel, sizeof pixel);'
|
||||
print ' memcpy(dst, &pixel, sizeof pixel);'
|
||||
|
||||
|
||||
def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix):
|
||||
'''Generate the function to unpack pixels from a particular format'''
|
||||
|
||||
name = format.short_name()
|
||||
|
||||
print 'static INLINE void'
|
||||
print 'util_format_%s_unpack_%s(%s *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, dst_suffix, dst_native_type)
|
||||
print '{'
|
||||
|
||||
if is_format_supported(format):
|
||||
print ' unsigned x, y;'
|
||||
print ' for(y = 0; y < height; y += %u) {' % (format.block_height,)
|
||||
print ' %s *dst = dst_row;' % (dst_native_type)
|
||||
print ' const uint8_t *src = src_row;'
|
||||
print ' for(x = 0; x < width; x += %u) {' % (format.block_width,)
|
||||
|
||||
generate_unpack_kernel(format, dst_channel, dst_native_type)
|
||||
|
||||
print ' src += %u;' % (format.block_size() / 8,)
|
||||
print ' dst += 4;'
|
||||
print ' }'
|
||||
print ' src_row += src_stride;'
|
||||
print ' dst_row += dst_stride/sizeof(*dst_row);'
|
||||
print ' }'
|
||||
|
||||
print '}'
|
||||
print
|
||||
|
||||
|
||||
def generate_format_pack(format, src_channel, src_native_type, src_suffix):
|
||||
'''Generate the function to pack pixels to a particular format'''
|
||||
|
||||
name = format.short_name()
|
||||
|
||||
print 'static INLINE void'
|
||||
print 'util_format_%s_pack_%s(uint8_t *dst_row, unsigned dst_stride, const %s *src_row, unsigned src_stride, unsigned width, unsigned height)' % (name, src_suffix, src_native_type)
|
||||
print '{'
|
||||
|
||||
if is_format_supported(format):
|
||||
print ' unsigned x, y;'
|
||||
print ' for(y = 0; y < height; y += %u) {' % (format.block_height,)
|
||||
print ' const %s *src = src_row;' % (src_native_type)
|
||||
print ' uint8_t *dst = dst_row;'
|
||||
print ' for(x = 0; x < width; x += %u) {' % (format.block_width,)
|
||||
|
||||
generate_pack_kernel(format, src_channel, src_native_type)
|
||||
|
||||
print ' src += 4;'
|
||||
print ' dst += %u;' % (format.block_size() / 8,)
|
||||
print ' }'
|
||||
print ' dst_row += dst_stride;'
|
||||
print ' src_row += src_stride/sizeof(*src_row);'
|
||||
print ' }'
|
||||
|
||||
print '}'
|
||||
print
|
||||
|
||||
|
||||
def generate_unpack(formats, dst_channel, dst_native_type, dst_suffix):
|
||||
'''Generate the dispatch function to unpack pixels from any format'''
|
||||
def generate_format_fetch(format, dst_channel, dst_native_type, dst_suffix):
|
||||
'''Generate the function to unpack pixels from a particular format'''
|
||||
|
||||
for format in formats:
|
||||
if is_format_supported(format):
|
||||
generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix)
|
||||
name = format.short_name()
|
||||
|
||||
print 'static INLINE void'
|
||||
print 'util_format_unpack_%s(enum pipe_format format, %s *dst, const void *src)' % (dst_suffix, dst_native_type)
|
||||
print 'util_format_%s_fetch_%s(%s *dst, const uint8_t *src, unsigned i, unsigned j)' % (name, dst_suffix, dst_native_type)
|
||||
print '{'
|
||||
print ' void (*func)(%s *dst, const void *src);' % dst_native_type
|
||||
print ' switch(format) {'
|
||||
for format in formats:
|
||||
if is_format_supported(format):
|
||||
print ' case %s:' % format.name
|
||||
print ' func = &util_format_%s_unpack_%s;' % (format.short_name(), dst_suffix)
|
||||
print ' break;'
|
||||
print ' default:'
|
||||
print ' debug_printf("unsupported format\\n");'
|
||||
print ' return;'
|
||||
print ' }'
|
||||
print ' func(dst, src);'
|
||||
|
||||
if is_format_supported(format):
|
||||
generate_unpack_kernel(format, dst_channel, dst_native_type)
|
||||
|
||||
print '}'
|
||||
print
|
||||
|
||||
|
||||
def generate_pack(formats, src_channel, src_native_type, src_suffix):
|
||||
'''Generate the dispatch function to pack pixels to any format'''
|
||||
|
||||
for format in formats:
|
||||
if is_format_supported(format):
|
||||
generate_format_pack(format, src_channel, src_native_type, src_suffix)
|
||||
|
||||
print 'static INLINE void'
|
||||
print 'util_format_pack_%s(enum pipe_format format, void *dst, %s r, %s g, %s b, %s a)' % (src_suffix, src_native_type, src_native_type, src_native_type, src_native_type)
|
||||
print '{'
|
||||
print ' void (*func)(void *dst, %s r, %s g, %s b, %s a);' % (src_native_type, src_native_type, src_native_type, src_native_type)
|
||||
print ' switch(format) {'
|
||||
for format in formats:
|
||||
if is_format_supported(format):
|
||||
print ' case %s:' % format.name
|
||||
print ' func = &util_format_%s_pack_%s;' % (format.short_name(), src_suffix)
|
||||
print ' break;'
|
||||
print ' default:'
|
||||
print ' debug_printf("%s: unsupported format\\n", __FUNCTION__);'
|
||||
print ' return;'
|
||||
print ' }'
|
||||
print ' func(dst, r, g, b, a);'
|
||||
print '}'
|
||||
print
|
||||
|
||||
|
||||
def main():
|
||||
formats = []
|
||||
for arg in sys.argv[1:]:
|
||||
formats.extend(parse(arg))
|
||||
|
||||
print '/* This file is autogenerated by u_format_pack.py from u_format.csv. Do not edit directly. */'
|
||||
print
|
||||
# This will print the copyright message on the top of this file
|
||||
print __doc__.strip()
|
||||
|
||||
print
|
||||
print '#ifndef U_FORMAT_PACK_H'
|
||||
print '#define U_FORMAT_PACK_H'
|
||||
def generate(formats):
|
||||
print
|
||||
print '#include "pipe/p_compiler.h"'
|
||||
print '#include "u_math.h"'
|
||||
print '#include "u_format.h"'
|
||||
print
|
||||
|
||||
generate_clamp()
|
||||
generate_f16_to_f32()
|
||||
generate_f32_to_f16()
|
||||
|
||||
for format in formats:
|
||||
if format.layout == PLAIN:
|
||||
if is_format_supported(format):
|
||||
generate_format_type(format)
|
||||
|
||||
channel = Channel(FLOAT, False, 32)
|
||||
native_type = 'float'
|
||||
suffix = '4f'
|
||||
suffix = 'float'
|
||||
|
||||
generate_unpack(formats, channel, native_type, suffix)
|
||||
generate_pack(formats, channel, native_type, suffix)
|
||||
for format in formats:
|
||||
if format.layout != 's3tc':
|
||||
generate_format_unpack(format, channel, native_type, suffix)
|
||||
generate_format_pack(format, channel, native_type, suffix)
|
||||
generate_format_fetch(format, channel, native_type, suffix)
|
||||
|
||||
channel = Channel(UNSIGNED, True, 8)
|
||||
native_type = 'uint8_t'
|
||||
suffix = '4ub'
|
||||
suffix = '8unorm'
|
||||
|
||||
generate_unpack(formats, channel, native_type, suffix)
|
||||
generate_pack(formats, channel, native_type, suffix)
|
||||
for format in formats:
|
||||
if format.layout != 's3tc':
|
||||
generate_format_unpack(format, channel, native_type, suffix)
|
||||
generate_format_pack(format, channel, native_type, suffix)
|
||||
|
||||
print
|
||||
print '#ifdef __cplusplus'
|
||||
print '}'
|
||||
print '#endif'
|
||||
print
|
||||
print '#endif /* ! U_FORMAT_PACK_H */'
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -142,6 +142,8 @@ class Format:
|
|||
|
||||
def is_mixed(self):
|
||||
ref_channel = self.channels[0]
|
||||
if ref_channel.type == VOID:
|
||||
ref_channel = self.channels[1]
|
||||
for channel in self.channels[1:]:
|
||||
if channel.type != VOID:
|
||||
if channel.type != ref_channel.type:
|
||||
|
|
|
@ -0,0 +1,510 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
|
||||
* Copyright (c) 2008 VMware, Inc.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 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.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include "u_dl.h"
|
||||
#include "u_math.h"
|
||||
#include "u_format.h"
|
||||
#include "u_format_s3tc.h"
|
||||
|
||||
|
||||
#if defined(_WIN32) || defined(WIN32)
|
||||
#define DXTN_LIBNAME "dxtn.dll"
|
||||
#else
|
||||
#define DXTN_LIBNAME "libtxc_dxtn.so"
|
||||
#endif
|
||||
|
||||
|
||||
boolean util_format_s3tc_enabled = FALSE;
|
||||
|
||||
util_format_dxtn_fetch_t util_format_dxt1_rgb_fetch = NULL;
|
||||
util_format_dxtn_fetch_t util_format_dxt1_rgba_fetch = NULL;
|
||||
util_format_dxtn_fetch_t util_format_dxt3_rgba_fetch = NULL;
|
||||
util_format_dxtn_fetch_t util_format_dxt5_rgba_fetch = NULL;
|
||||
|
||||
util_format_dxtn_pack_t util_format_dxtn_pack = NULL;
|
||||
|
||||
|
||||
void
|
||||
util_format_s3tc_init(void)
|
||||
{
|
||||
static struct util_dl_library *
|
||||
library = NULL;
|
||||
|
||||
if (util_format_s3tc_enabled)
|
||||
return;
|
||||
|
||||
if (!library) {
|
||||
library = util_dl_open(DXTN_LIBNAME);
|
||||
if (!library) {
|
||||
debug_printf("couldn't open " DXTN_LIBNAME ", software DXTn "
|
||||
"compression/decompression unavailable");
|
||||
}
|
||||
else {
|
||||
util_format_dxt1_rgb_fetch = (util_format_dxtn_fetch_t)
|
||||
util_dl_get_proc_address(library, "fetch_2d_texel_rgb_dxt1");
|
||||
util_format_dxt1_rgba_fetch = (util_format_dxtn_fetch_t)
|
||||
util_dl_get_proc_address(library, "fetch_2d_texel_rgba_dxt1");
|
||||
util_format_dxt3_rgba_fetch = (util_format_dxtn_fetch_t)
|
||||
util_dl_get_proc_address(library, "fetch_2d_texel_rgba_dxt3");
|
||||
util_format_dxt5_rgba_fetch = (util_format_dxtn_fetch_t)
|
||||
util_dl_get_proc_address(library, "fetch_2d_texel_rgba_dxt5");
|
||||
util_format_dxtn_pack = (util_format_dxtn_pack_t)
|
||||
util_dl_get_proc_address(library, "tx_compress_dxtn");
|
||||
|
||||
if (util_format_dxt1_rgb_fetch ||
|
||||
util_format_dxt1_rgba_fetch ||
|
||||
util_format_dxt3_rgba_fetch ||
|
||||
util_format_dxt5_rgba_fetch ||
|
||||
util_format_dxtn_pack) {
|
||||
util_format_s3tc_enabled = TRUE;
|
||||
debug_printf("software DXTn compression/decompression available");
|
||||
|
||||
} else {
|
||||
debug_printf("couldn't reference all symbols in "
|
||||
DXTN_LIBNAME ", software DXTn compression/decompression "
|
||||
"unavailable");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Pixel fetch.
|
||||
*/
|
||||
|
||||
void
|
||||
util_format_dxt1_rgb_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||
{
|
||||
if (util_format_dxt1_rgb_fetch) {
|
||||
util_format_dxt1_rgb_fetch(0, src, i, j, dst);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||
{
|
||||
if (util_format_dxt1_rgba_fetch) {
|
||||
util_format_dxt1_rgba_fetch(0, src, i, j, dst);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt3_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||
{
|
||||
if (util_format_dxt3_rgba_fetch) {
|
||||
util_format_dxt3_rgba_fetch(0, src, i, j, dst);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt5_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||
{
|
||||
if (util_format_dxt5_rgba_fetch) {
|
||||
util_format_dxt5_rgba_fetch(0, src, i, j, dst);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_rgb_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||
{
|
||||
if (util_format_dxt1_rgb_fetch) {
|
||||
uint8_t tmp[4];
|
||||
util_format_dxt1_rgb_fetch(0, src, i, j, tmp);
|
||||
dst[0] = ubyte_to_float(tmp[0]);
|
||||
dst[1] = ubyte_to_float(tmp[1]);
|
||||
dst[2] = ubyte_to_float(tmp[2]);
|
||||
dst[3] = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||
{
|
||||
if (util_format_dxt1_rgba_fetch) {
|
||||
uint8_t tmp[4];
|
||||
util_format_dxt1_rgba_fetch(0, src, i, j, tmp);
|
||||
dst[0] = ubyte_to_float(tmp[0]);
|
||||
dst[1] = ubyte_to_float(tmp[1]);
|
||||
dst[2] = ubyte_to_float(tmp[2]);
|
||||
dst[3] = ubyte_to_float(tmp[3]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt3_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||
{
|
||||
if (util_format_dxt3_rgba_fetch) {
|
||||
uint8_t tmp[4];
|
||||
util_format_dxt3_rgba_fetch(0, src, i, j, tmp);
|
||||
dst[0] = ubyte_to_float(tmp[0]);
|
||||
dst[1] = ubyte_to_float(tmp[1]);
|
||||
dst[2] = ubyte_to_float(tmp[2]);
|
||||
dst[3] = ubyte_to_float(tmp[3]);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt5_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||
{
|
||||
if (util_format_dxt5_rgba_fetch) {
|
||||
uint8_t tmp[4];
|
||||
util_format_dxt5_rgba_fetch(0, src, i, j, tmp);
|
||||
dst[0] = ubyte_to_float(tmp[0]);
|
||||
dst[1] = ubyte_to_float(tmp[1]);
|
||||
dst[2] = ubyte_to_float(tmp[2]);
|
||||
dst[3] = ubyte_to_float(tmp[3]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Block decompression.
|
||||
*
|
||||
* FIXME
|
||||
*/
|
||||
|
||||
void
|
||||
util_format_dxt1_rgb_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt3_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt5_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_rgb_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
if (util_format_dxt1_rgb_fetch) {
|
||||
unsigned x, y, i, j;
|
||||
for(y = 0; y < height; y += 4) {
|
||||
const uint8_t *src = src_row;
|
||||
for(x = 0; x < width; x += 4) {
|
||||
for(j = 0; j < 4; ++j) {
|
||||
for(i = 0; i < 4; ++i) {
|
||||
float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
|
||||
uint8_t tmp[4];
|
||||
util_format_dxt1_rgb_fetch(0, src, i, j, tmp);
|
||||
dst[0] = ubyte_to_float(tmp[0]);
|
||||
dst[1] = ubyte_to_float(tmp[1]);
|
||||
dst[2] = ubyte_to_float(tmp[2]);
|
||||
dst[3] = 1.0;
|
||||
}
|
||||
}
|
||||
src += 8;
|
||||
}
|
||||
src_row += src_stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
if (util_format_dxt1_rgba_fetch) {
|
||||
unsigned x, y, i, j;
|
||||
for(y = 0; y < height; y += 4) {
|
||||
const uint8_t *src = src_row;
|
||||
for(x = 0; x < width; x += 4) {
|
||||
for(j = 0; j < 4; ++j) {
|
||||
for(i = 0; i < 4; ++i) {
|
||||
float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
|
||||
uint8_t tmp[4];
|
||||
util_format_dxt1_rgba_fetch(0, src, i, j, tmp);
|
||||
dst[0] = ubyte_to_float(tmp[0]);
|
||||
dst[1] = ubyte_to_float(tmp[1]);
|
||||
dst[2] = ubyte_to_float(tmp[2]);
|
||||
dst[3] = ubyte_to_float(tmp[3]);
|
||||
}
|
||||
}
|
||||
src += 8;
|
||||
}
|
||||
src_row += src_stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt3_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
if (util_format_dxt3_rgba_fetch) {
|
||||
unsigned x, y, i, j;
|
||||
for(y = 0; y < height; y += 4) {
|
||||
const uint8_t *src = src_row;
|
||||
for(x = 0; x < width; x += 4) {
|
||||
for(j = 0; j < 4; ++j) {
|
||||
for(i = 0; i < 4; ++i) {
|
||||
float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
|
||||
uint8_t tmp[4];
|
||||
util_format_dxt3_rgba_fetch(0, src, i, j, tmp);
|
||||
dst[0] = ubyte_to_float(tmp[0]);
|
||||
dst[1] = ubyte_to_float(tmp[1]);
|
||||
dst[2] = ubyte_to_float(tmp[2]);
|
||||
dst[3] = ubyte_to_float(tmp[3]);
|
||||
}
|
||||
}
|
||||
src += 16;
|
||||
}
|
||||
src_row += src_stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt5_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
if (util_format_dxt5_rgba_fetch) {
|
||||
unsigned x, y, i, j;
|
||||
for(y = 0; y < height; y += 4) {
|
||||
const uint8_t *src = src_row;
|
||||
for(x = 0; x < width; x += 4) {
|
||||
for(j = 0; j < 4; ++j) {
|
||||
for(i = 0; i < 4; ++i) {
|
||||
float *dst = dst_row + (y + j)*dst_stride/sizeof(*dst_row) + (x + i)*4;
|
||||
uint8_t tmp[4];
|
||||
util_format_dxt5_rgba_fetch(0, src, i, j, tmp);
|
||||
dst[0] = ubyte_to_float(tmp[0]);
|
||||
dst[1] = ubyte_to_float(tmp[1]);
|
||||
dst[2] = ubyte_to_float(tmp[2]);
|
||||
dst[3] = ubyte_to_float(tmp[3]);
|
||||
}
|
||||
}
|
||||
src += 16;
|
||||
}
|
||||
src_row += src_stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Block compression.
|
||||
*
|
||||
* FIXME
|
||||
*/
|
||||
|
||||
void
|
||||
util_format_dxt1_rgb_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt3_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt5_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_rgb_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt3_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt5_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* SRGB variants.
|
||||
*
|
||||
* FIXME: shunts to RGB for now
|
||||
*/
|
||||
|
||||
void
|
||||
util_format_dxt1_srgb_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
util_format_dxt1_rgb_unpack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_srgb_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
util_format_dxt1_rgb_pack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_srgb_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||
{
|
||||
util_format_dxt1_rgb_fetch_8unorm(dst, src, i, j);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_srgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
util_format_dxt1_rgba_unpack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_srgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
util_format_dxt1_rgba_pack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||
{
|
||||
util_format_dxt1_rgba_fetch_8unorm(dst, src, i, j);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt3_srgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
util_format_dxt3_rgba_unpack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt3_srgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
util_format_dxt3_rgba_pack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt3_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||
{
|
||||
util_format_dxt3_rgba_fetch_8unorm(dst, src, i, j);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt5_srgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
util_format_dxt5_rgba_unpack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt5_srgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
util_format_dxt5_rgba_pack_8unorm(dst_row, dst_stride, src_row, src_stride, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt5_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||
{
|
||||
util_format_dxt5_rgba_fetch_8unorm(dst, src, i, j);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_srgb_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
util_format_dxt1_rgb_unpack_float(dst_row, dst_stride, src_row, src_stride, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_srgb_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
util_format_dxt1_rgb_pack_float(dst_row, dst_stride, src_row, src_stride, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_srgb_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||
{
|
||||
util_format_dxt1_rgb_fetch_float(dst, src, i, j);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
util_format_dxt1_rgba_unpack_float(dst_row, dst_stride, src_row, src_stride, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
util_format_dxt1_rgba_pack_float(dst_row, dst_stride, src_row, src_stride, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt1_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||
{
|
||||
util_format_dxt1_rgba_fetch_float(dst, src, i, j);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt3_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
util_format_dxt3_rgba_unpack_float(dst_row, dst_stride, src_row, src_stride, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt3_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
util_format_dxt3_rgba_pack_float(dst_row, dst_stride, src_row, src_stride, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt3_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||
{
|
||||
util_format_dxt3_rgba_fetch_float(dst, src, i, j);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt5_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
util_format_dxt5_rgba_unpack_float(dst_row, dst_stride, src_row, src_stride, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt5_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height)
|
||||
{
|
||||
util_format_dxt5_rgba_pack_float(dst_row, dst_stride, src_row, src_stride, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
util_format_dxt5_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
|
||||
{
|
||||
util_format_dxt5_rgba_fetch_float(dst, src, i, j);
|
||||
}
|
||||
|
|
@ -0,0 +1,218 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2010 VMware, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER 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.
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#ifndef U_FORMAT_S3TC_H_
|
||||
#define U_FORMAT_S3TC_H_
|
||||
|
||||
|
||||
#include "pipe/p_compiler.h"
|
||||
|
||||
|
||||
enum util_format_dxtn {
|
||||
UTIL_FORMAT_DXT1_RGB = 0x83F0,
|
||||
UTIL_FORMAT_DXT1_RGBA = 0x83F1,
|
||||
UTIL_FORMAT_DXT3_RGBA = 0x83F2,
|
||||
UTIL_FORMAT_DXT5_RGBA = 0x83F3
|
||||
};
|
||||
|
||||
|
||||
typedef void
|
||||
(*util_format_dxtn_fetch_t)( int src_stride,
|
||||
const uint8_t *src,
|
||||
int col, int row,
|
||||
uint8_t *dst );
|
||||
|
||||
typedef void
|
||||
(*util_format_dxtn_pack_t)( int src_comps,
|
||||
int width, int height,
|
||||
const uint8_t *src,
|
||||
enum util_format_dxtn dst_format,
|
||||
uint8_t *dst,
|
||||
int dst_stride);
|
||||
|
||||
extern boolean util_format_s3tc_enabled;
|
||||
|
||||
extern util_format_dxtn_fetch_t util_format_dxt1_rgb_fetch;
|
||||
extern util_format_dxtn_fetch_t util_format_dxt1_rgba_fetch;
|
||||
extern util_format_dxtn_fetch_t util_format_dxt3_rgba_fetch;
|
||||
extern util_format_dxtn_fetch_t util_format_dxt5_rgba_fetch;
|
||||
|
||||
extern util_format_dxtn_pack_t util_format_dxtn_pack;
|
||||
|
||||
|
||||
void
|
||||
util_format_s3tc_init(void);
|
||||
|
||||
|
||||
void
|
||||
util_format_dxt1_rgb_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt1_rgb_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt1_rgb_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
|
||||
|
||||
void
|
||||
util_format_dxt1_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt1_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt1_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
|
||||
|
||||
void
|
||||
util_format_dxt3_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt3_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt3_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
|
||||
|
||||
void
|
||||
util_format_dxt5_rgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt5_rgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt5_rgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
|
||||
|
||||
void
|
||||
util_format_dxt1_srgb_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt1_srgb_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt1_srgb_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
|
||||
|
||||
void
|
||||
util_format_dxt1_srgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt1_srgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt1_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
|
||||
|
||||
void
|
||||
util_format_dxt3_srgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt3_srgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt3_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
|
||||
|
||||
void
|
||||
util_format_dxt5_srgba_unpack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt5_srgba_pack_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt5_srgba_fetch_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j);
|
||||
|
||||
|
||||
void
|
||||
util_format_dxt1_rgb_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt1_rgb_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt1_rgb_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
|
||||
|
||||
void
|
||||
util_format_dxt1_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt1_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt1_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
|
||||
|
||||
void
|
||||
util_format_dxt3_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt3_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt3_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
|
||||
|
||||
void
|
||||
util_format_dxt5_rgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt5_rgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt5_rgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
|
||||
|
||||
void
|
||||
util_format_dxt1_srgb_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt1_srgb_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt1_srgb_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
|
||||
|
||||
void
|
||||
util_format_dxt1_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt1_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt1_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
|
||||
|
||||
void
|
||||
util_format_dxt3_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt3_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt3_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
|
||||
|
||||
void
|
||||
util_format_dxt5_srgba_unpack_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt5_srgba_pack_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height);
|
||||
|
||||
void
|
||||
util_format_dxt5_srgba_fetch_float(float *dst, const uint8_t *src, unsigned i, unsigned j);
|
||||
|
||||
|
||||
#endif /* U_FORMAT_S3TC_H_ */
|
|
@ -3,7 +3,7 @@
|
|||
'''
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2009 VMware, Inc.
|
||||
* Copyright 2010 VMware, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
|
@ -33,6 +33,7 @@
|
|||
import sys
|
||||
|
||||
from u_format_parse import *
|
||||
import u_format_pack
|
||||
|
||||
|
||||
def layout_map(layout):
|
||||
|
@ -85,23 +86,11 @@ def write_format_table(formats):
|
|||
print __doc__.strip()
|
||||
print
|
||||
print '#include "u_format.h"'
|
||||
print '#include "u_format_s3tc.h"'
|
||||
print
|
||||
print 'const struct util_format_description'
|
||||
print 'util_format_none_description = {'
|
||||
print " PIPE_FORMAT_NONE,"
|
||||
print " \"PIPE_FORMAT_NONE\","
|
||||
print " \"none\","
|
||||
print " {0, 0, 0},"
|
||||
print " 0,"
|
||||
print " 0,"
|
||||
print " 0,"
|
||||
print " 0,"
|
||||
print " 0,"
|
||||
print " {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},"
|
||||
print " {0, 0, 0, 0},"
|
||||
print " 0"
|
||||
print "};"
|
||||
print
|
||||
|
||||
u_format_pack.generate(formats)
|
||||
|
||||
for format in formats:
|
||||
print 'const struct util_format_description'
|
||||
print 'util_format_%s_description = {' % (format.short_name(),)
|
||||
|
@ -140,8 +129,14 @@ def write_format_table(formats):
|
|||
print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment)
|
||||
print " },"
|
||||
print " %s," % (colorspace_map(format.colorspace),)
|
||||
print " &util_format_%s_unpack_8unorm," % format.short_name()
|
||||
print " &util_format_%s_pack_8unorm," % format.short_name()
|
||||
print " &util_format_%s_unpack_float," % format.short_name()
|
||||
print " &util_format_%s_pack_float," % format.short_name()
|
||||
print " &util_format_%s_fetch_float" % format.short_name()
|
||||
print "};"
|
||||
print
|
||||
|
||||
print "const struct util_format_description *"
|
||||
print "util_format_description(enum pipe_format format)"
|
||||
print "{"
|
||||
|
@ -150,8 +145,6 @@ def write_format_table(formats):
|
|||
print " }"
|
||||
print
|
||||
print " switch (format) {"
|
||||
print " case PIPE_FORMAT_NONE:"
|
||||
print " return &util_format_none_description;"
|
||||
for format in formats:
|
||||
print " case %s:" % format.name
|
||||
print " return &util_format_%s_description;" % (format.short_name(),)
|
||||
|
|
|
@ -120,12 +120,11 @@ util_format_test_cases[] =
|
|||
* 16-bit rendertarget formats
|
||||
*/
|
||||
|
||||
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x001f), {0.0, 0.0, 1.0, 0.0}},
|
||||
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x03e0), {0.0, 1.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x7c00), {1.0, 0.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x8000), {0.0, 0.0, 0.0, 1.0}},
|
||||
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0xffff), {1.0, 1.0, 1.0, 1.0}},
|
||||
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 1.0}},
|
||||
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x001f), {0.0, 0.0, 1.0, 1.0}},
|
||||
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x03e0), {0.0, 1.0, 0.0, 1.0}},
|
||||
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x7c00), {1.0, 0.0, 0.0, 1.0}},
|
||||
{PIPE_FORMAT_B5G5R5X1_UNORM, PACKED_1x16(0x7fff), PACKED_1x16(0x7fff), {1.0, 1.0, 1.0, 1.0}},
|
||||
|
||||
{PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x001f), {0.0, 0.0, 1.0, 0.0}},
|
||||
|
|
|
@ -88,7 +88,7 @@ mem_dup(const void *src, uint size)
|
|||
/**
|
||||
* Offset of a field in a struct, in bytes.
|
||||
*/
|
||||
#define Offset(TYPE, MEMBER) ((unsigned)&(((TYPE *)NULL)->MEMBER))
|
||||
#define Offset(TYPE, MEMBER) ((uintptr_t)&(((TYPE *)NULL)->MEMBER))
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -446,17 +446,17 @@ util_pack_z(enum pipe_format format, double z)
|
|||
return (uint) (z * 0xffffffff);
|
||||
case PIPE_FORMAT_Z32_FLOAT:
|
||||
return (uint)z;
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
if (z == 1.0)
|
||||
return 0xffffff;
|
||||
return (uint) (z * 0xffffff);
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
if (z == 1.0)
|
||||
return 0xffffff00;
|
||||
return ((uint) (z * 0xffffff)) << 8;
|
||||
case PIPE_FORMAT_S8_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED:
|
||||
/* this case can get it via util_pack_z_stencil() */
|
||||
return 0;
|
||||
default:
|
||||
|
@ -477,13 +477,13 @@ util_pack_z_stencil(enum pipe_format format, double z, uint s)
|
|||
unsigned packed = util_pack_z(format, z);
|
||||
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
packed |= s << 24;
|
||||
break;
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
packed |= s;
|
||||
break;
|
||||
case PIPE_FORMAT_S8_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED:
|
||||
packed |= s;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -108,436 +108,6 @@ pipe_put_tile_raw(struct pipe_context *pipe,
|
|||
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_B8G8R8A8_UNORM ***/
|
||||
|
||||
static void
|
||||
a8r8g8b8_get_tile_rgba(const unsigned *src,
|
||||
unsigned w, unsigned h,
|
||||
float *p,
|
||||
unsigned dst_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
const unsigned pixel = *src++;
|
||||
pRow[0] = ubyte_to_float((pixel >> 16) & 0xff);
|
||||
pRow[1] = ubyte_to_float((pixel >> 8) & 0xff);
|
||||
pRow[2] = ubyte_to_float((pixel >> 0) & 0xff);
|
||||
pRow[3] = ubyte_to_float((pixel >> 24) & 0xff);
|
||||
}
|
||||
p += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
a8r8g8b8_put_tile_rgba(unsigned *dst,
|
||||
unsigned w, unsigned h,
|
||||
const float *p,
|
||||
unsigned src_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
const float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
unsigned r, g, b, a;
|
||||
r = float_to_ubyte(pRow[0]);
|
||||
g = float_to_ubyte(pRow[1]);
|
||||
b = float_to_ubyte(pRow[2]);
|
||||
a = float_to_ubyte(pRow[3]);
|
||||
*dst++ = (a << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
p += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_B8G8R8X8_UNORM ***/
|
||||
|
||||
static void
|
||||
x8r8g8b8_get_tile_rgba(const unsigned *src,
|
||||
unsigned w, unsigned h,
|
||||
float *p,
|
||||
unsigned dst_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
const unsigned pixel = *src++;
|
||||
pRow[0] = ubyte_to_float((pixel >> 16) & 0xff);
|
||||
pRow[1] = ubyte_to_float((pixel >> 8) & 0xff);
|
||||
pRow[2] = ubyte_to_float((pixel >> 0) & 0xff);
|
||||
pRow[3] = 1.0F;
|
||||
}
|
||||
p += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
x8r8g8b8_put_tile_rgba(unsigned *dst,
|
||||
unsigned w, unsigned h,
|
||||
const float *p,
|
||||
unsigned src_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
const float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
unsigned r, g, b;
|
||||
r = float_to_ubyte(pRow[0]);
|
||||
g = float_to_ubyte(pRow[1]);
|
||||
b = float_to_ubyte(pRow[2]);
|
||||
*dst++ = (0xff << 24) | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
p += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_A8R8G8B8_UNORM ***/
|
||||
|
||||
static void
|
||||
b8g8r8a8_get_tile_rgba(const unsigned *src,
|
||||
unsigned w, unsigned h,
|
||||
float *p,
|
||||
unsigned dst_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
const unsigned pixel = *src++;
|
||||
pRow[0] = ubyte_to_float((pixel >> 8) & 0xff);
|
||||
pRow[1] = ubyte_to_float((pixel >> 16) & 0xff);
|
||||
pRow[2] = ubyte_to_float((pixel >> 24) & 0xff);
|
||||
pRow[3] = ubyte_to_float((pixel >> 0) & 0xff);
|
||||
}
|
||||
p += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
b8g8r8a8_put_tile_rgba(unsigned *dst,
|
||||
unsigned w, unsigned h,
|
||||
const float *p,
|
||||
unsigned src_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
const float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
unsigned r, g, b, a;
|
||||
r = float_to_ubyte(pRow[0]);
|
||||
g = float_to_ubyte(pRow[1]);
|
||||
b = float_to_ubyte(pRow[2]);
|
||||
a = float_to_ubyte(pRow[3]);
|
||||
*dst++ = (b << 24) | (g << 16) | (r << 8) | a;
|
||||
}
|
||||
p += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_A8B8G8R8_UNORM ***/
|
||||
|
||||
static void
|
||||
r8g8b8a8_get_tile_rgba(const unsigned *src,
|
||||
unsigned w, unsigned h,
|
||||
float *p,
|
||||
unsigned dst_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
const unsigned pixel = *src++;
|
||||
pRow[0] = ubyte_to_float((pixel >> 24) & 0xff);
|
||||
pRow[1] = ubyte_to_float((pixel >> 16) & 0xff);
|
||||
pRow[2] = ubyte_to_float((pixel >> 8) & 0xff);
|
||||
pRow[3] = ubyte_to_float((pixel >> 0) & 0xff);
|
||||
}
|
||||
p += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
r8g8b8a8_put_tile_rgba(unsigned *dst,
|
||||
unsigned w, unsigned h,
|
||||
const float *p,
|
||||
unsigned src_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
const float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
unsigned r, g, b, a;
|
||||
r = float_to_ubyte(pRow[0]);
|
||||
g = float_to_ubyte(pRow[1]);
|
||||
b = float_to_ubyte(pRow[2]);
|
||||
a = float_to_ubyte(pRow[3]);
|
||||
*dst++ = (r << 24) | (g << 16) | (b << 8) | a;
|
||||
}
|
||||
p += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_B5G5R5X1_UNORM ***/
|
||||
|
||||
static void
|
||||
x1r5g5b5_get_tile_rgba(const ushort *src,
|
||||
unsigned w, unsigned h,
|
||||
float *p,
|
||||
unsigned dst_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
const ushort pixel = *src++;
|
||||
pRow[0] = ((pixel >> 10) & 0x1f) * (1.0f / 31.0f);
|
||||
pRow[1] = ((pixel >> 5) & 0x1f) * (1.0f / 31.0f);
|
||||
pRow[2] = ((pixel ) & 0x1f) * (1.0f / 31.0f);
|
||||
pRow[3] = 1.0f;
|
||||
}
|
||||
p += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
x1r5g5b5_put_tile_rgba(ushort *dst,
|
||||
unsigned w, unsigned h,
|
||||
const float *p,
|
||||
unsigned src_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
const float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
unsigned r, g, b;
|
||||
r = float_to_ubyte(pRow[0]);
|
||||
g = float_to_ubyte(pRow[1]);
|
||||
b = float_to_ubyte(pRow[2]);
|
||||
r = r >> 3; /* 5 bits */
|
||||
g = g >> 3; /* 5 bits */
|
||||
b = b >> 3; /* 5 bits */
|
||||
*dst++ = (1 << 15) | (r << 10) | (g << 5) | b;
|
||||
}
|
||||
p += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_B5G5R5A1_UNORM ***/
|
||||
|
||||
static void
|
||||
a1r5g5b5_get_tile_rgba(const ushort *src,
|
||||
unsigned w, unsigned h,
|
||||
float *p,
|
||||
unsigned dst_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
const ushort pixel = *src++;
|
||||
pRow[0] = ((pixel >> 10) & 0x1f) * (1.0f / 31.0f);
|
||||
pRow[1] = ((pixel >> 5) & 0x1f) * (1.0f / 31.0f);
|
||||
pRow[2] = ((pixel ) & 0x1f) * (1.0f / 31.0f);
|
||||
pRow[3] = ((pixel >> 15) ) * 1.0f;
|
||||
}
|
||||
p += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
a1r5g5b5_put_tile_rgba(ushort *dst,
|
||||
unsigned w, unsigned h,
|
||||
const float *p,
|
||||
unsigned src_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
const float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
unsigned r, g, b, a;
|
||||
r = float_to_ubyte(pRow[0]);
|
||||
g = float_to_ubyte(pRow[1]);
|
||||
b = float_to_ubyte(pRow[2]);
|
||||
a = float_to_ubyte(pRow[3]);
|
||||
r = r >> 3; /* 5 bits */
|
||||
g = g >> 3; /* 5 bits */
|
||||
b = b >> 3; /* 5 bits */
|
||||
a = a >> 7; /* 1 bit */
|
||||
*dst++ = (a << 15) | (r << 10) | (g << 5) | b;
|
||||
}
|
||||
p += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_B4G4R4A4_UNORM ***/
|
||||
|
||||
static void
|
||||
a4r4g4b4_get_tile_rgba(const ushort *src,
|
||||
unsigned w, unsigned h,
|
||||
float *p,
|
||||
unsigned dst_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
const ushort pixel = *src++;
|
||||
pRow[0] = ((pixel >> 8) & 0xf) * (1.0f / 15.0f);
|
||||
pRow[1] = ((pixel >> 4) & 0xf) * (1.0f / 15.0f);
|
||||
pRow[2] = ((pixel ) & 0xf) * (1.0f / 15.0f);
|
||||
pRow[3] = ((pixel >> 12) ) * (1.0f / 15.0f);
|
||||
}
|
||||
p += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
a4r4g4b4_put_tile_rgba(ushort *dst,
|
||||
unsigned w, unsigned h,
|
||||
const float *p,
|
||||
unsigned src_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
const float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
unsigned r, g, b, a;
|
||||
r = float_to_ubyte(pRow[0]);
|
||||
g = float_to_ubyte(pRow[1]);
|
||||
b = float_to_ubyte(pRow[2]);
|
||||
a = float_to_ubyte(pRow[3]);
|
||||
r >>= 4;
|
||||
g >>= 4;
|
||||
b >>= 4;
|
||||
a >>= 4;
|
||||
*dst++ = (a << 12) | (r << 8) | (g << 4) | b;
|
||||
}
|
||||
p += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_B5G6R5_UNORM ***/
|
||||
|
||||
static void
|
||||
r5g6b5_get_tile_rgba(const ushort *src,
|
||||
unsigned w, unsigned h,
|
||||
float *p,
|
||||
unsigned dst_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
const ushort pixel = *src++;
|
||||
pRow[0] = ((pixel >> 11) & 0x1f) * (1.0f / 31.0f);
|
||||
pRow[1] = ((pixel >> 5) & 0x3f) * (1.0f / 63.0f);
|
||||
pRow[2] = ((pixel ) & 0x1f) * (1.0f / 31.0f);
|
||||
pRow[3] = 1.0f;
|
||||
}
|
||||
p += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
r5g6b5_put_tile_rgba(ushort *dst,
|
||||
unsigned w, unsigned h,
|
||||
const float *p,
|
||||
unsigned src_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
const float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
uint r = (uint) (CLAMP(pRow[0], 0.0, 1.0) * 31.0);
|
||||
uint g = (uint) (CLAMP(pRow[1], 0.0, 1.0) * 63.0);
|
||||
uint b = (uint) (CLAMP(pRow[2], 0.0, 1.0) * 31.0);
|
||||
*dst++ = (r << 11) | (g << 5) | (b);
|
||||
}
|
||||
p += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_R8G8B8_UNORM ***/
|
||||
|
||||
static void
|
||||
r8g8b8_get_tile_rgba(const ubyte *src,
|
||||
unsigned w, unsigned h,
|
||||
float *p,
|
||||
unsigned dst_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
pRow[0] = ubyte_to_float(src[0]);
|
||||
pRow[1] = ubyte_to_float(src[1]);
|
||||
pRow[2] = ubyte_to_float(src[2]);
|
||||
pRow[3] = 1.0f;
|
||||
src += 3;
|
||||
}
|
||||
p += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
r8g8b8_put_tile_rgba(ubyte *dst,
|
||||
unsigned w, unsigned h,
|
||||
const float *p,
|
||||
unsigned src_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
const float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
dst[0] = float_to_ubyte(pRow[0]);
|
||||
dst[1] = float_to_ubyte(pRow[1]);
|
||||
dst[2] = float_to_ubyte(pRow[2]);
|
||||
dst += 3;
|
||||
}
|
||||
p += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_Z16_UNORM ***/
|
||||
|
||||
/**
|
||||
|
@ -567,179 +137,6 @@ z16_get_tile_rgba(const ushort *src,
|
|||
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_L8_UNORM ***/
|
||||
|
||||
static void
|
||||
l8_get_tile_rgba(const ubyte *src,
|
||||
unsigned w, unsigned h,
|
||||
float *p,
|
||||
unsigned dst_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
float *pRow = p;
|
||||
for (j = 0; j < w; j++, src++, pRow += 4) {
|
||||
pRow[0] =
|
||||
pRow[1] =
|
||||
pRow[2] = ubyte_to_float(*src);
|
||||
pRow[3] = 1.0;
|
||||
}
|
||||
p += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
l8_put_tile_rgba(ubyte *dst,
|
||||
unsigned w, unsigned h,
|
||||
const float *p,
|
||||
unsigned src_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
const float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
unsigned r;
|
||||
r = float_to_ubyte(pRow[0]);
|
||||
*dst++ = (ubyte) r;
|
||||
}
|
||||
p += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_A8_UNORM ***/
|
||||
|
||||
static void
|
||||
a8_get_tile_rgba(const ubyte *src,
|
||||
unsigned w, unsigned h,
|
||||
float *p,
|
||||
unsigned dst_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
float *pRow = p;
|
||||
for (j = 0; j < w; j++, src++, pRow += 4) {
|
||||
pRow[0] =
|
||||
pRow[1] =
|
||||
pRow[2] = 0.0;
|
||||
pRow[3] = ubyte_to_float(*src);
|
||||
}
|
||||
p += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
a8_put_tile_rgba(ubyte *dst,
|
||||
unsigned w, unsigned h,
|
||||
const float *p,
|
||||
unsigned src_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
const float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
unsigned a;
|
||||
a = float_to_ubyte(pRow[3]);
|
||||
*dst++ = (ubyte) a;
|
||||
}
|
||||
p += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_R16_SNORM ***/
|
||||
|
||||
static void
|
||||
r16_get_tile_rgba(const short *src,
|
||||
unsigned w, unsigned h,
|
||||
float *p,
|
||||
unsigned dst_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
float *pRow = p;
|
||||
for (j = 0; j < w; j++, src++, pRow += 4) {
|
||||
pRow[0] = SHORT_TO_FLOAT(src[0]);
|
||||
pRow[1] =
|
||||
pRow[2] = 0.0;
|
||||
pRow[3] = 1.0;
|
||||
}
|
||||
p += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
r16_put_tile_rgba(short *dst,
|
||||
unsigned w, unsigned h,
|
||||
const float *p,
|
||||
unsigned src_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
const float *pRow = p;
|
||||
for (j = 0; j < w; j++, dst++, pRow += 4) {
|
||||
UNCLAMPED_FLOAT_TO_SHORT(dst[0], pRow[0]);
|
||||
}
|
||||
p += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_R16G16B16A16_SNORM ***/
|
||||
|
||||
static void
|
||||
r16g16b16a16_get_tile_rgba(const short *src,
|
||||
unsigned w, unsigned h,
|
||||
float *p,
|
||||
unsigned dst_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
float *pRow = p;
|
||||
for (j = 0; j < w; j++, src += 4, pRow += 4) {
|
||||
pRow[0] = SHORT_TO_FLOAT(src[0]);
|
||||
pRow[1] = SHORT_TO_FLOAT(src[1]);
|
||||
pRow[2] = SHORT_TO_FLOAT(src[2]);
|
||||
pRow[3] = SHORT_TO_FLOAT(src[3]);
|
||||
}
|
||||
p += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
r16g16b16a16_put_tile_rgba(short *dst,
|
||||
unsigned w, unsigned h,
|
||||
const float *p,
|
||||
unsigned src_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
const float *pRow = p;
|
||||
for (j = 0; j < w; j++, dst += 4, pRow += 4) {
|
||||
UNCLAMPED_FLOAT_TO_SHORT(dst[0], pRow[0]);
|
||||
UNCLAMPED_FLOAT_TO_SHORT(dst[1], pRow[1]);
|
||||
UNCLAMPED_FLOAT_TO_SHORT(dst[2], pRow[2]);
|
||||
UNCLAMPED_FLOAT_TO_SHORT(dst[3], pRow[3]);
|
||||
}
|
||||
p += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_A8B8G8R8_SRGB ***/
|
||||
|
||||
/**
|
||||
|
@ -919,96 +316,6 @@ l8_srgb_put_tile_rgba(ubyte *dst,
|
|||
}
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_I8_UNORM ***/
|
||||
|
||||
static void
|
||||
i8_get_tile_rgba(const ubyte *src,
|
||||
unsigned w, unsigned h,
|
||||
float *p,
|
||||
unsigned dst_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
float *pRow = p;
|
||||
for (j = 0; j < w; j++, src++, pRow += 4) {
|
||||
pRow[0] =
|
||||
pRow[1] =
|
||||
pRow[2] =
|
||||
pRow[3] = ubyte_to_float(*src);
|
||||
}
|
||||
p += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
i8_put_tile_rgba(ubyte *dst,
|
||||
unsigned w, unsigned h,
|
||||
const float *p,
|
||||
unsigned src_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
const float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
unsigned r;
|
||||
r = float_to_ubyte(pRow[0]);
|
||||
*dst++ = (ubyte) r;
|
||||
}
|
||||
p += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_L8A8_UNORM ***/
|
||||
|
||||
static void
|
||||
a8l8_get_tile_rgba(const ushort *src,
|
||||
unsigned w, unsigned h,
|
||||
float *p,
|
||||
unsigned dst_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
ushort p = *src++;
|
||||
pRow[0] =
|
||||
pRow[1] =
|
||||
pRow[2] = ubyte_to_float(p & 0xff);
|
||||
pRow[3] = ubyte_to_float(p >> 8);
|
||||
}
|
||||
p += dst_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
a8l8_put_tile_rgba(ushort *dst,
|
||||
unsigned w, unsigned h,
|
||||
const float *p,
|
||||
unsigned src_stride)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
const float *pRow = p;
|
||||
for (j = 0; j < w; j++, pRow += 4) {
|
||||
unsigned r, a;
|
||||
r = float_to_ubyte(pRow[0]);
|
||||
a = float_to_ubyte(pRow[3]);
|
||||
*dst++ = (a << 8) | r;
|
||||
}
|
||||
p += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_Z32_UNORM ***/
|
||||
|
||||
/**
|
||||
|
@ -1036,7 +343,7 @@ z32_get_tile_rgba(const unsigned *src,
|
|||
}
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_Z24S8_UNORM ***/
|
||||
/*** PIPE_FORMAT_Z24_UNORM_S8_USCALED ***/
|
||||
|
||||
/**
|
||||
* Return Z component as four float in [0,1]. Stencil part ignored.
|
||||
|
@ -1063,7 +370,7 @@ s8z24_get_tile_rgba(const unsigned *src,
|
|||
}
|
||||
|
||||
|
||||
/*** PIPE_FORMAT_S8Z24_UNORM ***/
|
||||
/*** PIPE_FORMAT_S8_USCALED_Z24_UNORM ***/
|
||||
|
||||
/**
|
||||
* Return Z component as four float in [0,1]. Stencil part ignored.
|
||||
|
@ -1211,51 +518,6 @@ pipe_tile_raw_to_rgba(enum pipe_format format,
|
|||
float *dst, unsigned dst_stride)
|
||||
{
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_B8G8R8A8_UNORM:
|
||||
a8r8g8b8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_B8G8R8X8_UNORM:
|
||||
x8r8g8b8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
||||
b8g8r8a8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_A8B8G8R8_UNORM:
|
||||
r8g8b8a8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_B5G5R5X1_UNORM:
|
||||
x1r5g5b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_B5G5R5A1_UNORM:
|
||||
a1r5g5b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_B4G4R4A4_UNORM:
|
||||
a4r4g4b4_get_tile_rgba((ushort *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_B5G6R5_UNORM:
|
||||
r5g6b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_R8G8B8_UNORM:
|
||||
r8g8b8_get_tile_rgba((ubyte *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_L8_UNORM:
|
||||
l8_get_tile_rgba((ubyte *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_A8_UNORM:
|
||||
a8_get_tile_rgba((ubyte *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_I8_UNORM:
|
||||
i8_get_tile_rgba((ubyte *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_L8A8_UNORM:
|
||||
a8l8_get_tile_rgba((ushort *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_R16_SNORM:
|
||||
r16_get_tile_rgba((short *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_R16G16B16A16_SNORM:
|
||||
r16g16b16a16_get_tile_rgba((short *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_B8G8R8A8_SRGB:
|
||||
a8r8g8b8_srgb_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
|
@ -1271,11 +533,11 @@ pipe_tile_raw_to_rgba(enum pipe_format format,
|
|||
case PIPE_FORMAT_Z32_UNORM:
|
||||
z32_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
s8z24_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
z24s8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride);
|
||||
break;
|
||||
|
@ -1408,51 +670,6 @@ pipe_put_tile_rgba(struct pipe_context *pipe,
|
|||
return;
|
||||
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_B8G8R8A8_UNORM:
|
||||
a8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_B8G8R8X8_UNORM:
|
||||
x8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
||||
b8g8r8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_A8B8G8R8_UNORM:
|
||||
r8g8b8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_B5G5R5X1_UNORM:
|
||||
x1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_B5G5R5A1_UNORM:
|
||||
a1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_B5G6R5_UNORM:
|
||||
r5g6b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_R8G8B8_UNORM:
|
||||
r8g8b8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_B4G4R4A4_UNORM:
|
||||
a4r4g4b4_put_tile_rgba((ushort *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_L8_UNORM:
|
||||
l8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_A8_UNORM:
|
||||
a8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_I8_UNORM:
|
||||
i8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_L8A8_UNORM:
|
||||
a8l8_put_tile_rgba((ushort *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_R16_SNORM:
|
||||
r16_put_tile_rgba((short *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_R16G16B16A16_SNORM:
|
||||
r16g16b16a16_put_tile_rgba((short *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
case PIPE_FORMAT_B8G8R8A8_SRGB:
|
||||
a8r8g8b8_srgb_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);
|
||||
break;
|
||||
|
@ -1468,11 +685,11 @@ pipe_put_tile_rgba(struct pipe_context *pipe,
|
|||
case PIPE_FORMAT_Z32_UNORM:
|
||||
/*z32_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
|
||||
break;
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
/*s8z24_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
|
||||
break;
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
/*z24s8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
|
||||
break;
|
||||
|
@ -1525,7 +742,7 @@ pipe_get_tile_z(struct pipe_context *pipe,
|
|||
}
|
||||
}
|
||||
break;
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
{
|
||||
const uint *ptrc
|
||||
|
@ -1540,7 +757,7 @@ pipe_get_tile_z(struct pipe_context *pipe,
|
|||
}
|
||||
}
|
||||
break;
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
{
|
||||
const uint *ptrc
|
||||
|
@ -1609,7 +826,7 @@ pipe_put_tile_z(struct pipe_context *pipe,
|
|||
}
|
||||
}
|
||||
break;
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
{
|
||||
uint *pDest = (uint *) (map + y * pt->stride + x*4);
|
||||
assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE);
|
||||
|
@ -1636,7 +853,7 @@ pipe_put_tile_z(struct pipe_context *pipe,
|
|||
}
|
||||
}
|
||||
break;
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
{
|
||||
uint *pDest = (uint *) (map + y * pt->stride + x*4);
|
||||
assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE);
|
||||
|
|
|
@ -138,7 +138,7 @@ ClearUnorderedAccessViewUint (D3D11 only)
|
|||
- Gallium does not support unordered access views (views that can be written to arbitrarily from compute shaders)
|
||||
|
||||
CreateBlendState (extended in D3D10.1) -> create_blend_state
|
||||
# D3D10 does not support per-RT blending, only D3D10.1 does
|
||||
# D3D10 does not support per-RT blend modes (but per-RT blending), only D3D10.1 does
|
||||
- Gallium lacks alpha-to-coverage
|
||||
+ Gallium supports logic ops
|
||||
+ Gallium supports dithering
|
||||
|
|
|
@ -81,8 +81,8 @@ point_quad_rasterization
|
|||
Determines if points should be rasterized as quads or points. Certain APIs,
|
||||
like Direct3D, always use quad rasterization for points, regardless of
|
||||
whether point sprites are enabled or not. If this state is enabled, point
|
||||
smoothing and antialiasing are disabled, and sprite coordinates are not
|
||||
generated.
|
||||
smoothing and antialiasing are disabled. If it is disabled, point sprite
|
||||
coordinates are not generated.
|
||||
|
||||
.. note::
|
||||
|
||||
|
|
|
@ -1859,7 +1859,7 @@ gen_depth_stencil(struct cell_context *cell,
|
|||
spe_comment(f, 0, "Fetch Z/stencil quad from tile");
|
||||
|
||||
switch(zs_format) {
|
||||
case PIPE_FORMAT_Z24S8_UNORM: /* fall through */
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED: /* fall through */
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
/* prepare mask to extract Z vals from ZS vals */
|
||||
spe_load_uint(f, zmask_reg, 0x00ffffff);
|
||||
|
@ -1880,7 +1880,7 @@ gen_depth_stencil(struct cell_context *cell,
|
|||
spe_rotmi(f, fbS_reg, fbZS_reg, -24);
|
||||
break;
|
||||
|
||||
case PIPE_FORMAT_S8Z24_UNORM: /* fall through */
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM: /* fall through */
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
/* convert fragment Z from [0,1] to 32-bit ints */
|
||||
spe_cfltu(f, fragZ_reg, fragZ_reg, 32);
|
||||
|
@ -1969,12 +1969,12 @@ gen_depth_stencil(struct cell_context *cell,
|
|||
* fbS_reg has four 8-bit Z values in bits [7..0].
|
||||
*/
|
||||
spe_comment(f, 0, "Store quad's depth/stencil values in tile");
|
||||
if (zs_format == PIPE_FORMAT_Z24S8_UNORM ||
|
||||
if (zs_format == PIPE_FORMAT_Z24_UNORM_S8_USCALED ||
|
||||
zs_format == PIPE_FORMAT_Z24X8_UNORM) {
|
||||
spe_shli(f, fbS_reg, fbS_reg, 24); /* fbS = fbS << 24 */
|
||||
spe_or(f, fbZS_reg, fbS_reg, fbZ_reg); /* fbZS = fbS | fbZ */
|
||||
}
|
||||
else if (zs_format == PIPE_FORMAT_S8Z24_UNORM ||
|
||||
else if (zs_format == PIPE_FORMAT_S8_USCALED_Z24_UNORM ||
|
||||
zs_format == PIPE_FORMAT_X8Z24_UNORM) {
|
||||
spe_shli(f, fbZ_reg, fbZ_reg, 8); /* fbZ = fbZ << 8 */
|
||||
spe_or(f, fbZS_reg, fbS_reg, fbZ_reg); /* fbZS = fbS | fbZ */
|
||||
|
@ -1985,7 +1985,7 @@ gen_depth_stencil(struct cell_context *cell,
|
|||
else if (zs_format == PIPE_FORMAT_Z16_UNORM) {
|
||||
spe_move(f, fbZS_reg, fbZ_reg); /* fbZS = fbZ */
|
||||
}
|
||||
else if (zs_format == PIPE_FORMAT_S8_UNORM) {
|
||||
else if (zs_format == PIPE_FORMAT_S8_USCALED) {
|
||||
ASSERT(0); /* XXX to do */
|
||||
}
|
||||
else {
|
||||
|
@ -2015,7 +2015,7 @@ gen_depth_stencil(struct cell_context *cell,
|
|||
* code before the fragment shader to cull fragments/quads that are
|
||||
* totally occluded/discarded.
|
||||
*
|
||||
* XXX we only support PIPE_FORMAT_S8Z24_UNORM z/stencil buffer right now.
|
||||
* XXX we only support PIPE_FORMAT_S8_USCALED_Z24_UNORM z/stencil buffer right now.
|
||||
*
|
||||
* See the spu_default_fragment_ops() function to see how the per-fragment
|
||||
* operations would be done with ordinary C code.
|
||||
|
|
|
@ -147,7 +147,7 @@ cell_is_format_supported( struct pipe_screen *screen,
|
|||
|
||||
/* only a few formats are known to work at this time */
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
case PIPE_FORMAT_B8G8R8A8_UNORM:
|
||||
case PIPE_FORMAT_I8_UNORM:
|
||||
|
|
|
@ -337,8 +337,8 @@ cmd_state_framebuffer(const struct cell_command_framebuffer *cmd)
|
|||
spu.fb.zsize = 4;
|
||||
spu.fb.zscale = (float) 0xffffffffu;
|
||||
break;
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
spu.fb.zsize = 4;
|
||||
|
|
|
@ -138,13 +138,13 @@ spu_fallback_fragment_ops(uint x, uint y,
|
|||
|
||||
if (spu.depth_stencil_alpha.stencil[0].enabled) {
|
||||
/* do stencil test */
|
||||
ASSERT(spu.fb.depth_format == PIPE_FORMAT_Z24S8_UNORM);
|
||||
ASSERT(spu.fb.depth_format == PIPE_FORMAT_Z24_UNORM_S8_USCALED);
|
||||
|
||||
}
|
||||
else if (spu.depth_stencil_alpha.depth.enabled) {
|
||||
/* do depth test */
|
||||
|
||||
ASSERT(spu.fb.depth_format == PIPE_FORMAT_Z24S8_UNORM ||
|
||||
ASSERT(spu.fb.depth_format == PIPE_FORMAT_Z24_UNORM_S8_USCALED ||
|
||||
spu.fb.depth_format == PIPE_FORMAT_Z24X8_UNORM);
|
||||
|
||||
vector unsigned int ifragZ;
|
||||
|
|
|
@ -178,13 +178,13 @@ i915_is_format_supported(struct pipe_screen *screen,
|
|||
PIPE_FORMAT_L8A8_UNORM,
|
||||
PIPE_FORMAT_UYVY,
|
||||
PIPE_FORMAT_YUYV,
|
||||
PIPE_FORMAT_Z24S8_UNORM,
|
||||
PIPE_FORMAT_Z24_UNORM_S8_USCALED,
|
||||
PIPE_FORMAT_NONE /* list terminator */
|
||||
};
|
||||
static const enum pipe_format surface_supported[] = {
|
||||
PIPE_FORMAT_B8G8R8A8_UNORM,
|
||||
PIPE_FORMAT_B5G6R5_UNORM,
|
||||
PIPE_FORMAT_Z24S8_UNORM,
|
||||
PIPE_FORMAT_Z24_UNORM_S8_USCALED,
|
||||
PIPE_FORMAT_NONE /* list terminator */
|
||||
};
|
||||
const enum pipe_format *list;
|
||||
|
|
|
@ -50,7 +50,7 @@ static unsigned translate_format( enum pipe_format format )
|
|||
static unsigned translate_depth_format( enum pipe_format zformat )
|
||||
{
|
||||
switch (zformat) {
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
return DEPTH_FRMT_24_FIXED_8_OTHER;
|
||||
case PIPE_FORMAT_Z16_UNORM:
|
||||
return DEPTH_FRMT_16_FIXED;
|
||||
|
|
|
@ -220,7 +220,7 @@ translate_texture_format(enum pipe_format pipeFormat)
|
|||
case PIPE_FORMAT_RGBA_DXT5:
|
||||
return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5);
|
||||
#endif
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
return (MAPSURF_32BIT | MT_32BIT_xI824);
|
||||
default:
|
||||
debug_printf("i915: translate_texture_format() bad image format %x\n",
|
||||
|
|
|
@ -266,7 +266,7 @@ static int emit_depthbuffer(struct brw_context *brw)
|
|||
cpp = 2;
|
||||
break;
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
format = BRW_DEPTHFORMAT_D24_UNORM_S8_UINT;
|
||||
cpp = 4;
|
||||
break;
|
||||
|
|
|
@ -140,7 +140,7 @@ static void zstencil_clear(struct brw_context *brw,
|
|||
|
||||
switch (bsurface->base.format) {
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
value = ((unsigned)(depth * MASK24) & MASK24);
|
||||
break;
|
||||
case PIPE_FORMAT_Z16_UNORM:
|
||||
|
@ -153,7 +153,7 @@ static void zstencil_clear(struct brw_context *brw,
|
|||
|
||||
switch (bsurface->base.format) {
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
value = value | (stencil << 24);
|
||||
break;
|
||||
|
||||
|
|
|
@ -252,7 +252,7 @@ brw_is_format_supported(struct pipe_screen *screen,
|
|||
/* depth */
|
||||
PIPE_FORMAT_Z32_FLOAT,
|
||||
PIPE_FORMAT_Z24X8_UNORM,
|
||||
PIPE_FORMAT_Z24S8_UNORM,
|
||||
PIPE_FORMAT_Z24_UNORM_S8_USCALED,
|
||||
PIPE_FORMAT_Z16_UNORM,
|
||||
/* signed */
|
||||
PIPE_FORMAT_R8G8_SNORM,
|
||||
|
@ -268,7 +268,7 @@ brw_is_format_supported(struct pipe_screen *screen,
|
|||
static const enum pipe_format depth_supported[] = {
|
||||
PIPE_FORMAT_Z32_FLOAT,
|
||||
PIPE_FORMAT_Z24X8_UNORM,
|
||||
PIPE_FORMAT_Z24S8_UNORM,
|
||||
PIPE_FORMAT_Z24_UNORM_S8_USCALED,
|
||||
PIPE_FORMAT_Z16_UNORM,
|
||||
PIPE_FORMAT_NONE /* list terminator */
|
||||
};
|
||||
|
|
|
@ -158,7 +158,7 @@ static GLuint translate_tex_format( enum pipe_format pf )
|
|||
case PIPE_FORMAT_Z16_UNORM:
|
||||
return BRW_SURFACEFORMAT_I16_UNORM;
|
||||
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
return BRW_SURFACEFORMAT_I24X8_UNORM;
|
||||
|
||||
|
@ -315,6 +315,7 @@ brw_texture_from_handle(struct pipe_screen *screen,
|
|||
struct brw_winsys_buffer *buffer;
|
||||
unsigned tiling;
|
||||
unsigned pitch;
|
||||
GLuint format;
|
||||
|
||||
if (templ->target != PIPE_TEXTURE_2D ||
|
||||
templ->last_level != 0 ||
|
||||
|
@ -362,8 +363,10 @@ brw_texture_from_handle(struct pipe_screen *screen,
|
|||
|
||||
tex->ss.ss0.mipmap_layout_mode = BRW_SURFACE_MIPMAPLAYOUT_BELOW;
|
||||
tex->ss.ss0.surface_type = translate_tex_target(tex->base.target);
|
||||
tex->ss.ss0.surface_format = translate_tex_format(tex->base.format);
|
||||
assert(tex->ss.ss0.surface_format != BRW_SURFACEFORMAT_INVALID);
|
||||
|
||||
format = translate_tex_format(tex->base.format);
|
||||
assert(format != BRW_SURFACEFORMAT_INVALID);
|
||||
tex->ss.ss0.surface_format = format;
|
||||
|
||||
/* This is ok for all textures with channel width 8bit or less:
|
||||
*/
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "id_drm.h"
|
||||
#include "id_screen.h"
|
||||
#include "id_public.h"
|
||||
#include "id_objects.h"
|
||||
|
||||
struct identity_drm_api
|
||||
{
|
||||
|
|
|
@ -42,7 +42,7 @@ C_SOURCES = \
|
|||
|
||||
CPP_SOURCES = \
|
||||
|
||||
PROGS := lp_test_format \
|
||||
PROGS := \
|
||||
lp_test_blend \
|
||||
lp_test_conv \
|
||||
lp_test_printf
|
||||
|
@ -50,7 +50,7 @@ PROGS := lp_test_format \
|
|||
|
||||
include ../../Makefile.template
|
||||
|
||||
lp_tile_soa.c: lp_tile_soa.py ../../auxiliary/util/u_format_parse.py ../../auxiliary/util/u_format_access.py ../../auxiliary/util/u_format.csv
|
||||
lp_tile_soa.c: lp_tile_soa.py ../../auxiliary/util/u_format_parse.py ../../auxiliary/util/u_format_pack.py ../../auxiliary/util/u_format.csv
|
||||
python lp_tile_soa.py ../../auxiliary/util/u_format.csv > $@
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ env.CodeGenerate(
|
|||
env.Depends('lp_tile_soa.c', [
|
||||
'#src/gallium/auxiliary/util/u_format_parse.py',
|
||||
'#src/gallium/auxiliary/util/u_format_pack.py',
|
||||
'#src/gallium/auxiliary/util/u_format_access.py',
|
||||
])
|
||||
|
||||
llvmpipe = env.ConvenienceLibrary(
|
||||
|
@ -70,7 +69,6 @@ if env['platform'] != 'embedded':
|
|||
env.Prepend(LIBS = [llvmpipe] + gallium)
|
||||
|
||||
tests = [
|
||||
'format',
|
||||
'blend',
|
||||
'conv',
|
||||
]
|
||||
|
|
|
@ -768,8 +768,12 @@ create_rast_threads(struct lp_rasterizer *rast)
|
|||
/* Multithreading not supported on windows until conditions and barriers are
|
||||
* properly implemented. */
|
||||
rast->num_threads = 0;
|
||||
#else
|
||||
#ifdef PIPE_OS_EMBEDDED
|
||||
rast->num_threads = 0;
|
||||
#else
|
||||
rast->num_threads = util_cpu_caps.nr_cpus;
|
||||
#endif
|
||||
rast->num_threads = debug_get_num_option("LP_NUM_THREADS", rast->num_threads);
|
||||
rast->num_threads = MIN2(rast->num_threads, MAX_THREADS);
|
||||
#endif
|
||||
|
|
|
@ -222,11 +222,7 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
|
|||
|
||||
/* FIXME: Temporary restrictions. See lp_bld_sample_soa.c */
|
||||
if(tex_usage & PIPE_TEXTURE_USAGE_SAMPLER) {
|
||||
if(format_desc->block.width != 1 ||
|
||||
format_desc->block.height != 1)
|
||||
return FALSE;
|
||||
|
||||
if(format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN)
|
||||
if(!format_desc->is_bitmask)
|
||||
return FALSE;
|
||||
|
||||
if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB &&
|
||||
|
|
|
@ -1,314 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2009 VMware, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER 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.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gallivm/lp_bld.h"
|
||||
#include <llvm-c/Analysis.h>
|
||||
#include <llvm-c/ExecutionEngine.h>
|
||||
#include <llvm-c/Target.h>
|
||||
#include <llvm-c/Transforms/Scalar.h>
|
||||
|
||||
#include "util/u_cpu_detect.h"
|
||||
#include "util/u_format.h"
|
||||
|
||||
#include "gallivm/lp_bld_format.h"
|
||||
#include "lp_test.h"
|
||||
|
||||
|
||||
struct pixel_test_case
|
||||
{
|
||||
enum pipe_format format;
|
||||
uint32_t packed;
|
||||
double unpacked[4];
|
||||
};
|
||||
|
||||
|
||||
struct pixel_test_case test_cases[] =
|
||||
{
|
||||
{PIPE_FORMAT_B5G6R5_UNORM, 0x0000, {0.0, 0.0, 0.0, 1.0}},
|
||||
{PIPE_FORMAT_B5G6R5_UNORM, 0x001f, {0.0, 0.0, 1.0, 1.0}},
|
||||
{PIPE_FORMAT_B5G6R5_UNORM, 0x07e0, {0.0, 1.0, 0.0, 1.0}},
|
||||
{PIPE_FORMAT_B5G6R5_UNORM, 0xf800, {1.0, 0.0, 0.0, 1.0}},
|
||||
{PIPE_FORMAT_B5G6R5_UNORM, 0xffff, {1.0, 1.0, 1.0, 1.0}},
|
||||
|
||||
{PIPE_FORMAT_B5G5R5A1_UNORM, 0x0000, {0.0, 0.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_B5G5R5A1_UNORM, 0x001f, {0.0, 0.0, 1.0, 0.0}},
|
||||
{PIPE_FORMAT_B5G5R5A1_UNORM, 0x03e0, {0.0, 1.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_B5G5R5A1_UNORM, 0x7c00, {1.0, 0.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_B5G5R5A1_UNORM, 0x8000, {0.0, 0.0, 0.0, 1.0}},
|
||||
{PIPE_FORMAT_B5G5R5A1_UNORM, 0xffff, {1.0, 1.0, 1.0, 1.0}},
|
||||
|
||||
{PIPE_FORMAT_B8G8R8A8_UNORM, 0x00000000, {0.0, 0.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_B8G8R8A8_UNORM, 0x000000ff, {0.0, 0.0, 1.0, 0.0}},
|
||||
{PIPE_FORMAT_B8G8R8A8_UNORM, 0x0000ff00, {0.0, 1.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_B8G8R8A8_UNORM, 0x00ff0000, {1.0, 0.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_B8G8R8A8_UNORM, 0xff000000, {0.0, 0.0, 0.0, 1.0}},
|
||||
{PIPE_FORMAT_B8G8R8A8_UNORM, 0xffffffff, {1.0, 1.0, 1.0, 1.0}},
|
||||
|
||||
#if 0
|
||||
{PIPE_FORMAT_R8G8B8A8_UNORM, 0x00000000, {0.0, 0.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_R8G8B8A8_UNORM, 0x000000ff, {0.0, 0.0, 0.0, 1.0}},
|
||||
{PIPE_FORMAT_R8G8B8A8_UNORM, 0x0000ff00, {0.0, 0.0, 1.0, 0.0}},
|
||||
{PIPE_FORMAT_R8G8B8A8_UNORM, 0x00ff0000, {0.0, 1.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_R8G8B8A8_UNORM, 0xff000000, {1.0, 0.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_R8G8B8A8_UNORM, 0xffffffff, {1.0, 1.0, 1.0, 1.0}},
|
||||
#endif
|
||||
|
||||
{PIPE_FORMAT_A8R8G8B8_UNORM, 0x00000000, {0.0, 0.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_A8R8G8B8_UNORM, 0x000000ff, {0.0, 0.0, 0.0, 1.0}},
|
||||
{PIPE_FORMAT_A8R8G8B8_UNORM, 0x0000ff00, {1.0, 0.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_A8R8G8B8_UNORM, 0x00ff0000, {0.0, 1.0, 0.0, 0.0}},
|
||||
{PIPE_FORMAT_A8R8G8B8_UNORM, 0xff000000, {0.0, 0.0, 1.0, 0.0}},
|
||||
{PIPE_FORMAT_A8R8G8B8_UNORM, 0xffffffff, {1.0, 1.0, 1.0, 1.0}},
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
write_tsv_header(FILE *fp)
|
||||
{
|
||||
fprintf(fp,
|
||||
"result\t"
|
||||
"format\n");
|
||||
|
||||
fflush(fp);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
write_tsv_row(FILE *fp,
|
||||
const struct util_format_description *desc,
|
||||
boolean success)
|
||||
{
|
||||
fprintf(fp, "%s\t", success ? "pass" : "fail");
|
||||
|
||||
fprintf(fp, "%s\n", desc->name);
|
||||
|
||||
fflush(fp);
|
||||
}
|
||||
|
||||
|
||||
typedef void (*load_ptr_t)(const uint32_t packed, float *);
|
||||
|
||||
|
||||
static LLVMValueRef
|
||||
add_load_rgba_test(LLVMModuleRef module,
|
||||
const struct util_format_description *desc)
|
||||
{
|
||||
LLVMTypeRef args[2];
|
||||
LLVMValueRef func;
|
||||
LLVMValueRef packed;
|
||||
LLVMValueRef rgba_ptr;
|
||||
LLVMBasicBlockRef block;
|
||||
LLVMBuilderRef builder;
|
||||
LLVMValueRef rgba;
|
||||
|
||||
args[0] = LLVMInt32Type();
|
||||
args[1] = LLVMPointerType(LLVMVectorType(LLVMFloatType(), 4), 0);
|
||||
|
||||
func = LLVMAddFunction(module, "load", LLVMFunctionType(LLVMVoidType(), args, 2, 0));
|
||||
LLVMSetFunctionCallConv(func, LLVMCCallConv);
|
||||
packed = LLVMGetParam(func, 0);
|
||||
rgba_ptr = LLVMGetParam(func, 1);
|
||||
|
||||
block = LLVMAppendBasicBlock(func, "entry");
|
||||
builder = LLVMCreateBuilder();
|
||||
LLVMPositionBuilderAtEnd(builder, block);
|
||||
|
||||
if(desc->block.bits < 32)
|
||||
packed = LLVMBuildTrunc(builder, packed, LLVMIntType(desc->block.bits), "");
|
||||
|
||||
rgba = lp_build_unpack_rgba_aos(builder, desc, packed);
|
||||
|
||||
LLVMBuildStore(builder, rgba, rgba_ptr);
|
||||
|
||||
LLVMBuildRetVoid(builder);
|
||||
|
||||
LLVMDisposeBuilder(builder);
|
||||
return func;
|
||||
}
|
||||
|
||||
|
||||
typedef void (*store_ptr_t)(uint32_t *, const float *);
|
||||
|
||||
|
||||
static LLVMValueRef
|
||||
add_store_rgba_test(LLVMModuleRef module,
|
||||
const struct util_format_description *desc)
|
||||
{
|
||||
LLVMTypeRef args[2];
|
||||
LLVMValueRef func;
|
||||
LLVMValueRef packed_ptr;
|
||||
LLVMValueRef rgba_ptr;
|
||||
LLVMBasicBlockRef block;
|
||||
LLVMBuilderRef builder;
|
||||
LLVMValueRef rgba;
|
||||
LLVMValueRef packed;
|
||||
|
||||
args[0] = LLVMPointerType(LLVMInt32Type(), 0);
|
||||
args[1] = LLVMPointerType(LLVMVectorType(LLVMFloatType(), 4), 0);
|
||||
|
||||
func = LLVMAddFunction(module, "store", LLVMFunctionType(LLVMVoidType(), args, 2, 0));
|
||||
LLVMSetFunctionCallConv(func, LLVMCCallConv);
|
||||
packed_ptr = LLVMGetParam(func, 0);
|
||||
rgba_ptr = LLVMGetParam(func, 1);
|
||||
|
||||
block = LLVMAppendBasicBlock(func, "entry");
|
||||
builder = LLVMCreateBuilder();
|
||||
LLVMPositionBuilderAtEnd(builder, block);
|
||||
|
||||
rgba = LLVMBuildLoad(builder, rgba_ptr, "");
|
||||
|
||||
packed = lp_build_pack_rgba_aos(builder, desc, rgba);
|
||||
|
||||
if(desc->block.bits < 32)
|
||||
packed = LLVMBuildZExt(builder, packed, LLVMInt32Type(), "");
|
||||
|
||||
LLVMBuildStore(builder, packed, packed_ptr);
|
||||
|
||||
LLVMBuildRetVoid(builder);
|
||||
|
||||
LLVMDisposeBuilder(builder);
|
||||
return func;
|
||||
}
|
||||
|
||||
|
||||
PIPE_ALIGN_STACK
|
||||
static boolean
|
||||
test_format(unsigned verbose, FILE *fp, const struct pixel_test_case *test)
|
||||
{
|
||||
LLVMModuleRef module = NULL;
|
||||
LLVMValueRef load = NULL;
|
||||
LLVMValueRef store = NULL;
|
||||
LLVMExecutionEngineRef engine = NULL;
|
||||
LLVMModuleProviderRef provider = NULL;
|
||||
LLVMPassManagerRef pass = NULL;
|
||||
char *error = NULL;
|
||||
const struct util_format_description *desc;
|
||||
load_ptr_t load_ptr;
|
||||
store_ptr_t store_ptr;
|
||||
float unpacked[4];
|
||||
unsigned packed;
|
||||
boolean success;
|
||||
unsigned i;
|
||||
|
||||
desc = util_format_description(test->format);
|
||||
fprintf(stderr, "%s\n", desc->name);
|
||||
|
||||
module = LLVMModuleCreateWithName("test");
|
||||
|
||||
load = add_load_rgba_test(module, desc);
|
||||
store = add_store_rgba_test(module, desc);
|
||||
|
||||
if(LLVMVerifyModule(module, LLVMPrintMessageAction, &error)) {
|
||||
LLVMDumpModule(module);
|
||||
abort();
|
||||
}
|
||||
LLVMDisposeMessage(error);
|
||||
|
||||
provider = LLVMCreateModuleProviderForExistingModule(module);
|
||||
if (LLVMCreateJITCompiler(&engine, provider, 1, &error)) {
|
||||
fprintf(stderr, "%s\n", error);
|
||||
LLVMDisposeMessage(error);
|
||||
abort();
|
||||
}
|
||||
|
||||
#if 0
|
||||
pass = LLVMCreatePassManager();
|
||||
LLVMAddTargetData(LLVMGetExecutionEngineTargetData(engine), pass);
|
||||
/* These are the passes currently listed in llvm-c/Transforms/Scalar.h,
|
||||
* but there are more on SVN. */
|
||||
LLVMAddConstantPropagationPass(pass);
|
||||
LLVMAddInstructionCombiningPass(pass);
|
||||
LLVMAddPromoteMemoryToRegisterPass(pass);
|
||||
LLVMAddGVNPass(pass);
|
||||
LLVMAddCFGSimplificationPass(pass);
|
||||
LLVMRunPassManager(pass, module);
|
||||
#else
|
||||
(void)pass;
|
||||
#endif
|
||||
|
||||
load_ptr = (load_ptr_t) LLVMGetPointerToGlobal(engine, load);
|
||||
store_ptr = (store_ptr_t)LLVMGetPointerToGlobal(engine, store);
|
||||
|
||||
memset(unpacked, 0, sizeof unpacked);
|
||||
packed = 0;
|
||||
|
||||
load_ptr(test->packed, unpacked);
|
||||
store_ptr(&packed, unpacked);
|
||||
|
||||
success = TRUE;
|
||||
if(test->packed != packed)
|
||||
success = FALSE;
|
||||
for(i = 0; i < 4; ++i)
|
||||
if(test->unpacked[i] != unpacked[i])
|
||||
success = FALSE;
|
||||
|
||||
if (!success) {
|
||||
printf("FAILED\n");
|
||||
printf(" Packed: %08x\n", test->packed);
|
||||
printf(" %08x\n", packed);
|
||||
printf(" Unpacked: %f %f %f %f\n", unpacked[0], unpacked[1], unpacked[2], unpacked[3]);
|
||||
printf(" %f %f %f %f\n", test->unpacked[0], test->unpacked[1], test->unpacked[2], test->unpacked[3]);
|
||||
LLVMDumpModule(module);
|
||||
}
|
||||
|
||||
LLVMFreeMachineCodeForFunction(engine, store);
|
||||
LLVMFreeMachineCodeForFunction(engine, load);
|
||||
|
||||
LLVMDisposeExecutionEngine(engine);
|
||||
if(pass)
|
||||
LLVMDisposePassManager(pass);
|
||||
|
||||
if(fp)
|
||||
write_tsv_row(fp, desc, success);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
boolean
|
||||
test_all(unsigned verbose, FILE *fp)
|
||||
{
|
||||
unsigned i;
|
||||
bool success = TRUE;
|
||||
|
||||
for (i = 0; i < sizeof(test_cases)/sizeof(test_cases[0]); ++i)
|
||||
if(!test_format(verbose, fp, &test_cases[i]))
|
||||
success = FALSE;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
boolean
|
||||
test_some(unsigned verbose, FILE *fp, unsigned long n)
|
||||
{
|
||||
return test_all(verbose, fp);
|
||||
}
|
|
@ -42,7 +42,7 @@ import os.path
|
|||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), '../../auxiliary/util'))
|
||||
|
||||
from u_format_access import *
|
||||
from u_format_pack import *
|
||||
|
||||
|
||||
def generate_format_read(format, dst_channel, dst_native_type, dst_suffix):
|
||||
|
@ -62,7 +62,7 @@ def generate_format_read(format, dst_channel, dst_native_type, dst_suffix):
|
|||
print ' for (x = 0; x < w; ++x) {'
|
||||
|
||||
names = ['']*4
|
||||
if format.colorspace == 'rgb':
|
||||
if format.colorspace in ('rgb', 'srgb'):
|
||||
for i in range(4):
|
||||
swizzle = format.swizzles[i]
|
||||
if swizzle < 4:
|
||||
|
@ -104,7 +104,7 @@ def generate_format_read(format, dst_channel, dst_native_type, dst_suffix):
|
|||
assert False
|
||||
|
||||
for i in range(4):
|
||||
if format.colorspace == 'rgb':
|
||||
if format.colorspace in ('rgb', 'srgb'):
|
||||
swizzle = format.swizzles[i]
|
||||
if swizzle < 4:
|
||||
value = names[swizzle]
|
||||
|
@ -134,7 +134,7 @@ def pack_rgba(format, src_channel, r, g, b, a):
|
|||
"""Return an expression for packing r, g, b, a into a pixel of the
|
||||
given format. Ex: '(b << 24) | (g << 16) | (r << 8) | (a << 0)'
|
||||
"""
|
||||
assert format.colorspace == 'rgb'
|
||||
assert format.colorspace in ('rgb', 'srgb')
|
||||
inv_swizzle = format.inv_swizzles()
|
||||
shift = 0
|
||||
expr = None
|
||||
|
@ -277,7 +277,7 @@ def generate_read(formats, dst_channel, dst_native_type, dst_suffix):
|
|||
print ' func = &lp_tile_%s_read_%s;' % (format.short_name(), dst_suffix)
|
||||
print ' break;'
|
||||
print ' default:'
|
||||
print ' debug_printf("unsupported format\\n");'
|
||||
print ' debug_printf("%s: unsupported format %s\\n", __FUNCTION__, util_format_name(format));'
|
||||
print ' return;'
|
||||
print ' }'
|
||||
print ' func(dst, (const uint8_t *)src, src_stride, x, y, w, h);'
|
||||
|
@ -304,7 +304,7 @@ def generate_write(formats, src_channel, src_native_type, src_suffix):
|
|||
print ' func = &lp_tile_%s_write_%s;' % (format.short_name(), src_suffix)
|
||||
print ' break;'
|
||||
print ' default:'
|
||||
print ' debug_printf("unsupported format\\n");'
|
||||
print ' debug_printf("%s: unsupported format %s\\n", __FUNCTION__, util_format_name(format));'
|
||||
print ' return;'
|
||||
print ' }'
|
||||
print ' func(src, (uint8_t *)dst, dst_stride, x, y, w, h);'
|
||||
|
@ -349,8 +349,6 @@ def main():
|
|||
print '};'
|
||||
print
|
||||
|
||||
generate_clamp()
|
||||
|
||||
channel = Channel(UNSIGNED, True, 8)
|
||||
native_type = 'uint8_t'
|
||||
suffix = '4ub'
|
||||
|
|
|
@ -89,14 +89,14 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
|
|||
case PIPE_FORMAT_Z32_FLOAT:
|
||||
tile_flags = 0x4800;
|
||||
break;
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
tile_flags = 0x1800;
|
||||
break;
|
||||
case PIPE_FORMAT_Z16_UNORM:
|
||||
tile_flags = 0x6c00;
|
||||
break;
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
tile_flags = 0x2800;
|
||||
break;
|
||||
case PIPE_FORMAT_R32G32B32A32_FLOAT:
|
||||
|
|
|
@ -51,9 +51,9 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen,
|
|||
if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) {
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_Z32_FLOAT:
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
|
@ -75,8 +75,8 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen,
|
|||
case PIPE_FORMAT_DXT1_RGBA:
|
||||
case PIPE_FORMAT_DXT3_RGBA:
|
||||
case PIPE_FORMAT_DXT5_RGBA:
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
case PIPE_FORMAT_Z32_FLOAT:
|
||||
case PIPE_FORMAT_R16G16B16A16_SNORM:
|
||||
case PIPE_FORMAT_R16G16B16A16_UNORM:
|
||||
|
|
|
@ -122,13 +122,13 @@ validate_fb(struct nv50_context *nv50)
|
|||
so_reloc (so, bo, fb->zsbuf->offset, NOUVEAU_BO_VRAM |
|
||||
NOUVEAU_BO_LOW | NOUVEAU_BO_RDWR, 0, 0);
|
||||
switch (fb->zsbuf->format) {
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
so_data(so, NV50TCL_ZETA_FORMAT_S8Z24_UNORM);
|
||||
break;
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
so_data(so, NV50TCL_ZETA_FORMAT_X8Z24_UNORM);
|
||||
break;
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
so_data(so, NV50TCL_ZETA_FORMAT_Z24S8_UNORM);
|
||||
break;
|
||||
case PIPE_FORMAT_Z32_FLOAT:
|
||||
|
|
|
@ -60,8 +60,8 @@ nv50_format(enum pipe_format format)
|
|||
/* only because we require src format == dst format: */
|
||||
case PIPE_FORMAT_R16G16_SNORM:
|
||||
case PIPE_FORMAT_R16G16_UNORM:
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
return NV50_2D_DST_FORMAT_A8R8G8B8_UNORM;
|
||||
case PIPE_FORMAT_L8A8_UNORM:
|
||||
case PIPE_FORMAT_B4G4R4A4_UNORM:
|
||||
|
|
|
@ -62,8 +62,8 @@ static const uint32_t nv50_texture_formats[PIPE_FORMAT_COUNT] =
|
|||
_(DXT3_RGBA, UNORM, C0, C1, C2, C3, DXT3),
|
||||
_(DXT5_RGBA, UNORM, C0, C1, C2, C3, DXT5),
|
||||
|
||||
_MIXED(S8Z24_UNORM, UINT, UNORM, UINT, UINT, C1, C1, C1, ONE, 24_8),
|
||||
_MIXED(Z24S8_UNORM, UNORM, UINT, UINT, UINT, C0, C0, C0, ONE, 8_24),
|
||||
_MIXED(S8_USCALED_Z24_UNORM, UINT, UNORM, UINT, UINT, C1, C1, C1, ONE, 24_8),
|
||||
_MIXED(Z24_UNORM_S8_USCALED, UNORM, UINT, UINT, UINT, C0, C0, C0, ONE, 8_24),
|
||||
|
||||
_(R16G16B16A16_SNORM, UNORM, C0, C1, C2, C3, 16_16_16_16),
|
||||
_(R16G16B16A16_UNORM, SNORM, C0, C1, C2, C3, 16_16_16_16),
|
||||
|
|
|
@ -25,7 +25,7 @@ nv04_surface_format(enum pipe_format format)
|
|||
case PIPE_FORMAT_B8G8R8X8_UNORM:
|
||||
case PIPE_FORMAT_B8G8R8A8_UNORM:
|
||||
return NV04_CONTEXT_SURFACES_2D_FORMAT_A8R8G8B8;
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
return NV04_CONTEXT_SURFACES_2D_FORMAT_Y32;
|
||||
default:
|
||||
|
@ -45,7 +45,7 @@ nv04_rect_format(enum pipe_format format)
|
|||
return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A16R5G6B5;
|
||||
case PIPE_FORMAT_B8G8R8X8_UNORM:
|
||||
case PIPE_FORMAT_B8G8R8A8_UNORM:
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
|
||||
default:
|
||||
|
|
|
@ -63,7 +63,7 @@ nv30_texture_formats[] = {
|
|||
_(I8_UNORM , L8 , S1, S1, S1, S1, X, X, X, X),
|
||||
_(L8A8_UNORM , A8L8 , S1, S1, S1, S1, X, X, X, Y),
|
||||
_(Z16_UNORM , R5G6B5 , S1, S1, S1, ONE, X, X, X, X),
|
||||
_(S8Z24_UNORM , A8R8G8B8, S1, S1, S1, ONE, X, X, X, X),
|
||||
_(S8_USCALED_Z24_UNORM , A8R8G8B8, S1, S1, S1, ONE, X, X, X, X),
|
||||
_(DXT1_RGB , DXT1 , S1, S1, S1, ONE, X, Y, Z, W),
|
||||
_(DXT1_RGBA , DXT1 , S1, S1, S1, S1, X, Y, Z, W),
|
||||
_(DXT3_RGBA , DXT3 , S1, S1, S1, S1, X, Y, Z, W),
|
||||
|
|
|
@ -81,7 +81,7 @@ nv40_texture_formats[] = {
|
|||
_(I8_UNORM , L8 , S1, S1, S1, S1, X, X, X, X, 0, 0, 0, 0),
|
||||
_(L8A8_UNORM , A8L8 , S1, S1, S1, S1, X, X, X, Y, 0, 0, 0, 0),
|
||||
_(Z16_UNORM , Z16 , S1, S1, S1, ONE, X, X, X, X, 0, 0, 0, 0),
|
||||
_(S8Z24_UNORM , Z24 , S1, S1, S1, ONE, X, X, X, X, 0, 0, 0, 0),
|
||||
_(S8_USCALED_Z24_UNORM , Z24 , S1, S1, S1, ONE, X, X, X, X, 0, 0, 0, 0),
|
||||
_(DXT1_RGB , DXT1 , S1, S1, S1, ONE, X, Y, Z, W, 0, 0, 0, 0),
|
||||
_(DXT1_RGBA , DXT1 , S1, S1, S1, S1, X, Y, Z, W, 0, 0, 0, 0),
|
||||
_(DXT3_RGBA , DXT3 , S1, S1, S1, S1, X, Y, Z, W, 0, 0, 0, 0),
|
||||
|
|
|
@ -133,7 +133,7 @@ nvfx_screen_surface_format_supported(struct pipe_screen *pscreen,
|
|||
} else
|
||||
if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) {
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
return TRUE;
|
||||
case PIPE_FORMAT_Z16_UNORM:
|
||||
|
@ -155,7 +155,7 @@ nvfx_screen_surface_format_supported(struct pipe_screen *pscreen,
|
|||
case PIPE_FORMAT_I8_UNORM:
|
||||
case PIPE_FORMAT_L8A8_UNORM:
|
||||
case PIPE_FORMAT_Z16_UNORM:
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
case PIPE_FORMAT_DXT1_RGB:
|
||||
case PIPE_FORMAT_DXT1_RGBA:
|
||||
case PIPE_FORMAT_DXT3_RGBA:
|
||||
|
|
|
@ -102,7 +102,7 @@ nvfx_state_framebuffer_validate(struct nvfx_context *nvfx)
|
|||
rt_format |= NV34TCL_RT_FORMAT_ZETA_Z16;
|
||||
zeta_bits = 16;
|
||||
break;
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
case 0:
|
||||
rt_format |= NV34TCL_RT_FORMAT_ZETA_Z24S8;
|
||||
|
|
|
@ -1556,6 +1556,26 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
# define R300_TX_FORMAT_32F_32F 0x1C
|
||||
# define R300_TX_FORMAT_32F_32F_32F_32F 0x1D
|
||||
# define R300_TX_FORMAT_W24_FP 0x1E
|
||||
# define R400_TX_FORMAT_ATI2N 0x1F
|
||||
|
||||
/* These need TX_FORMAT2_[0-15].TXFORMAT_MSB set.
|
||||
|
||||
My guess is the 10-bit formats are the 8-bit ones but with filtering being
|
||||
performed with the precision of 10 bits per channel. This makes sense
|
||||
with sRGB textures since the conversion to linear space reduces the precision
|
||||
significantly so the shader gets approximately the 8-bit precision
|
||||
in the end. It might also improve the quality of HDR rendering where
|
||||
high-precision filtering is desirable.
|
||||
|
||||
Again, this is guessed, the formats might mean something entirely else.
|
||||
The others should be fine. */
|
||||
# define R500_TX_FORMAT_X1 0x0
|
||||
# define R500_TX_FORMAT_X1_REV 0x1
|
||||
# define R500_TX_FORMAT_X10 0x2
|
||||
# define R500_TX_FORMAT_Y10X10 0x3
|
||||
# define R500_TX_FORMAT_W10Z10Y10X10 0x4
|
||||
# define R500_TX_FORMAT_ATI1N 0x5
|
||||
|
||||
|
||||
# define R300_TX_FORMAT_SIGNED_W (1 << 5)
|
||||
# define R300_TX_FORMAT_SIGNED_Z (1 << 6)
|
||||
|
|
|
@ -207,9 +207,14 @@ static boolean r300_is_format_supported(struct pipe_screen* screen,
|
|||
{
|
||||
uint32_t retval = 0;
|
||||
boolean is_r500 = r300_screen(screen)->caps->is_r500;
|
||||
boolean is_r400 = r300_screen(screen)->caps->is_r400;
|
||||
boolean is_z24 = format == PIPE_FORMAT_X8Z24_UNORM ||
|
||||
format == PIPE_FORMAT_S8Z24_UNORM;
|
||||
format == PIPE_FORMAT_S8_USCALED_Z24_UNORM;
|
||||
boolean is_color2101010 = format == PIPE_FORMAT_R10G10B10A2_UNORM;
|
||||
boolean is_ati1n = format == PIPE_FORMAT_RGTC1_UNORM ||
|
||||
format == PIPE_FORMAT_RGTC1_SNORM;
|
||||
boolean is_ati2n = format == PIPE_FORMAT_RGTC2_UNORM ||
|
||||
format == PIPE_FORMAT_RGTC2_SNORM;
|
||||
|
||||
if (target >= PIPE_MAX_TEXTURE_TYPES) {
|
||||
fprintf(stderr, "r300: Implementation error: Received bogus texture "
|
||||
|
@ -221,6 +226,10 @@ static boolean r300_is_format_supported(struct pipe_screen* screen,
|
|||
if ((usage & PIPE_TEXTURE_USAGE_SAMPLER) &&
|
||||
/* Z24 cannot be sampled from on non-r5xx. */
|
||||
(is_r500 || !is_z24) &&
|
||||
/* ATI1N is r5xx-only. */
|
||||
(is_r500 || !is_ati1n) &&
|
||||
/* ATI2N is supported on r4xx-r5xx. */
|
||||
(is_r400 || is_r500 || !is_ati2n) &&
|
||||
r300_is_sampler_format_supported(format)) {
|
||||
retval |= PIPE_TEXTURE_USAGE_SAMPLER;
|
||||
}
|
||||
|
|
|
@ -367,7 +367,6 @@ static INLINE uint16_t
|
|||
r300_translate_vertex_data_type(enum pipe_format format) {
|
||||
uint32_t result = 0;
|
||||
const struct util_format_description *desc;
|
||||
unsigned components = util_format_get_nr_components(format);
|
||||
|
||||
desc = util_format_description(format);
|
||||
|
||||
|
@ -380,17 +379,17 @@ r300_translate_vertex_data_type(enum pipe_format format) {
|
|||
switch (desc->channel[0].type) {
|
||||
/* Half-floats, floats, doubles */
|
||||
case UTIL_FORMAT_TYPE_FLOAT:
|
||||
switch (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0)) {
|
||||
switch (desc->channel[0].size) {
|
||||
case 16:
|
||||
/* XXX Supported only on RV350 and later. */
|
||||
if (components > 2) {
|
||||
if (desc->nr_channels > 2) {
|
||||
result = R300_DATA_TYPE_FLT16_4;
|
||||
} else {
|
||||
result = R300_DATA_TYPE_FLT16_2;
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
result = R300_DATA_TYPE_FLOAT_1 + (components - 1);
|
||||
result = R300_DATA_TYPE_FLOAT_1 + (desc->nr_channels - 1);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "r300: Bad format %s in %s:%d\n",
|
||||
|
@ -402,12 +401,12 @@ r300_translate_vertex_data_type(enum pipe_format format) {
|
|||
case UTIL_FORMAT_TYPE_UNSIGNED:
|
||||
/* Signed ints */
|
||||
case UTIL_FORMAT_TYPE_SIGNED:
|
||||
switch (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0)) {
|
||||
switch (desc->channel[0].size) {
|
||||
case 8:
|
||||
result = R300_DATA_TYPE_BYTE;
|
||||
break;
|
||||
case 16:
|
||||
if (components > 2) {
|
||||
if (desc->nr_channels > 2) {
|
||||
result = R300_DATA_TYPE_SHORT_4;
|
||||
} else {
|
||||
result = R300_DATA_TYPE_SHORT_2;
|
||||
|
@ -416,8 +415,8 @@ r300_translate_vertex_data_type(enum pipe_format format) {
|
|||
default:
|
||||
fprintf(stderr, "r300: Bad format %s in %s:%d\n",
|
||||
util_format_name(format), __FUNCTION__, __LINE__);
|
||||
fprintf(stderr, "r300: util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) == %d\n",
|
||||
util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0));
|
||||
fprintf(stderr, "r300: desc->channel[0].size == %d\n",
|
||||
desc->channel[0].size);
|
||||
assert(0);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
#include "r300_state_inlines.h"
|
||||
#include "r300_winsys.h"
|
||||
|
||||
/* XXX Enable float textures here. */
|
||||
/*#define ENABLE_FLOAT_TEXTURES*/
|
||||
|
||||
#define TILE_WIDTH 0
|
||||
#define TILE_HEIGHT 1
|
||||
|
||||
|
@ -73,7 +76,7 @@ static uint32_t r300_translate_texformat(enum pipe_format format)
|
|||
{
|
||||
uint32_t result = 0;
|
||||
const struct util_format_description *desc;
|
||||
unsigned components = 0, i;
|
||||
unsigned i;
|
||||
boolean uniform = TRUE;
|
||||
const uint32_t swizzle_shift[4] = {
|
||||
R300_TX_FORMAT_R_SHIFT,
|
||||
|
@ -104,7 +107,7 @@ static uint32_t r300_translate_texformat(enum pipe_format format)
|
|||
case PIPE_FORMAT_Z16_UNORM:
|
||||
return R300_EASY_TX_FORMAT(X, X, X, X, X16);
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
return R300_EASY_TX_FORMAT(X, X, X, X, W24_FP);
|
||||
default:
|
||||
return ~0; /* Unsupported. */
|
||||
|
@ -158,7 +161,7 @@ static uint32_t r300_translate_texformat(enum pipe_format format)
|
|||
}
|
||||
}
|
||||
|
||||
/* Compressed formats. */
|
||||
/* S3TC formats. */
|
||||
if (desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_DXT1_RGB:
|
||||
|
@ -177,28 +180,35 @@ static uint32_t r300_translate_texformat(enum pipe_format format)
|
|||
}
|
||||
}
|
||||
|
||||
/* Get the number of components. */
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) {
|
||||
++components;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add sign. */
|
||||
for (i = 0; i < components; i++) {
|
||||
for (i = 0; i < desc->nr_channels; i++) {
|
||||
if (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED) {
|
||||
result |= sign_bit[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* RGTC formats. */
|
||||
if (desc->layout == UTIL_FORMAT_LAYOUT_RGTC) {
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_RGTC1_UNORM:
|
||||
case PIPE_FORMAT_RGTC1_SNORM:
|
||||
return R500_TX_FORMAT_ATI1N | result;
|
||||
case PIPE_FORMAT_RGTC2_UNORM:
|
||||
case PIPE_FORMAT_RGTC2_SNORM:
|
||||
return R400_TX_FORMAT_ATI2N | result;
|
||||
default:
|
||||
return ~0; /* Unsupported/unknown. */
|
||||
}
|
||||
}
|
||||
|
||||
/* See whether the components are of the same size. */
|
||||
for (i = 1; i < components; i++) {
|
||||
for (i = 1; i < desc->nr_channels; i++) {
|
||||
uniform = uniform && desc->channel[0].size == desc->channel[i].size;
|
||||
}
|
||||
|
||||
/* Non-uniform formats. */
|
||||
if (!uniform) {
|
||||
switch (components) {
|
||||
switch (desc->nr_channels) {
|
||||
case 3:
|
||||
if (desc->channel[0].size == 5 &&
|
||||
desc->channel[1].size == 6 &&
|
||||
|
@ -240,7 +250,7 @@ static uint32_t r300_translate_texformat(enum pipe_format format)
|
|||
|
||||
switch (desc->channel[0].size) {
|
||||
case 4:
|
||||
switch (components) {
|
||||
switch (desc->nr_channels) {
|
||||
case 2:
|
||||
return R300_TX_FORMAT_Y4X4 | result;
|
||||
case 4:
|
||||
|
@ -249,7 +259,7 @@ static uint32_t r300_translate_texformat(enum pipe_format format)
|
|||
return ~0;
|
||||
|
||||
case 8:
|
||||
switch (components) {
|
||||
switch (desc->nr_channels) {
|
||||
case 1:
|
||||
return R300_TX_FORMAT_X8 | result;
|
||||
case 2:
|
||||
|
@ -260,7 +270,7 @@ static uint32_t r300_translate_texformat(enum pipe_format format)
|
|||
return ~0;
|
||||
|
||||
case 16:
|
||||
switch (components) {
|
||||
switch (desc->nr_channels) {
|
||||
case 1:
|
||||
return R300_TX_FORMAT_X16 | result;
|
||||
case 2:
|
||||
|
@ -271,12 +281,11 @@ static uint32_t r300_translate_texformat(enum pipe_format format)
|
|||
}
|
||||
return ~0;
|
||||
|
||||
/* XXX Enable float textures here. */
|
||||
#if 0
|
||||
#if defined(ENABLE_FLOAT_TEXTURES)
|
||||
case UTIL_FORMAT_TYPE_FLOAT:
|
||||
switch (desc->channel[0].size) {
|
||||
case 16:
|
||||
switch (components) {
|
||||
switch (desc->nr_channels) {
|
||||
case 1:
|
||||
return R300_TX_FORMAT_16F | result;
|
||||
case 2:
|
||||
|
@ -287,7 +296,7 @@ static uint32_t r300_translate_texformat(enum pipe_format format)
|
|||
return ~0;
|
||||
|
||||
case 32:
|
||||
switch (components) {
|
||||
switch (desc->nr_channels) {
|
||||
case 1:
|
||||
return R300_TX_FORMAT_32F | result;
|
||||
case 2:
|
||||
|
@ -302,6 +311,17 @@ static uint32_t r300_translate_texformat(enum pipe_format format)
|
|||
return ~0; /* Unsupported/unknown. */
|
||||
}
|
||||
|
||||
static uint32_t r500_tx_format_msb_bit(enum pipe_format format)
|
||||
{
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_RGTC1_UNORM:
|
||||
case PIPE_FORMAT_RGTC1_SNORM:
|
||||
return R500_TXFORMAT_MSB;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Buffer formats. */
|
||||
|
||||
/* Colorbuffer formats. This is the unswizzled format of the RB3D block's
|
||||
|
@ -342,12 +362,13 @@ static uint32_t r300_translate_colorformat(enum pipe_format format)
|
|||
/* 64-bit buffers. */
|
||||
case PIPE_FORMAT_R16G16B16A16_UNORM:
|
||||
case PIPE_FORMAT_R16G16B16A16_SNORM:
|
||||
//case PIPE_FORMAT_R16G16B16A16_FLOAT: /* not in pipe_format */
|
||||
#if defined(ENABLE_FLOAT_TEXTURES)
|
||||
case PIPE_FORMAT_R16G16B16A16_FLOAT:
|
||||
#endif
|
||||
return R300_COLOR_FORMAT_ARGB16161616;
|
||||
|
||||
/* XXX Enable float textures here. */
|
||||
#if 0
|
||||
/* 128-bit buffers. */
|
||||
#if defined(ENABLE_FLOAT_TEXTURES)
|
||||
case PIPE_FORMAT_R32G32B32A32_FLOAT:
|
||||
return R300_COLOR_FORMAT_ARGB32323232;
|
||||
#endif
|
||||
|
@ -372,7 +393,7 @@ static uint32_t r300_translate_zsformat(enum pipe_format format)
|
|||
/* 24-bit depth, ignored stencil */
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
/* 24-bit depth, 8-bit stencil */
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
return R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL;
|
||||
default:
|
||||
return ~0; /* Unsupported. */
|
||||
|
@ -527,6 +548,7 @@ static void r300_setup_texture_state(struct r300_screen* screen, struct r300_tex
|
|||
if (pt->height0 > 2048) {
|
||||
state->format2 |= R500_TXHEIGHT_BIT11;
|
||||
}
|
||||
state->format2 |= r500_tx_format_msb_bit(pt->format);
|
||||
}
|
||||
|
||||
SCREEN_DBG(screen, DBG_TEX, "r300: Set texture state (%dx%d, %d levels)\n",
|
||||
|
|
|
@ -75,7 +75,7 @@ get_depth_stencil_values( struct depth_data *data,
|
|||
}
|
||||
break;
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
for (j = 0; j < QUAD_SIZE; j++) {
|
||||
int x = quad->input.x0 % TILE_SIZE + (j & 1);
|
||||
int y = quad->input.y0 % TILE_SIZE + (j >> 1);
|
||||
|
@ -84,7 +84,7 @@ get_depth_stencil_values( struct depth_data *data,
|
|||
}
|
||||
break;
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
for (j = 0; j < QUAD_SIZE; j++) {
|
||||
int x = quad->input.x0 % TILE_SIZE + (j & 1);
|
||||
int y = quad->input.y0 % TILE_SIZE + (j >> 1);
|
||||
|
@ -153,7 +153,7 @@ convert_quad_depth( struct depth_data *data,
|
|||
}
|
||||
break;
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
{
|
||||
float scale = (float) ((1 << 24) - 1);
|
||||
|
||||
|
@ -163,7 +163,7 @@ convert_quad_depth( struct depth_data *data,
|
|||
}
|
||||
break;
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
{
|
||||
float scale = (float) ((1 << 24) - 1);
|
||||
|
||||
|
@ -206,14 +206,14 @@ write_depth_stencil_values( struct depth_data *data,
|
|||
tile->data.depth32[y][x] = data->bzzzz[j];
|
||||
}
|
||||
break;
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
for (j = 0; j < QUAD_SIZE; j++) {
|
||||
int x = quad->input.x0 % TILE_SIZE + (j & 1);
|
||||
int y = quad->input.y0 % TILE_SIZE + (j >> 1);
|
||||
tile->data.depth32[y][x] = (data->stencilVals[j] << 24) | data->bzzzz[j];
|
||||
}
|
||||
break;
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
for (j = 0; j < QUAD_SIZE; j++) {
|
||||
int x = quad->input.x0 % TILE_SIZE + (j & 1);
|
||||
int y = quad->input.y0 % TILE_SIZE + (j >> 1);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_format_s3tc.h"
|
||||
#include "pipe/p_defines.h"
|
||||
#include "pipe/p_screen.h"
|
||||
|
||||
|
@ -155,20 +156,20 @@ softpipe_is_format_supported( struct pipe_screen *screen,
|
|||
target == PIPE_TEXTURE_CUBE);
|
||||
|
||||
switch(format) {
|
||||
case PIPE_FORMAT_L16_UNORM:
|
||||
case PIPE_FORMAT_YUYV:
|
||||
case PIPE_FORMAT_UYVY:
|
||||
return FALSE;
|
||||
|
||||
case PIPE_FORMAT_DXT1_RGB:
|
||||
case PIPE_FORMAT_DXT1_RGBA:
|
||||
case PIPE_FORMAT_DXT3_RGBA:
|
||||
case PIPE_FORMAT_DXT5_RGBA:
|
||||
return util_format_s3tc_enabled;
|
||||
|
||||
case PIPE_FORMAT_Z32_FLOAT:
|
||||
case PIPE_FORMAT_R8G8_SNORM:
|
||||
case PIPE_FORMAT_R5SG5SB6U_NORM:
|
||||
case PIPE_FORMAT_R8SG8SB8UX8U_NORM:
|
||||
case PIPE_FORMAT_R8G8B8A8_SNORM:
|
||||
case PIPE_FORMAT_NONE:
|
||||
return FALSE;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -240,6 +241,8 @@ softpipe_create_screen(struct sw_winsys *winsys)
|
|||
screen->base.context_create = softpipe_create_context;
|
||||
screen->base.flush_frontbuffer = softpipe_flush_frontbuffer;
|
||||
|
||||
util_format_s3tc_init();
|
||||
|
||||
softpipe_init_screen_texture_funcs(&screen->base);
|
||||
softpipe_init_screen_buffer_funcs(&screen->base);
|
||||
softpipe_init_screen_fence_funcs(&screen->base);
|
||||
|
|
|
@ -158,13 +158,13 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
|
|||
PIPE_TRANSFER_READ_WRITE,
|
||||
0, 0, ps->width, ps->height);
|
||||
|
||||
tc->depth_stencil = (ps->format == PIPE_FORMAT_Z24S8_UNORM ||
|
||||
tc->depth_stencil = (ps->format == PIPE_FORMAT_Z24_UNORM_S8_USCALED ||
|
||||
ps->format == PIPE_FORMAT_Z24X8_UNORM ||
|
||||
ps->format == PIPE_FORMAT_S8Z24_UNORM ||
|
||||
ps->format == PIPE_FORMAT_S8_USCALED_Z24_UNORM ||
|
||||
ps->format == PIPE_FORMAT_X8Z24_UNORM ||
|
||||
ps->format == PIPE_FORMAT_Z16_UNORM ||
|
||||
ps->format == PIPE_FORMAT_Z32_UNORM ||
|
||||
ps->format == PIPE_FORMAT_S8_UNORM);
|
||||
ps->format == PIPE_FORMAT_S8_USCALED);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ try_clear(struct svga_context *svga,
|
|||
if ((buffers & PIPE_CLEAR_DEPTHSTENCIL) && fb->zsbuf) {
|
||||
flags |= SVGA3D_CLEAR_DEPTH;
|
||||
|
||||
if (svga->curr.framebuffer.zsbuf->format == PIPE_FORMAT_S8Z24_UNORM)
|
||||
if (svga->curr.framebuffer.zsbuf->format == PIPE_FORMAT_S8_USCALED_Z24_UNORM)
|
||||
flags |= SVGA3D_CLEAR_STENCIL;
|
||||
|
||||
rect.w = MAX2(rect.w, fb->zsbuf->width);
|
||||
|
|
|
@ -118,9 +118,9 @@ static void svga_set_framebuffer_state(struct pipe_context *pipe,
|
|||
case PIPE_FORMAT_Z16_UNORM:
|
||||
svga->curr.depthscale = 1.0f / DEPTH_BIAS_SCALE_FACTOR_D16;
|
||||
break;
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
svga->curr.depthscale = 1.0f / DEPTH_BIAS_SCALE_FACTOR_D24S8;
|
||||
break;
|
||||
|
|
|
@ -210,7 +210,7 @@ svga_translate_format_cap(enum pipe_format format)
|
|||
|
||||
case PIPE_FORMAT_Z16_UNORM:
|
||||
return SVGA3D_DEVCAP_SURFACEFMT_Z_D16;
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
return SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8;
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
return SVGA3D_DEVCAP_SURFACEFMT_Z_D24X8;
|
||||
|
|
|
@ -81,7 +81,7 @@ svga_translate_format(enum pipe_format format)
|
|||
*/
|
||||
case PIPE_FORMAT_Z16_UNORM:
|
||||
return SVGA3D_Z_D16;
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
return SVGA3D_Z_D24S8;
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
return SVGA3D_Z_D24X8;
|
||||
|
@ -114,7 +114,7 @@ svga_translate_format_render(enum pipe_format format)
|
|||
case PIPE_FORMAT_B5G5R5A1_UNORM:
|
||||
case PIPE_FORMAT_B4G4R4A4_UNORM:
|
||||
case PIPE_FORMAT_B5G6R5_UNORM:
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
case PIPE_FORMAT_Z32_UNORM:
|
||||
case PIPE_FORMAT_Z16_UNORM:
|
||||
|
|
|
@ -70,7 +70,7 @@ static int emit_framebuffer( struct svga_context *svga,
|
|||
return ret;
|
||||
|
||||
if (curr->zsbuf &&
|
||||
curr->zsbuf->format == PIPE_FORMAT_S8Z24_UNORM) {
|
||||
curr->zsbuf->format == PIPE_FORMAT_S8_USCALED_Z24_UNORM) {
|
||||
ret = SVGA3D_SetRenderTarget(svga->swc, SVGA3D_RT_STENCIL, curr->zsbuf);
|
||||
if (ret != PIPE_OK)
|
||||
return ret;
|
||||
|
|
|
@ -44,120 +44,140 @@ extern "C" {
|
|||
*/
|
||||
|
||||
enum pipe_format {
|
||||
PIPE_FORMAT_NONE = 0,
|
||||
PIPE_FORMAT_B8G8R8A8_UNORM = 1,
|
||||
PIPE_FORMAT_B8G8R8X8_UNORM = 2,
|
||||
PIPE_FORMAT_A8R8G8B8_UNORM = 3,
|
||||
PIPE_FORMAT_X8R8G8B8_UNORM = 4,
|
||||
PIPE_FORMAT_B5G5R5A1_UNORM = 5,
|
||||
PIPE_FORMAT_B4G4R4A4_UNORM = 6,
|
||||
PIPE_FORMAT_B5G6R5_UNORM = 7,
|
||||
PIPE_FORMAT_R10G10B10A2_UNORM = 8,
|
||||
PIPE_FORMAT_L8_UNORM = 9, /**< ubyte luminance */
|
||||
PIPE_FORMAT_A8_UNORM = 10, /**< ubyte alpha */
|
||||
PIPE_FORMAT_I8_UNORM = 11, /**< ubyte intensity */
|
||||
PIPE_FORMAT_L8A8_UNORM = 12, /**< ubyte alpha, luminance */
|
||||
PIPE_FORMAT_L16_UNORM = 13, /**< ushort luminance */
|
||||
PIPE_FORMAT_UYVY = 14,
|
||||
PIPE_FORMAT_YUYV = 15,
|
||||
PIPE_FORMAT_Z16_UNORM = 16,
|
||||
PIPE_FORMAT_Z32_UNORM = 17,
|
||||
PIPE_FORMAT_Z32_FLOAT = 18,
|
||||
PIPE_FORMAT_Z24S8_UNORM = 19,
|
||||
PIPE_FORMAT_S8Z24_UNORM = 20,
|
||||
PIPE_FORMAT_Z24X8_UNORM = 21,
|
||||
PIPE_FORMAT_X8Z24_UNORM = 22,
|
||||
PIPE_FORMAT_S8_UNORM = 23, /**< ubyte stencil */
|
||||
PIPE_FORMAT_R64_FLOAT = 24,
|
||||
PIPE_FORMAT_R64G64_FLOAT = 25,
|
||||
PIPE_FORMAT_R64G64B64_FLOAT = 26,
|
||||
PIPE_FORMAT_R64G64B64A64_FLOAT = 27,
|
||||
PIPE_FORMAT_R32_FLOAT = 28,
|
||||
PIPE_FORMAT_R32G32_FLOAT = 29,
|
||||
PIPE_FORMAT_R32G32B32_FLOAT = 30,
|
||||
PIPE_FORMAT_R32G32B32A32_FLOAT = 31,
|
||||
PIPE_FORMAT_R32_UNORM = 32,
|
||||
PIPE_FORMAT_R32G32_UNORM = 33,
|
||||
PIPE_FORMAT_R32G32B32_UNORM = 34,
|
||||
PIPE_FORMAT_R32G32B32A32_UNORM = 35,
|
||||
PIPE_FORMAT_R32_USCALED = 36,
|
||||
PIPE_FORMAT_R32G32_USCALED = 37,
|
||||
PIPE_FORMAT_R32G32B32_USCALED = 38,
|
||||
PIPE_FORMAT_R32G32B32A32_USCALED = 39,
|
||||
PIPE_FORMAT_R32_SNORM = 40,
|
||||
PIPE_FORMAT_R32G32_SNORM = 41,
|
||||
PIPE_FORMAT_R32G32B32_SNORM = 42,
|
||||
PIPE_FORMAT_R32G32B32A32_SNORM = 43,
|
||||
PIPE_FORMAT_R32_SSCALED = 44,
|
||||
PIPE_FORMAT_R32G32_SSCALED = 45,
|
||||
PIPE_FORMAT_R32G32B32_SSCALED = 46,
|
||||
PIPE_FORMAT_R32G32B32A32_SSCALED = 47,
|
||||
PIPE_FORMAT_R16_UNORM = 48,
|
||||
PIPE_FORMAT_R16G16_UNORM = 49,
|
||||
PIPE_FORMAT_R16G16B16_UNORM = 50,
|
||||
PIPE_FORMAT_R16G16B16A16_UNORM = 51,
|
||||
PIPE_FORMAT_R16_USCALED = 52,
|
||||
PIPE_FORMAT_R16G16_USCALED = 53,
|
||||
PIPE_FORMAT_R16G16B16_USCALED = 54,
|
||||
PIPE_FORMAT_R16G16B16A16_USCALED = 55,
|
||||
PIPE_FORMAT_R16_SNORM = 56,
|
||||
PIPE_FORMAT_R16G16_SNORM = 57,
|
||||
PIPE_FORMAT_R16G16B16_SNORM = 58,
|
||||
PIPE_FORMAT_R16G16B16A16_SNORM = 59,
|
||||
PIPE_FORMAT_R16_SSCALED = 60,
|
||||
PIPE_FORMAT_R16G16_SSCALED = 61,
|
||||
PIPE_FORMAT_R16G16B16_SSCALED = 62,
|
||||
PIPE_FORMAT_R16G16B16A16_SSCALED = 63,
|
||||
PIPE_FORMAT_R8_UNORM = 64,
|
||||
PIPE_FORMAT_R8G8_UNORM = 65,
|
||||
PIPE_FORMAT_R8G8B8_UNORM = 66,
|
||||
PIPE_FORMAT_R8G8B8A8_UNORM = 67,
|
||||
PIPE_FORMAT_X8B8G8R8_UNORM = 68,
|
||||
PIPE_FORMAT_R8_USCALED = 69,
|
||||
PIPE_FORMAT_R8G8_USCALED = 70,
|
||||
PIPE_FORMAT_R8G8B8_USCALED = 71,
|
||||
PIPE_FORMAT_R8G8B8A8_USCALED = 72,
|
||||
PIPE_FORMAT_R8_SNORM = 74,
|
||||
PIPE_FORMAT_R8G8_SNORM = 75,
|
||||
PIPE_FORMAT_R8G8B8_SNORM = 76,
|
||||
PIPE_FORMAT_R8G8B8A8_SNORM = 77,
|
||||
PIPE_FORMAT_R8_SSCALED = 82,
|
||||
PIPE_FORMAT_R8G8_SSCALED = 83,
|
||||
PIPE_FORMAT_R8G8B8_SSCALED = 84,
|
||||
PIPE_FORMAT_R8G8B8A8_SSCALED = 85,
|
||||
PIPE_FORMAT_R32_FIXED = 87,
|
||||
PIPE_FORMAT_R32G32_FIXED = 88,
|
||||
PIPE_FORMAT_R32G32B32_FIXED = 89,
|
||||
PIPE_FORMAT_R32G32B32A32_FIXED = 90,
|
||||
/* sRGB formats */
|
||||
PIPE_FORMAT_L8_SRGB = 91,
|
||||
PIPE_FORMAT_L8A8_SRGB = 92,
|
||||
PIPE_FORMAT_R8G8B8_SRGB = 93,
|
||||
PIPE_FORMAT_A8B8G8R8_SRGB = 94,
|
||||
PIPE_FORMAT_X8B8G8R8_SRGB = 95,
|
||||
PIPE_FORMAT_B8G8R8A8_SRGB = 96,
|
||||
PIPE_FORMAT_B8G8R8X8_SRGB = 97,
|
||||
PIPE_FORMAT_A8R8G8B8_SRGB = 98,
|
||||
PIPE_FORMAT_X8R8G8B8_SRGB = 99,
|
||||
PIPE_FORMAT_NONE = 0,
|
||||
PIPE_FORMAT_B8G8R8A8_UNORM = 1,
|
||||
PIPE_FORMAT_B8G8R8X8_UNORM = 2,
|
||||
PIPE_FORMAT_A8R8G8B8_UNORM = 3,
|
||||
PIPE_FORMAT_X8R8G8B8_UNORM = 4,
|
||||
PIPE_FORMAT_B5G5R5A1_UNORM = 5,
|
||||
PIPE_FORMAT_B4G4R4A4_UNORM = 6,
|
||||
PIPE_FORMAT_B5G6R5_UNORM = 7,
|
||||
PIPE_FORMAT_R10G10B10A2_UNORM = 8,
|
||||
PIPE_FORMAT_L8_UNORM = 9, /**< ubyte luminance */
|
||||
PIPE_FORMAT_A8_UNORM = 10, /**< ubyte alpha */
|
||||
PIPE_FORMAT_I8_UNORM = 11, /**< ubyte intensity */
|
||||
PIPE_FORMAT_L8A8_UNORM = 12, /**< ubyte alpha, luminance */
|
||||
PIPE_FORMAT_L16_UNORM = 13, /**< ushort luminance */
|
||||
PIPE_FORMAT_UYVY = 14,
|
||||
PIPE_FORMAT_YUYV = 15,
|
||||
PIPE_FORMAT_Z16_UNORM = 16,
|
||||
PIPE_FORMAT_Z32_UNORM = 17,
|
||||
PIPE_FORMAT_Z32_FLOAT = 18,
|
||||
PIPE_FORMAT_Z24_UNORM_S8_USCALED = 19,
|
||||
PIPE_FORMAT_S8_USCALED_Z24_UNORM = 20,
|
||||
PIPE_FORMAT_Z24X8_UNORM = 21,
|
||||
PIPE_FORMAT_X8Z24_UNORM = 22,
|
||||
PIPE_FORMAT_S8_USCALED = 23, /**< ubyte stencil */
|
||||
PIPE_FORMAT_R64_FLOAT = 24,
|
||||
PIPE_FORMAT_R64G64_FLOAT = 25,
|
||||
PIPE_FORMAT_R64G64B64_FLOAT = 26,
|
||||
PIPE_FORMAT_R64G64B64A64_FLOAT = 27,
|
||||
PIPE_FORMAT_R32_FLOAT = 28,
|
||||
PIPE_FORMAT_R32G32_FLOAT = 29,
|
||||
PIPE_FORMAT_R32G32B32_FLOAT = 30,
|
||||
PIPE_FORMAT_R32G32B32A32_FLOAT = 31,
|
||||
PIPE_FORMAT_R32_UNORM = 32,
|
||||
PIPE_FORMAT_R32G32_UNORM = 33,
|
||||
PIPE_FORMAT_R32G32B32_UNORM = 34,
|
||||
PIPE_FORMAT_R32G32B32A32_UNORM = 35,
|
||||
PIPE_FORMAT_R32_USCALED = 36,
|
||||
PIPE_FORMAT_R32G32_USCALED = 37,
|
||||
PIPE_FORMAT_R32G32B32_USCALED = 38,
|
||||
PIPE_FORMAT_R32G32B32A32_USCALED = 39,
|
||||
PIPE_FORMAT_R32_SNORM = 40,
|
||||
PIPE_FORMAT_R32G32_SNORM = 41,
|
||||
PIPE_FORMAT_R32G32B32_SNORM = 42,
|
||||
PIPE_FORMAT_R32G32B32A32_SNORM = 43,
|
||||
PIPE_FORMAT_R32_SSCALED = 44,
|
||||
PIPE_FORMAT_R32G32_SSCALED = 45,
|
||||
PIPE_FORMAT_R32G32B32_SSCALED = 46,
|
||||
PIPE_FORMAT_R32G32B32A32_SSCALED = 47,
|
||||
PIPE_FORMAT_R16_UNORM = 48,
|
||||
PIPE_FORMAT_R16G16_UNORM = 49,
|
||||
PIPE_FORMAT_R16G16B16_UNORM = 50,
|
||||
PIPE_FORMAT_R16G16B16A16_UNORM = 51,
|
||||
PIPE_FORMAT_R16_USCALED = 52,
|
||||
PIPE_FORMAT_R16G16_USCALED = 53,
|
||||
PIPE_FORMAT_R16G16B16_USCALED = 54,
|
||||
PIPE_FORMAT_R16G16B16A16_USCALED = 55,
|
||||
PIPE_FORMAT_R16_SNORM = 56,
|
||||
PIPE_FORMAT_R16G16_SNORM = 57,
|
||||
PIPE_FORMAT_R16G16B16_SNORM = 58,
|
||||
PIPE_FORMAT_R16G16B16A16_SNORM = 59,
|
||||
PIPE_FORMAT_R16_SSCALED = 60,
|
||||
PIPE_FORMAT_R16G16_SSCALED = 61,
|
||||
PIPE_FORMAT_R16G16B16_SSCALED = 62,
|
||||
PIPE_FORMAT_R16G16B16A16_SSCALED = 63,
|
||||
PIPE_FORMAT_R8_UNORM = 64,
|
||||
PIPE_FORMAT_R8G8_UNORM = 65,
|
||||
PIPE_FORMAT_R8G8B8_UNORM = 66,
|
||||
PIPE_FORMAT_R8G8B8A8_UNORM = 67,
|
||||
PIPE_FORMAT_X8B8G8R8_UNORM = 68,
|
||||
PIPE_FORMAT_R8_USCALED = 69,
|
||||
PIPE_FORMAT_R8G8_USCALED = 70,
|
||||
PIPE_FORMAT_R8G8B8_USCALED = 71,
|
||||
PIPE_FORMAT_R8G8B8A8_USCALED = 72,
|
||||
PIPE_FORMAT_R8_SNORM = 74,
|
||||
PIPE_FORMAT_R8G8_SNORM = 75,
|
||||
PIPE_FORMAT_R8G8B8_SNORM = 76,
|
||||
PIPE_FORMAT_R8G8B8A8_SNORM = 77,
|
||||
PIPE_FORMAT_R8_SSCALED = 82,
|
||||
PIPE_FORMAT_R8G8_SSCALED = 83,
|
||||
PIPE_FORMAT_R8G8B8_SSCALED = 84,
|
||||
PIPE_FORMAT_R8G8B8A8_SSCALED = 85,
|
||||
PIPE_FORMAT_R32_FIXED = 87,
|
||||
PIPE_FORMAT_R32G32_FIXED = 88,
|
||||
PIPE_FORMAT_R32G32B32_FIXED = 89,
|
||||
PIPE_FORMAT_R32G32B32A32_FIXED = 90,
|
||||
PIPE_FORMAT_R16_FLOAT = 91,
|
||||
PIPE_FORMAT_R16G16_FLOAT = 92,
|
||||
PIPE_FORMAT_R16G16B16_FLOAT = 93,
|
||||
PIPE_FORMAT_R16G16B16A16_FLOAT = 94,
|
||||
|
||||
/* mixed formats */
|
||||
PIPE_FORMAT_R8SG8SB8UX8U_NORM = 100,
|
||||
PIPE_FORMAT_R5SG5SB6U_NORM = 101,
|
||||
/* sRGB formats */
|
||||
PIPE_FORMAT_L8_SRGB = 95,
|
||||
PIPE_FORMAT_L8A8_SRGB = 96,
|
||||
PIPE_FORMAT_R8G8B8_SRGB = 97,
|
||||
PIPE_FORMAT_A8B8G8R8_SRGB = 98,
|
||||
PIPE_FORMAT_X8B8G8R8_SRGB = 99,
|
||||
PIPE_FORMAT_B8G8R8A8_SRGB = 100,
|
||||
PIPE_FORMAT_B8G8R8X8_SRGB = 101,
|
||||
PIPE_FORMAT_A8R8G8B8_SRGB = 102,
|
||||
PIPE_FORMAT_X8R8G8B8_SRGB = 103,
|
||||
PIPE_FORMAT_R8G8B8A8_SRGB = 104,
|
||||
|
||||
/* compressed formats */
|
||||
PIPE_FORMAT_DXT1_RGB = 102,
|
||||
PIPE_FORMAT_DXT1_RGBA = 103,
|
||||
PIPE_FORMAT_DXT3_RGBA = 104,
|
||||
PIPE_FORMAT_DXT5_RGBA = 105,
|
||||
PIPE_FORMAT_DXT1_RGB = 105,
|
||||
PIPE_FORMAT_DXT1_RGBA = 106,
|
||||
PIPE_FORMAT_DXT3_RGBA = 107,
|
||||
PIPE_FORMAT_DXT5_RGBA = 108,
|
||||
|
||||
/* sRGB, compressed */
|
||||
PIPE_FORMAT_DXT1_SRGB = 106,
|
||||
PIPE_FORMAT_DXT1_SRGBA = 107,
|
||||
PIPE_FORMAT_DXT3_SRGBA = 108,
|
||||
PIPE_FORMAT_DXT5_SRGBA = 109,
|
||||
PIPE_FORMAT_DXT1_SRGB = 109,
|
||||
PIPE_FORMAT_DXT1_SRGBA = 110,
|
||||
PIPE_FORMAT_DXT3_SRGBA = 111,
|
||||
PIPE_FORMAT_DXT5_SRGBA = 112,
|
||||
|
||||
PIPE_FORMAT_A8B8G8R8_UNORM = 110,
|
||||
PIPE_FORMAT_B5G5R5X1_UNORM = 111,
|
||||
/* rgtc compressed */
|
||||
PIPE_FORMAT_RGTC1_UNORM = 113,
|
||||
PIPE_FORMAT_RGTC1_SNORM = 114,
|
||||
PIPE_FORMAT_RGTC2_UNORM = 115,
|
||||
PIPE_FORMAT_RGTC2_SNORM = 116,
|
||||
|
||||
PIPE_FORMAT_R8G8_B8G8_UNORM = 117,
|
||||
PIPE_FORMAT_G8R8_G8B8_UNORM = 118,
|
||||
|
||||
/* mixed formats */
|
||||
PIPE_FORMAT_R8SG8SB8UX8U_NORM = 119,
|
||||
PIPE_FORMAT_R5SG5SB6U_NORM = 120,
|
||||
|
||||
PIPE_FORMAT_A8B8G8R8_UNORM = 121,
|
||||
PIPE_FORMAT_B5G5R5X1_UNORM = 122,
|
||||
PIPE_FORMAT_R10G10B10A2_USCALED = 123,
|
||||
PIPE_FORMAT_R11G11B10_FLOAT = 124,
|
||||
PIPE_FORMAT_R9G9B9E5_FLOAT = 125,
|
||||
PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED = 126,
|
||||
PIPE_FORMAT_R1_UNORM = 127,
|
||||
|
||||
PIPE_FORMAT_COUNT
|
||||
};
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "pipe/p_screen.h"
|
||||
#include "util/u_format.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "util/u_inlines.h"
|
||||
|
||||
/**
|
||||
* This is called when we need to set up GL rendering to a new X window.
|
||||
|
|
|
@ -97,10 +97,10 @@ dri_fill_in_modes(struct dri_screen *screen,
|
|||
pf_z24x8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8Z24_UNORM,
|
||||
PIPE_TEXTURE_2D,
|
||||
PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
|
||||
pf_s8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24S8_UNORM,
|
||||
pf_s8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
|
||||
PIPE_TEXTURE_2D,
|
||||
PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
|
||||
pf_z24s8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_S8Z24_UNORM,
|
||||
pf_z24s8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
|
||||
PIPE_TEXTURE_2D,
|
||||
PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
|
||||
pf_a8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8A8_UNORM,
|
||||
|
@ -241,8 +241,8 @@ dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen,
|
|||
PIPE_FORMAT_X8Z24_UNORM;
|
||||
} else {
|
||||
stvis->depth_stencil_format = (screen->sd_depth_bits_last) ?
|
||||
PIPE_FORMAT_Z24S8_UNORM:
|
||||
PIPE_FORMAT_S8Z24_UNORM;
|
||||
PIPE_FORMAT_Z24_UNORM_S8_USCALED:
|
||||
PIPE_FORMAT_S8_USCALED_Z24_UNORM;
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "dri_context.h"
|
||||
#include "dri_drawable.h"
|
||||
#include "dri_st_api.h"
|
||||
#include "dri1_helper.h"
|
||||
#ifndef __NOT_HAVE_DRM_H
|
||||
#include "dri1.h"
|
||||
#include "dri2.h"
|
||||
|
|
|
@ -631,9 +631,9 @@ kms_display_get_configs(struct native_display *ndpy, int *num_configs)
|
|||
nconf->mode.alphaBits = 8;
|
||||
nconf->mode.rgbBits = 32;
|
||||
|
||||
format = PIPE_FORMAT_Z24S8_UNORM;
|
||||
format = PIPE_FORMAT_Z24_UNORM_S8_USCALED;
|
||||
if (!kms_display_is_format_supported(&kdpy->base, format, FALSE)) {
|
||||
format = PIPE_FORMAT_S8Z24_UNORM;
|
||||
format = PIPE_FORMAT_S8_USCALED_Z24_UNORM;
|
||||
if (!kms_display_is_format_supported(&kdpy->base, format, FALSE))
|
||||
format = PIPE_FORMAT_NONE;
|
||||
}
|
||||
|
|
|
@ -558,8 +558,8 @@ choose_depth_stencil_format(const __GLcontextModes *mode,
|
|||
break;
|
||||
case 24:
|
||||
if (mode->stencilBits) {
|
||||
formats[count++] = PIPE_FORMAT_Z24S8_UNORM;
|
||||
formats[count++] = PIPE_FORMAT_S8Z24_UNORM;
|
||||
formats[count++] = PIPE_FORMAT_Z24_UNORM_S8_USCALED;
|
||||
formats[count++] = PIPE_FORMAT_S8_USCALED_Z24_UNORM;
|
||||
}
|
||||
else {
|
||||
formats[count++] = PIPE_FORMAT_Z24X8_UNORM;
|
||||
|
|
|
@ -526,8 +526,8 @@ ximage_display_get_configs(struct native_display *ndpy, int *num_configs)
|
|||
xconf->base.stencil_format = PIPE_FORMAT_NONE;
|
||||
/* create the second config with depth/stencil buffer */
|
||||
if (j == 1) {
|
||||
xconf->base.depth_format = PIPE_FORMAT_Z24S8_UNORM;
|
||||
xconf->base.stencil_format = PIPE_FORMAT_Z24S8_UNORM;
|
||||
xconf->base.depth_format = PIPE_FORMAT_Z24_UNORM_S8_USCALED;
|
||||
xconf->base.stencil_format = PIPE_FORMAT_Z24_UNORM_S8_USCALED;
|
||||
mode->depthBits = 24;
|
||||
mode->stencilBits = 8;
|
||||
mode->haveDepthBuffer = TRUE;
|
||||
|
|
|
@ -355,8 +355,8 @@ choose_depth_stencil_format(XMesaDisplay xmdpy, int depth, int stencil)
|
|||
formats[count++] = PIPE_FORMAT_Z24X8_UNORM;
|
||||
}
|
||||
if (depth <= 24 && stencil <= 8) {
|
||||
formats[count++] = PIPE_FORMAT_S8Z24_UNORM;
|
||||
formats[count++] = PIPE_FORMAT_Z24S8_UNORM;
|
||||
formats[count++] = PIPE_FORMAT_S8_USCALED_Z24_UNORM;
|
||||
formats[count++] = PIPE_FORMAT_Z24_UNORM_S8_USCALED;
|
||||
}
|
||||
if (depth <= 32 && stencil == 0) {
|
||||
formats[count++] = PIPE_FORMAT_Z32_UNORM;
|
||||
|
|
|
@ -95,7 +95,7 @@
|
|||
|
||||
|
||||
%include "p_compiler.i"
|
||||
%include "p_defines.h";
|
||||
%include "p_defines.h"
|
||||
%include "p_format.h"
|
||||
|
||||
%include "p_device.i"
|
||||
|
@ -103,3 +103,4 @@
|
|||
%include "p_texture.i"
|
||||
%include "p_state.i"
|
||||
|
||||
%include "u_format.i"
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2010 VMware, Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER 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.
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
static INLINE const char *
|
||||
util_format_name(enum pipe_format format);
|
||||
|
||||
static INLINE boolean
|
||||
util_format_is_s3tc(enum pipe_format format);
|
||||
|
||||
static INLINE boolean
|
||||
util_format_is_depth_or_stencil(enum pipe_format format);
|
||||
|
||||
static INLINE boolean
|
||||
util_format_is_depth_and_stencil(enum pipe_format format);
|
||||
|
||||
|
||||
uint
|
||||
util_format_get_blocksizebits(enum pipe_format format);
|
||||
|
||||
uint
|
||||
util_format_get_blocksize(enum pipe_format format);
|
||||
|
||||
uint
|
||||
util_format_get_blockwidth(enum pipe_format format);
|
||||
|
||||
uint
|
||||
util_format_get_blockheight(enum pipe_format format);
|
||||
|
||||
unsigned
|
||||
util_format_get_nblocksx(enum pipe_format format,
|
||||
unsigned x);
|
||||
|
||||
unsigned
|
||||
util_format_get_nblocksy(enum pipe_format format,
|
||||
unsigned y);
|
||||
|
||||
unsigned
|
||||
util_format_get_nblocks(enum pipe_format format,
|
||||
unsigned width,
|
||||
unsigned height);
|
||||
|
||||
size_t
|
||||
util_format_get_stride(enum pipe_format format,
|
||||
unsigned width);
|
||||
|
||||
size_t
|
||||
util_format_get_2d_size(enum pipe_format format,
|
||||
size_t stride,
|
||||
unsigned height);
|
||||
|
||||
uint
|
||||
util_format_get_component_bits(enum pipe_format format,
|
||||
enum util_format_colorspace colorspace,
|
||||
uint component);
|
||||
|
||||
boolean
|
||||
util_format_has_alpha(enum pipe_format format);
|
||||
|
||||
|
||||
unsigned
|
||||
util_format_get_nr_components(enum pipe_format format);
|
||||
|
||||
|
|
@ -208,7 +208,7 @@ struct st_framebuffer * st_create_framebuffer(const void *visual,
|
|||
if (stencilFormat == depthFormat)
|
||||
stfb->dsrb = st_new_renderbuffer_fb(stencilFormat);
|
||||
else
|
||||
stfb->dsrb = st_new_renderbuffer_fb(PIPE_FORMAT_Z24S8_UNORM);
|
||||
stfb->dsrb = st_new_renderbuffer_fb(PIPE_FORMAT_Z24_UNORM_S8_USCALED);
|
||||
|
||||
/*### currently we always allocate it but it's possible it's
|
||||
not necessary if EGL_ALPHA_MASK_SIZE was 0
|
||||
|
|
|
@ -96,8 +96,8 @@ stw_pf_depth_stencil[] = {
|
|||
{ PIPE_FORMAT_Z24X8_UNORM, {24, 0} },
|
||||
{ PIPE_FORMAT_Z16_UNORM, {16, 0} },
|
||||
/* combined depth-stencil */
|
||||
{ PIPE_FORMAT_Z24S8_UNORM, {24, 8} },
|
||||
{ PIPE_FORMAT_S8Z24_UNORM, {24, 8} }
|
||||
{ PIPE_FORMAT_Z24_UNORM_S8_USCALED, {24, 8} },
|
||||
{ PIPE_FORMAT_S8_USCALED_Z24_UNORM, {24, 8} }
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int form
|
|||
}
|
||||
} else {
|
||||
template.format = ms->ds_depth_bits_last ?
|
||||
PIPE_FORMAT_Z24S8_UNORM : PIPE_FORMAT_S8Z24_UNORM;
|
||||
PIPE_FORMAT_Z24_UNORM_S8_USCALED : PIPE_FORMAT_S8_USCALED_Z24_UNORM;
|
||||
}
|
||||
template.width0 = pDraw->width;
|
||||
template.height0 = pDraw->height;
|
||||
|
@ -439,7 +439,7 @@ xorg_dri2_init(ScreenPtr pScreen)
|
|||
PIPE_TEXTURE_2D,
|
||||
PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
|
||||
ms->ds_depth_bits_last =
|
||||
ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_Z24S8_UNORM,
|
||||
ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
|
||||
PIPE_TEXTURE_2D,
|
||||
PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ sources = [
|
|||
'xlib.c',
|
||||
]
|
||||
|
||||
env.Tool('x11')
|
||||
|
||||
if 'softpipe' in env['drivers']:
|
||||
env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE')
|
||||
env.Prepend(LIBS = [softpipe])
|
||||
|
|
|
@ -103,6 +103,7 @@ if env['platform'] != 'winddk':
|
|||
'main/texrender.c',
|
||||
'main/texstate.c',
|
||||
'main/texstore.c',
|
||||
'main/transformfeedback.c',
|
||||
'main/varray.c',
|
||||
'main/version.c',
|
||||
'main/viewport.c',
|
||||
|
|
|
@ -83,6 +83,13 @@ get_buffer_target(GLcontext *ctx, GLenum target)
|
|||
return &ctx->CopyWriteBuffer;
|
||||
}
|
||||
break;
|
||||
#if FEATURE_EXT_transform_feedback
|
||||
case GL_TRANSFORM_FEEDBACK_BUFFER:
|
||||
if (ctx->Extensions.EXT_transform_feedback) {
|
||||
return &ctx->TransformFeedback.CurrentBuffer;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -262,6 +262,11 @@
|
|||
/** For GL_ATI_envmap_bump - support bump mapping on first 8 units */
|
||||
#define SUPPORTED_ATI_BUMP_UNITS 0xff
|
||||
|
||||
/** For GL_EXT_transform_feedback */
|
||||
#define MAX_FEEDBACK_ATTRIBS 32
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* \name Mesa-specific parameters
|
||||
*/
|
||||
|
|
|
@ -123,6 +123,7 @@
|
|||
#include "stencil.h"
|
||||
#include "texcompress_s3tc.h"
|
||||
#include "texstate.h"
|
||||
#include "transformfeedback.h"
|
||||
#include "mtypes.h"
|
||||
#include "varray.h"
|
||||
#include "version.h"
|
||||
|
@ -560,6 +561,11 @@ _mesa_init_constants(GLcontext *ctx)
|
|||
|
||||
/* GL_EXT_provoking_vertex */
|
||||
ctx->Const.QuadsFollowProvokingVertexConvention = GL_TRUE;
|
||||
|
||||
/* GL_EXT_transform_feedback */
|
||||
ctx->Const.MaxTransformFeedbackSeparateAttribs = MAX_FEEDBACK_ATTRIBS;
|
||||
ctx->Const.MaxTransformFeedbackSeparateComponents = 4 * MAX_FEEDBACK_ATTRIBS;
|
||||
ctx->Const.MaxTransformFeedbackInterleavedComponents = 4 * MAX_FEEDBACK_ATTRIBS;
|
||||
}
|
||||
|
||||
|
||||
|
@ -684,6 +690,7 @@ init_attrib_groups(GLcontext *ctx)
|
|||
_mesa_init_shader_state( ctx );
|
||||
_mesa_init_stencil( ctx );
|
||||
_mesa_init_transform( ctx );
|
||||
_mesa_init_transform_feedback( ctx );
|
||||
_mesa_init_varray( ctx );
|
||||
_mesa_init_viewport( ctx );
|
||||
|
||||
|
@ -969,6 +976,7 @@ _mesa_free_context_data( GLcontext *ctx )
|
|||
_mesa_free_sync_data(ctx);
|
||||
#endif
|
||||
_mesa_free_varray_data(ctx);
|
||||
_mesa_free_transform_feedback(ctx);
|
||||
|
||||
_mesa_delete_array_object(ctx, ctx->Array.DefaultArrayObj);
|
||||
|
||||
|
|
|
@ -982,6 +982,16 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state)
|
|||
ctx->Texture.CubeMapSeamless = state;
|
||||
break;
|
||||
|
||||
#if FEATURE_EXT_transform_feedback
|
||||
case GL_RASTERIZER_DISCARD:
|
||||
CHECK_EXTENSION(EXT_transform_feedback, cap);
|
||||
if (ctx->TransformFeedback.RasterDiscard != state) {
|
||||
ctx->TransformFeedback.RasterDiscard = state;
|
||||
FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM,
|
||||
"%s(0x%x)", state ? "glEnable" : "glDisable", cap);
|
||||
|
@ -1493,6 +1503,12 @@ _mesa_IsEnabled( GLenum cap )
|
|||
CHECK_EXTENSION(ARB_seamless_cube_map);
|
||||
return ctx->Texture.CubeMapSeamless;
|
||||
|
||||
#if FEATURE_EXT_transform_feedback
|
||||
case GL_RASTERIZER_DISCARD:
|
||||
CHECK_EXTENSION(EXT_transform_feedback);
|
||||
return ctx->TransformFeedback.RasterDiscard;
|
||||
#endif
|
||||
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap);
|
||||
return GL_FALSE;
|
||||
|
|
|
@ -146,6 +146,7 @@ static const struct {
|
|||
{ OFF, "GL_EXT_texture_sRGB", F(EXT_texture_sRGB) },
|
||||
{ OFF, "GL_EXT_texture_swizzle", F(EXT_texture_swizzle) },
|
||||
{ OFF, "GL_EXT_timer_query", F(EXT_timer_query) },
|
||||
{ OFF, "GL_EXT_transform_feedback", F(EXT_transform_feedback) },
|
||||
{ ON, "GL_EXT_vertex_array", F(EXT_vertex_array) },
|
||||
{ OFF, "GL_EXT_vertex_array_bgra", F(EXT_vertex_array_bgra) },
|
||||
{ OFF, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set) },
|
||||
|
@ -319,6 +320,9 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
|
|||
ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
|
||||
#endif
|
||||
ctx->Extensions.EXT_texture_swizzle = GL_TRUE;
|
||||
#if FEATURE_EXT_transform_feedback
|
||||
ctx->Extensions.EXT_transform_feedback = GL_TRUE;
|
||||
#endif
|
||||
ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE;
|
||||
/*ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;*/
|
||||
ctx->Extensions.MESA_pack_invert = GL_TRUE;
|
||||
|
|
|
@ -1922,6 +1922,26 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
|
|||
CHECK_EXT1(ARB_sync, "GetBooleanv");
|
||||
params[0] = INT64_TO_BOOLEAN(ctx->Const.MaxServerWaitTimeout);
|
||||
break;
|
||||
case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetBooleanv");
|
||||
params[0] = INT_TO_BOOLEAN(ctx->TransformFeedback.CurrentBuffer->Name);
|
||||
break;
|
||||
case GL_RASTERIZER_DISCARD:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetBooleanv");
|
||||
params[0] = ctx->TransformFeedback.RasterDiscard;
|
||||
break;
|
||||
case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetBooleanv");
|
||||
params[0] = INT_TO_BOOLEAN(ctx->Const.MaxTransformFeedbackInterleavedComponents);
|
||||
break;
|
||||
case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetBooleanv");
|
||||
params[0] = INT_TO_BOOLEAN(ctx->Const.MaxTransformFeedbackSeparateAttribs);
|
||||
break;
|
||||
case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetBooleanv");
|
||||
params[0] = INT_TO_BOOLEAN(ctx->Const.MaxTransformFeedbackSeparateComponents);
|
||||
break;
|
||||
case GL_NUM_EXTENSIONS:
|
||||
params[0] = INT_TO_BOOLEAN(_mesa_get_extension_count(ctx));
|
||||
break;
|
||||
|
@ -3793,6 +3813,26 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
|
|||
CHECK_EXT1(ARB_sync, "GetFloatv");
|
||||
params[0] = (GLfloat)(ctx->Const.MaxServerWaitTimeout);
|
||||
break;
|
||||
case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetFloatv");
|
||||
params[0] = (GLfloat)(ctx->TransformFeedback.CurrentBuffer->Name);
|
||||
break;
|
||||
case GL_RASTERIZER_DISCARD:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetFloatv");
|
||||
params[0] = BOOLEAN_TO_FLOAT(ctx->TransformFeedback.RasterDiscard);
|
||||
break;
|
||||
case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetFloatv");
|
||||
params[0] = (GLfloat)(ctx->Const.MaxTransformFeedbackInterleavedComponents);
|
||||
break;
|
||||
case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetFloatv");
|
||||
params[0] = (GLfloat)(ctx->Const.MaxTransformFeedbackSeparateAttribs);
|
||||
break;
|
||||
case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetFloatv");
|
||||
params[0] = (GLfloat)(ctx->Const.MaxTransformFeedbackSeparateComponents);
|
||||
break;
|
||||
case GL_NUM_EXTENSIONS:
|
||||
params[0] = (GLfloat)(_mesa_get_extension_count(ctx));
|
||||
break;
|
||||
|
@ -5664,6 +5704,26 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
|
|||
CHECK_EXT1(ARB_sync, "GetIntegerv");
|
||||
params[0] = INT64_TO_INT(ctx->Const.MaxServerWaitTimeout);
|
||||
break;
|
||||
case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetIntegerv");
|
||||
params[0] = ctx->TransformFeedback.CurrentBuffer->Name;
|
||||
break;
|
||||
case GL_RASTERIZER_DISCARD:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetIntegerv");
|
||||
params[0] = BOOLEAN_TO_INT(ctx->TransformFeedback.RasterDiscard);
|
||||
break;
|
||||
case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetIntegerv");
|
||||
params[0] = ctx->Const.MaxTransformFeedbackInterleavedComponents;
|
||||
break;
|
||||
case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetIntegerv");
|
||||
params[0] = ctx->Const.MaxTransformFeedbackSeparateAttribs;
|
||||
break;
|
||||
case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetIntegerv");
|
||||
params[0] = ctx->Const.MaxTransformFeedbackSeparateComponents;
|
||||
break;
|
||||
case GL_NUM_EXTENSIONS:
|
||||
params[0] = _mesa_get_extension_count(ctx);
|
||||
break;
|
||||
|
@ -7536,6 +7596,26 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
|
|||
CHECK_EXT1(ARB_sync, "GetInteger64v");
|
||||
params[0] = ctx->Const.MaxServerWaitTimeout;
|
||||
break;
|
||||
case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetInteger64v");
|
||||
params[0] = (GLint64)(ctx->TransformFeedback.CurrentBuffer->Name);
|
||||
break;
|
||||
case GL_RASTERIZER_DISCARD:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetInteger64v");
|
||||
params[0] = BOOLEAN_TO_INT64(ctx->TransformFeedback.RasterDiscard);
|
||||
break;
|
||||
case GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetInteger64v");
|
||||
params[0] = (GLint64)(ctx->Const.MaxTransformFeedbackInterleavedComponents);
|
||||
break;
|
||||
case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetInteger64v");
|
||||
params[0] = (GLint64)(ctx->Const.MaxTransformFeedbackSeparateAttribs);
|
||||
break;
|
||||
case GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetInteger64v");
|
||||
params[0] = (GLint64)(ctx->Const.MaxTransformFeedbackSeparateComponents);
|
||||
break;
|
||||
case GL_NUM_EXTENSIONS:
|
||||
params[0] = (GLint64)(_mesa_get_extension_count(ctx));
|
||||
break;
|
||||
|
@ -7606,6 +7686,30 @@ _mesa_GetBooleanIndexedv( GLenum pname, GLuint index, GLboolean *params )
|
|||
params[2] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][BCOMP] ? 1 : 0);
|
||||
params[3] = INT_TO_BOOLEAN(ctx->Color.ColorMask[index][ACOMP] ? 1 : 0);
|
||||
break;
|
||||
case GL_TRANSFORM_FEEDBACK_BUFFER_START:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetBooleanIndexedv");
|
||||
if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname);
|
||||
return;
|
||||
}
|
||||
params[0] = INT64_TO_BOOLEAN(ctx->TransformFeedback.Offset[index]);
|
||||
break;
|
||||
case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetBooleanIndexedv");
|
||||
if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname);
|
||||
return;
|
||||
}
|
||||
params[0] = INT64_TO_BOOLEAN(ctx->TransformFeedback.Size[index]);
|
||||
break;
|
||||
case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetBooleanIndexedv");
|
||||
if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glGetBooleanIndexedv(index=%u), index", pname);
|
||||
return;
|
||||
}
|
||||
params[0] = INT_TO_BOOLEAN(ctx->TransformFeedback.Buffers[index]->Name);
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanIndexedv(pname=0x%x)", pname);
|
||||
}
|
||||
|
@ -7640,6 +7744,30 @@ _mesa_GetIntegerIndexedv( GLenum pname, GLuint index, GLint *params )
|
|||
params[2] = ctx->Color.ColorMask[index][BCOMP] ? 1 : 0;
|
||||
params[3] = ctx->Color.ColorMask[index][ACOMP] ? 1 : 0;
|
||||
break;
|
||||
case GL_TRANSFORM_FEEDBACK_BUFFER_START:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetIntegerIndexedv");
|
||||
if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname);
|
||||
return;
|
||||
}
|
||||
params[0] = INT64_TO_INT(ctx->TransformFeedback.Offset[index]);
|
||||
break;
|
||||
case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetIntegerIndexedv");
|
||||
if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname);
|
||||
return;
|
||||
}
|
||||
params[0] = INT64_TO_INT(ctx->TransformFeedback.Size[index]);
|
||||
break;
|
||||
case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetIntegerIndexedv");
|
||||
if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glGetIntegerIndexedv(index=%u), index", pname);
|
||||
return;
|
||||
}
|
||||
params[0] = ctx->TransformFeedback.Buffers[index]->Name;
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerIndexedv(pname=0x%x)", pname);
|
||||
}
|
||||
|
@ -7675,6 +7803,30 @@ _mesa_GetInteger64Indexedv( GLenum pname, GLuint index, GLint64 *params )
|
|||
params[2] = (GLint64)(ctx->Color.ColorMask[index][BCOMP] ? 1 : 0);
|
||||
params[3] = (GLint64)(ctx->Color.ColorMask[index][ACOMP] ? 1 : 0);
|
||||
break;
|
||||
case GL_TRANSFORM_FEEDBACK_BUFFER_START:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetInteger64Indexedv");
|
||||
if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname);
|
||||
return;
|
||||
}
|
||||
params[0] = ctx->TransformFeedback.Offset[index];
|
||||
break;
|
||||
case GL_TRANSFORM_FEEDBACK_BUFFER_SIZE:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetInteger64Indexedv");
|
||||
if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname);
|
||||
return;
|
||||
}
|
||||
params[0] = ctx->TransformFeedback.Size[index];
|
||||
break;
|
||||
case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING:
|
||||
CHECK_EXT1(EXT_transform_feedback, "GetInteger64Indexedv");
|
||||
if (index >= ctx->Const.MaxTransformFeedbackSeparateAttribs) {
|
||||
_mesa_error(ctx, GL_INVALID_VALUE, "glGetInteger64Indexedv(index=%u), index", pname);
|
||||
return;
|
||||
}
|
||||
params[0] = (GLint64)(ctx->TransformFeedback.Buffers[index]->Name);
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetInteger64Indexedv(pname=0x%x)", pname);
|
||||
}
|
||||
|
|
|
@ -1122,6 +1122,23 @@ StateVars = [
|
|||
( "GL_MAX_SERVER_WAIT_TIMEOUT", GLint64, ["ctx->Const.MaxServerWaitTimeout"], "",
|
||||
NoState, ["ARB_sync"] ),
|
||||
|
||||
# GL_EXT_transform_feedback
|
||||
( "GL_TRANSFORM_FEEDBACK_BUFFER_BINDING", GLint,
|
||||
["ctx->TransformFeedback.CurrentBuffer->Name"], "",
|
||||
NoState, ["EXT_transform_feedback"] ),
|
||||
( "GL_RASTERIZER_DISCARD", GLboolean,
|
||||
["ctx->TransformFeedback.RasterDiscard"], "",
|
||||
NoState, ["EXT_transform_feedback"] ),
|
||||
( "GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS", GLint,
|
||||
["ctx->Const.MaxTransformFeedbackInterleavedComponents"], "",
|
||||
NoState, ["EXT_transform_feedback"] ),
|
||||
( "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS", GLint,
|
||||
["ctx->Const.MaxTransformFeedbackSeparateAttribs"], "",
|
||||
NoState, ["EXT_transform_feedback"] ),
|
||||
( "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS", GLint,
|
||||
["ctx->Const.MaxTransformFeedbackSeparateComponents"], "",
|
||||
NoState, ["EXT_transform_feedback"] ),
|
||||
|
||||
# GL3
|
||||
( "GL_NUM_EXTENSIONS", GLint, ["_mesa_get_extension_count(ctx)"], "", NoState, NoExt ),
|
||||
( "GL_MAJOR_VERSION", GLint, ["ctx->VersionMajor"], "", NoState, NoExt ),
|
||||
|
@ -1134,6 +1151,7 @@ StateVars = [
|
|||
# The tuples are the same as above, with one exception: the "optional"
|
||||
# code field is instead the max legal index value.
|
||||
IndexedStateVars = [
|
||||
# GL_EXT_draw_buffers2 / GL3
|
||||
( "GL_BLEND", GLint, ["((ctx->Color.BlendEnabled >> index) & 1)"],
|
||||
"ctx->Const.MaxDrawBuffers", NoState, ["EXT_draw_buffers2"] ),
|
||||
( "GL_COLOR_WRITEMASK", GLint,
|
||||
|
@ -1142,6 +1160,21 @@ IndexedStateVars = [
|
|||
"ctx->Color.ColorMask[index][BCOMP] ? 1 : 0",
|
||||
"ctx->Color.ColorMask[index][ACOMP] ? 1 : 0" ],
|
||||
"ctx->Const.MaxDrawBuffers", NoState, ["EXT_draw_buffers2"] ),
|
||||
|
||||
# GL_EXT_transform_feedback
|
||||
( "GL_TRANSFORM_FEEDBACK_BUFFER_START", GLint64,
|
||||
["ctx->TransformFeedback.Offset[index]"],
|
||||
"ctx->Const.MaxTransformFeedbackSeparateAttribs",
|
||||
NoState, ["EXT_transform_feedback"] ),
|
||||
( "GL_TRANSFORM_FEEDBACK_BUFFER_SIZE", GLint64,
|
||||
["ctx->TransformFeedback.Size[index]"],
|
||||
"ctx->Const.MaxTransformFeedbackSeparateAttribs",
|
||||
NoState, ["EXT_transform_feedback"] ),
|
||||
( "GL_TRANSFORM_FEEDBACK_BUFFER_BINDING", GLint,
|
||||
["ctx->TransformFeedback.Buffers[index]->Name"],
|
||||
"ctx->Const.MaxTransformFeedbackSeparateAttribs",
|
||||
NoState, ["EXT_transform_feedback"] ),
|
||||
|
||||
# XXX more to come...
|
||||
]
|
||||
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
#define FEATURE_EXT_framebuffer_object 1
|
||||
#define FEATURE_EXT_pixel_buffer_object 1
|
||||
#define FEATURE_EXT_texture_sRGB FEATURE_GL
|
||||
#define FEATURE_EXT_transform_feedback FEATURE_GL
|
||||
|
||||
#define FEATURE_APPLE_object_purgeable FEATURE_GL
|
||||
#define FEATURE_ATI_fragment_shader FEATURE_GL
|
||||
|
|
|
@ -1910,6 +1910,11 @@ struct gl_query_state
|
|||
|
||||
/** GL_NV_conditional_render */
|
||||
struct gl_query_object *CondRenderQuery;
|
||||
|
||||
/** GL_EXT_transform_feedback */
|
||||
struct gl_query_object *PrimitivesGenerated;
|
||||
struct gl_query_object *PrimitivesWritten;
|
||||
|
||||
GLenum CondRenderMode;
|
||||
};
|
||||
|
||||
|
@ -1976,6 +1981,13 @@ struct gl_shader_program
|
|||
/** User-defined attribute bindings (glBindAttribLocation) */
|
||||
struct gl_program_parameter_list *Attributes;
|
||||
|
||||
/** Transform feedback varyings */
|
||||
struct {
|
||||
GLenum BufferMode;
|
||||
GLuint NumVarying;
|
||||
GLchar **VaryingNames; /**< Array [NumVarying] of char * */
|
||||
} TransformFeedback;
|
||||
|
||||
/* post-link info: */
|
||||
struct gl_vertex_program *VertexProgram; /**< Linked vertex program */
|
||||
struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */
|
||||
|
@ -2016,6 +2028,29 @@ struct gl_shader_state
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
* Context state for transform feedback.
|
||||
*/
|
||||
struct gl_transform_feedback
|
||||
{
|
||||
GLboolean Active; /**< Is transform feedback enabled? */
|
||||
GLenum Mode; /**< GL_POINTS, GL_LINES or GL_TRIANGLES */
|
||||
/** Start of feedback data in dest buffer */
|
||||
GLintptr Offset[MAX_FEEDBACK_ATTRIBS];
|
||||
/** Max data to put into dest buffer (in bytes) */
|
||||
GLsizeiptr Size[MAX_FEEDBACK_ATTRIBS];
|
||||
GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */
|
||||
|
||||
/** The general binding point (GL_TRANSFORM_FEEDBACK_BUFFER) */
|
||||
struct gl_buffer_object *CurrentBuffer;
|
||||
|
||||
/** The feedback buffers */
|
||||
GLuint BufferNames[MAX_FEEDBACK_ATTRIBS];
|
||||
struct gl_buffer_object *Buffers[MAX_FEEDBACK_ATTRIBS];
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* State which can be shared by multiple contexts:
|
||||
*/
|
||||
|
@ -2388,6 +2423,11 @@ struct gl_constants
|
|||
|
||||
/**< OpenGL version 3.x */
|
||||
GLbitfield ContextFlags; /**< Ex: GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT */
|
||||
|
||||
/** GL_EXT_transform_feedback */
|
||||
GLuint MaxTransformFeedbackSeparateAttribs;
|
||||
GLuint MaxTransformFeedbackSeparateComponents;
|
||||
GLuint MaxTransformFeedbackInterleavedComponents;
|
||||
};
|
||||
|
||||
|
||||
|
@ -2489,6 +2529,7 @@ struct gl_extensions
|
|||
GLboolean EXT_texture_mirror_clamp;
|
||||
GLboolean EXT_texture_sRGB;
|
||||
GLboolean EXT_texture_swizzle;
|
||||
GLboolean EXT_transform_feedback;
|
||||
GLboolean EXT_timer_query;
|
||||
GLboolean EXT_vertex_array;
|
||||
GLboolean EXT_vertex_array_bgra;
|
||||
|
@ -2956,6 +2997,8 @@ struct __GLcontextRec
|
|||
|
||||
struct gl_query_state Query; /**< occlusion, timer queries */
|
||||
|
||||
struct gl_transform_feedback TransformFeedback;
|
||||
|
||||
struct gl_buffer_object *CopyReadBuffer; /**< GL_ARB_copy_buffer */
|
||||
struct gl_buffer_object *CopyWriteBuffer; /**< GL_ARB_copy_buffer */
|
||||
/*@}*/
|
||||
|
|
|
@ -130,6 +130,42 @@ _mesa_init_query_object_functions(struct dd_function_table *driver)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return pointer to the query object binding point for the given target.
|
||||
* \return NULL if invalid target, else the address of binding point
|
||||
*/
|
||||
static struct gl_query_object **
|
||||
get_query_binding_point(GLcontext *ctx, GLenum target)
|
||||
{
|
||||
switch (target) {
|
||||
case GL_SAMPLES_PASSED_ARB:
|
||||
if (ctx->Extensions.ARB_occlusion_query)
|
||||
return &ctx->Query.CurrentOcclusionObject;
|
||||
else
|
||||
return NULL;
|
||||
case GL_TIME_ELAPSED_EXT:
|
||||
if (ctx->Extensions.EXT_timer_query)
|
||||
return &ctx->Query.CurrentTimerObject;
|
||||
else
|
||||
return NULL;
|
||||
#if FEATURE_EXT_transform_feedback
|
||||
case GL_PRIMITIVES_GENERATED:
|
||||
if (ctx->Extensions.EXT_transform_feedback)
|
||||
return &ctx->Query.PrimitivesGenerated;
|
||||
else
|
||||
return NULL;
|
||||
case GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:
|
||||
if (ctx->Extensions.EXT_transform_feedback)
|
||||
return &ctx->Query.PrimitivesWritten;
|
||||
else
|
||||
return NULL;
|
||||
#endif
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_GenQueriesARB(GLsizei n, GLuint *ids)
|
||||
{
|
||||
|
@ -214,36 +250,16 @@ _mesa_IsQueryARB(GLuint id)
|
|||
static void GLAPIENTRY
|
||||
_mesa_BeginQueryARB(GLenum target, GLuint id)
|
||||
{
|
||||
struct gl_query_object *q;
|
||||
struct gl_query_object *q, **bindpt;
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
|
||||
FLUSH_VERTICES(ctx, _NEW_DEPTH);
|
||||
|
||||
switch (target) {
|
||||
case GL_SAMPLES_PASSED_ARB:
|
||||
if (!ctx->Extensions.ARB_occlusion_query) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glBeginQueryARB(target)");
|
||||
return;
|
||||
}
|
||||
if (ctx->Query.CurrentOcclusionObject) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glBeginQueryARB");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case GL_TIME_ELAPSED_EXT:
|
||||
if (!ctx->Extensions.EXT_timer_query) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glBeginQueryARB(target)");
|
||||
return;
|
||||
}
|
||||
if (ctx->Query.CurrentTimerObject) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION, "glBeginQueryARB");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glBeginQueryARB(target)");
|
||||
return;
|
||||
bindpt = get_query_binding_point(ctx, target);
|
||||
if (!bindpt) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glBeginQueryARB(target)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (id == 0) {
|
||||
|
@ -275,12 +291,8 @@ _mesa_BeginQueryARB(GLenum target, GLuint id)
|
|||
q->Result = 0;
|
||||
q->Ready = GL_FALSE;
|
||||
|
||||
if (target == GL_SAMPLES_PASSED_ARB) {
|
||||
ctx->Query.CurrentOcclusionObject = q;
|
||||
}
|
||||
else if (target == GL_TIME_ELAPSED_EXT) {
|
||||
ctx->Query.CurrentTimerObject = q;
|
||||
}
|
||||
/* XXX should probably refcount query objects */
|
||||
*bindpt = q;
|
||||
|
||||
ctx->Driver.BeginQuery(ctx, q);
|
||||
}
|
||||
|
@ -289,34 +301,22 @@ _mesa_BeginQueryARB(GLenum target, GLuint id)
|
|||
static void GLAPIENTRY
|
||||
_mesa_EndQueryARB(GLenum target)
|
||||
{
|
||||
struct gl_query_object *q;
|
||||
struct gl_query_object *q, **bindpt;
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
|
||||
FLUSH_VERTICES(ctx, _NEW_DEPTH);
|
||||
|
||||
switch (target) {
|
||||
case GL_SAMPLES_PASSED_ARB:
|
||||
if (!ctx->Extensions.ARB_occlusion_query) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glEndQueryARB(target)");
|
||||
return;
|
||||
}
|
||||
q = ctx->Query.CurrentOcclusionObject;
|
||||
ctx->Query.CurrentOcclusionObject = NULL;
|
||||
break;
|
||||
case GL_TIME_ELAPSED_EXT:
|
||||
if (!ctx->Extensions.EXT_timer_query) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glEndQueryARB(target)");
|
||||
return;
|
||||
}
|
||||
q = ctx->Query.CurrentTimerObject;
|
||||
ctx->Query.CurrentTimerObject = NULL;
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glEndQueryARB(target)");
|
||||
return;
|
||||
bindpt = get_query_binding_point(ctx, target);
|
||||
if (!bindpt) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glEndQueryARB(target)");
|
||||
return;
|
||||
}
|
||||
|
||||
/* XXX should probably refcount query objects */
|
||||
q = *bindpt;
|
||||
*bindpt = NULL;
|
||||
|
||||
if (!q || !q->Active) {
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION,
|
||||
"glEndQueryARB(no matching glBeginQueryARB)");
|
||||
|
@ -331,30 +331,18 @@ _mesa_EndQueryARB(GLenum target)
|
|||
void GLAPIENTRY
|
||||
_mesa_GetQueryivARB(GLenum target, GLenum pname, GLint *params)
|
||||
{
|
||||
struct gl_query_object *q;
|
||||
struct gl_query_object *q, **bindpt;
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
|
||||
switch (target) {
|
||||
case GL_SAMPLES_PASSED_ARB:
|
||||
if (!ctx->Extensions.ARB_occlusion_query) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glEndQueryARB(target)");
|
||||
return;
|
||||
}
|
||||
q = ctx->Query.CurrentOcclusionObject;
|
||||
break;
|
||||
case GL_TIME_ELAPSED_EXT:
|
||||
if (!ctx->Extensions.EXT_timer_query) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glEndQueryARB(target)");
|
||||
return;
|
||||
}
|
||||
q = ctx->Query.CurrentTimerObject;
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryivARB(target)");
|
||||
return;
|
||||
bindpt = get_query_binding_point(ctx, target);
|
||||
if (!bindpt) {
|
||||
_mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryARB(target)");
|
||||
return;
|
||||
}
|
||||
|
||||
q = *bindpt;
|
||||
|
||||
switch (pname) {
|
||||
case GL_QUERY_COUNTER_BITS_ARB:
|
||||
*params = 8 * sizeof(q->Result);
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
#if FEATURE_texture_s3tc
|
||||
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#if defined(_WIN32) || defined(WIN32)
|
||||
#define DXTN_LIBNAME "dxtn.dll"
|
||||
#define RTLD_LAZY 0
|
||||
#define RTLD_GLOBAL 0
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue