Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
virgl-es
mesa
Commits
135fe907
Commit
135fe907
authored
Nov 28, 2012
by
Marek Olšák
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mesa: move some helper functions from fboobject.c to glformats.c
Reviewed-by:
Brian Paul
<
brianp@vmware.com
>
parent
0fda2e91
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
127 additions
and
119 deletions
+127
-119
src/mesa/main/fbobject.c
src/mesa/main/fbobject.c
+8
-119
src/mesa/main/glformats.c
src/mesa/main/glformats.c
+113
-0
src/mesa/main/glformats.h
src/mesa/main/glformats.h
+6
-0
No files found.
src/mesa/main/fbobject.c
View file @
135fe907
...
...
@@ -2716,127 +2716,16 @@ compatible_color_datatypes(gl_format srcFormat, gl_format dstFormat)
}
/**
* Return the equivalent non-generic internal format.
* This is useful for comparing whether two internal formats are semantically
* equivalent.
*/
static
GLenum
get_nongeneric_internalformat
(
GLenum
format
)
{
switch
(
format
)
{
/* GL 1.1 formats. */
case
4
:
case
GL_RGBA
:
return
GL_RGBA8
;
case
3
:
case
GL_RGB
:
return
GL_RGB8
;
case
2
:
case
GL_LUMINANCE_ALPHA
:
return
GL_LUMINANCE8_ALPHA8
;
case
1
:
case
GL_LUMINANCE
:
return
GL_LUMINANCE8
;
case
GL_ALPHA
:
return
GL_ALPHA8
;
case
GL_INTENSITY
:
return
GL_INTENSITY8
;
/* GL_ARB_texture_rg */
case
GL_RED
:
return
GL_R8
;
case
GL_RG
:
return
GL_RG8
;
/* GL_EXT_texture_sRGB */
case
GL_SRGB
:
return
GL_SRGB8
;
case
GL_SRGB_ALPHA
:
return
GL_SRGB8_ALPHA8
;
case
GL_SLUMINANCE
:
return
GL_SLUMINANCE8
;
case
GL_SLUMINANCE_ALPHA
:
return
GL_SLUMINANCE8_ALPHA8
;
/* GL_EXT_texture_snorm */
case
GL_RGBA_SNORM
:
return
GL_RGBA8_SNORM
;
case
GL_RGB_SNORM
:
return
GL_RGB8_SNORM
;
case
GL_RG_SNORM
:
return
GL_RG8_SNORM
;
case
GL_RED_SNORM
:
return
GL_R8_SNORM
;
case
GL_LUMINANCE_ALPHA_SNORM
:
return
GL_LUMINANCE8_ALPHA8_SNORM
;
case
GL_LUMINANCE_SNORM
:
return
GL_LUMINANCE8_SNORM
;
case
GL_ALPHA_SNORM
:
return
GL_ALPHA8_SNORM
;
case
GL_INTENSITY_SNORM
:
return
GL_INTENSITY8_SNORM
;
default:
return
format
;
}
}
static
GLenum
get_linear_internalformat
(
GLenum
format
)
{
switch
(
format
)
{
case
GL_SRGB
:
return
GL_RGB
;
case
GL_SRGB_ALPHA
:
return
GL_RGBA
;
case
GL_SRGB8
:
return
GL_RGB8
;
case
GL_SRGB8_ALPHA8
:
return
GL_RGBA8
;
case
GL_SLUMINANCE
:
return
GL_LUMINANCE8
;
case
GL_SLUMINANCE_ALPHA
:
return
GL_LUMINANCE8_ALPHA8
;
default:
return
format
;
}
}
static
GLboolean
compatible_resolve_formats
(
const
struct
gl_renderbuffer
*
colorR
eadRb
,
const
struct
gl_renderbuffer
*
colorD
rawRb
)
compatible_resolve_formats
(
const
struct
gl_renderbuffer
*
r
eadRb
,
const
struct
gl_renderbuffer
*
d
rawRb
)
{
GLenum
readFormat
,
drawFormat
;
/* The simple case where we know the backing Mesa formats are the same.
*/
if
(
_mesa_get_srgb_format_linear
(
colorR
eadRb
->
Format
)
==
_mesa_get_srgb_format_linear
(
colorD
rawRb
->
Format
))
{
if
(
_mesa_get_srgb_format_linear
(
r
eadRb
->
Format
)
==
_mesa_get_srgb_format_linear
(
d
rawRb
->
Format
))
{
return
GL_TRUE
;
}
...
...
@@ -2850,10 +2739,10 @@ compatible_resolve_formats(const struct gl_renderbuffer *colorReadRb,
*
* Blits between linear and sRGB formats are also allowed.
*/
readFormat
=
get_nongeneric_internalformat
(
colorR
eadRb
->
InternalFormat
);
drawFormat
=
get_nongeneric_internalformat
(
colorD
rawRb
->
InternalFormat
);
readFormat
=
get_linear_internalformat
(
readFormat
);
drawFormat
=
get_linear_internalformat
(
drawFormat
);
readFormat
=
_mesa_
get_nongeneric_internalformat
(
r
eadRb
->
InternalFormat
);
drawFormat
=
_mesa_
get_nongeneric_internalformat
(
d
rawRb
->
InternalFormat
);
readFormat
=
_mesa_
get_linear_internalformat
(
readFormat
);
drawFormat
=
_mesa_
get_linear_internalformat
(
drawFormat
);
if
(
readFormat
==
drawFormat
)
{
return
GL_TRUE
;
...
...
src/mesa/main/glformats.c
View file @
135fe907
...
...
@@ -1007,6 +1007,119 @@ _mesa_generic_compressed_format_to_uncompressed_format(GLenum format)
}
/**
* Return the equivalent non-generic internal format.
* This is useful for comparing whether two internal formats are equivalent.
*/
GLenum
_mesa_get_nongeneric_internalformat
(
GLenum
format
)
{
switch
(
format
)
{
/* GL 1.1 formats. */
case
4
:
case
GL_RGBA
:
return
GL_RGBA8
;
case
3
:
case
GL_RGB
:
return
GL_RGB8
;
case
2
:
case
GL_LUMINANCE_ALPHA
:
return
GL_LUMINANCE8_ALPHA8
;
case
1
:
case
GL_LUMINANCE
:
return
GL_LUMINANCE8
;
case
GL_ALPHA
:
return
GL_ALPHA8
;
case
GL_INTENSITY
:
return
GL_INTENSITY8
;
/* GL_ARB_texture_rg */
case
GL_RED
:
return
GL_R8
;
case
GL_RG
:
return
GL_RG8
;
/* GL_EXT_texture_sRGB */
case
GL_SRGB
:
return
GL_SRGB8
;
case
GL_SRGB_ALPHA
:
return
GL_SRGB8_ALPHA8
;
case
GL_SLUMINANCE
:
return
GL_SLUMINANCE8
;
case
GL_SLUMINANCE_ALPHA
:
return
GL_SLUMINANCE8_ALPHA8
;
/* GL_EXT_texture_snorm */
case
GL_RGBA_SNORM
:
return
GL_RGBA8_SNORM
;
case
GL_RGB_SNORM
:
return
GL_RGB8_SNORM
;
case
GL_RG_SNORM
:
return
GL_RG8_SNORM
;
case
GL_RED_SNORM
:
return
GL_R8_SNORM
;
case
GL_LUMINANCE_ALPHA_SNORM
:
return
GL_LUMINANCE8_ALPHA8_SNORM
;
case
GL_LUMINANCE_SNORM
:
return
GL_LUMINANCE8_SNORM
;
case
GL_ALPHA_SNORM
:
return
GL_ALPHA8_SNORM
;
case
GL_INTENSITY_SNORM
:
return
GL_INTENSITY8_SNORM
;
default:
return
format
;
}
}
/**
* Convert an sRGB internal format to linear.
*/
GLenum
_mesa_get_linear_internalformat
(
GLenum
format
)
{
switch
(
format
)
{
case
GL_SRGB
:
return
GL_RGB
;
case
GL_SRGB_ALPHA
:
return
GL_RGBA
;
case
GL_SRGB8
:
return
GL_RGB8
;
case
GL_SRGB8_ALPHA8
:
return
GL_RGBA8
;
case
GL_SLUMINANCE
:
return
GL_LUMINANCE8
;
case
GL_SLUMINANCE_ALPHA
:
return
GL_LUMINANCE8_ALPHA8
;
default:
return
format
;
}
}
/**
* Do error checking of format/type combinations for glReadPixels,
* glDrawPixels and glTex[Sub]Image. Note that depending on the format
...
...
src/mesa/main/glformats.h
View file @
135fe907
...
...
@@ -94,6 +94,12 @@ _mesa_base_format_has_channel(GLenum base_format, GLenum pname);
extern
GLenum
_mesa_generic_compressed_format_to_uncompressed_format
(
GLenum
format
);
extern
GLenum
_mesa_get_nongeneric_internalformat
(
GLenum
format
);
extern
GLenum
_mesa_get_linear_internalformat
(
GLenum
format
);
extern
GLenum
_mesa_error_check_format_and_type
(
const
struct
gl_context
*
ctx
,
GLenum
format
,
GLenum
type
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment