Use uint8_t* instead of void* for texture data
NOTE: In texture_setimage, I had to move variables to the top of the scope because microsoft's C compiler will give the legacy C90 error of: 'illegal use of this type as an expression'. To sum it up, microsoft's C compiler is still utter garbage.master
parent
9478624b22
commit
7b12133af3
|
@ -508,7 +508,7 @@ uint32_t device_getheight(device_t device)
|
|||
|
||||
texture_t device_create_texture(device_t device, uint32_t width,
|
||||
uint32_t height, enum gs_color_format color_format,
|
||||
uint32_t levels, const void **data, uint32_t flags)
|
||||
uint32_t levels, const uint8_t **data, uint32_t flags)
|
||||
{
|
||||
gs_texture *texture = NULL;
|
||||
try {
|
||||
|
@ -527,7 +527,7 @@ texture_t device_create_texture(device_t device, uint32_t width,
|
|||
|
||||
texture_t device_create_cubetexture(device_t device, uint32_t size,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags)
|
||||
const uint8_t **data, uint32_t flags)
|
||||
{
|
||||
gs_texture *texture = NULL;
|
||||
try {
|
||||
|
@ -549,7 +549,7 @@ texture_t device_create_cubetexture(device_t device, uint32_t size,
|
|||
texture_t device_create_volumetexture(device_t device, uint32_t width,
|
||||
uint32_t height, uint32_t depth,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags)
|
||||
const uint8_t **data, uint32_t flags)
|
||||
{
|
||||
/* TODO */
|
||||
UNUSED_PARAMETER(device);
|
||||
|
@ -1502,7 +1502,7 @@ enum gs_color_format texture_getcolorformat(texture_t tex)
|
|||
return static_cast<gs_texture_2d*>(tex)->format;
|
||||
}
|
||||
|
||||
bool texture_map(texture_t tex, void **ptr, uint32_t *linesize)
|
||||
bool texture_map(texture_t tex, uint8_t **ptr, uint32_t *linesize)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
|
@ -1517,7 +1517,7 @@ bool texture_map(texture_t tex, void **ptr, uint32_t *linesize)
|
|||
if (FAILED(hr))
|
||||
return false;
|
||||
|
||||
*ptr = map.pData;
|
||||
*ptr = (uint8_t*)map.pData;
|
||||
*linesize = map.RowPitch;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -259,8 +259,8 @@ struct gs_texture_2d : gs_texture {
|
|||
bool genMipmaps;
|
||||
HANDLE sharedHandle;
|
||||
|
||||
void InitSRD(vector<D3D11_SUBRESOURCE_DATA> &srd, const void **data);
|
||||
void InitTexture(const void **data);
|
||||
void InitSRD(vector<D3D11_SUBRESOURCE_DATA> &srd, const uint8_t **data);
|
||||
void InitTexture(const uint8_t **data);
|
||||
void InitResourceView();
|
||||
void InitRenderTargets();
|
||||
|
||||
|
@ -280,8 +280,8 @@ struct gs_texture_2d : gs_texture {
|
|||
|
||||
gs_texture_2d(device_t device, uint32_t width, uint32_t height,
|
||||
gs_color_format colorFormat, uint32_t levels,
|
||||
const void **data, uint32_t flags, gs_texture_type type,
|
||||
bool gdiCompatible, bool shared);
|
||||
const uint8_t **data, uint32_t flags,
|
||||
gs_texture_type type, bool gdiCompatible, bool shared);
|
||||
};
|
||||
|
||||
struct gs_zstencil_buffer {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "d3d11-subsystem.hpp"
|
||||
|
||||
void gs_texture_2d::InitSRD(vector<D3D11_SUBRESOURCE_DATA> &srd,
|
||||
const void **data)
|
||||
const uint8_t **data)
|
||||
{
|
||||
uint32_t rowSizeBytes = width * gs_get_format_bpp(format);
|
||||
uint32_t texSizeBytes = height * rowSizeBytes / 8;
|
||||
|
@ -49,7 +49,7 @@ void gs_texture_2d::InitSRD(vector<D3D11_SUBRESOURCE_DATA> &srd,
|
|||
}
|
||||
}
|
||||
|
||||
void gs_texture_2d::InitTexture(const void **data)
|
||||
void gs_texture_2d::InitTexture(const uint8_t **data)
|
||||
{
|
||||
vector<D3D11_SUBRESOURCE_DATA> srd;
|
||||
D3D11_TEXTURE2D_DESC td;
|
||||
|
@ -142,9 +142,9 @@ void gs_texture_2d::InitRenderTargets()
|
|||
}
|
||||
|
||||
gs_texture_2d::gs_texture_2d(device_t device, uint32_t width, uint32_t height,
|
||||
gs_color_format colorFormat, uint32_t levels, const void **data,
|
||||
uint32_t flags, gs_texture_type type, bool gdiCompatible,
|
||||
bool shared)
|
||||
gs_color_format colorFormat, uint32_t levels,
|
||||
const uint8_t **data, uint32_t flags, gs_texture_type type,
|
||||
bool gdiCompatible, bool shared)
|
||||
: gs_texture (device, type, levels, colorFormat),
|
||||
width (width),
|
||||
height (height),
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
bool gl_init_face(GLenum target, GLenum type, uint32_t num_levels,
|
||||
GLenum format, GLint internal_format, bool compressed,
|
||||
uint32_t width, uint32_t height, uint32_t size,
|
||||
const void ***p_data)
|
||||
const uint8_t ***p_data)
|
||||
{
|
||||
bool success = true;
|
||||
const void **data = p_data ? *p_data : NULL;
|
||||
const uint8_t **data = p_data ? *p_data : NULL;
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < num_levels; i++) {
|
||||
|
|
|
@ -146,7 +146,7 @@ static inline bool gl_get_integer_v(GLenum pname, GLint *params)
|
|||
extern bool gl_init_face(GLenum target, GLenum type, uint32_t num_levels,
|
||||
GLenum format, GLint internal_format, bool compressed,
|
||||
uint32_t width, uint32_t height, uint32_t size,
|
||||
const void ***p_data);
|
||||
const uint8_t ***p_data);
|
||||
|
||||
extern bool gl_copy_texture(struct gs_device *device,
|
||||
GLuint dst, GLenum dst_target, uint32_t dst_x, uint32_t dst_y,
|
||||
|
|
|
@ -269,7 +269,7 @@ uint32_t device_getheight(device_t device)
|
|||
texture_t device_create_volumetexture(device_t device, uint32_t width,
|
||||
uint32_t height, uint32_t depth,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags)
|
||||
const uint8_t **data, uint32_t flags)
|
||||
{
|
||||
/* TODO */
|
||||
UNUSED_PARAMETER(device);
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "gl-subsystem.h"
|
||||
|
||||
static bool upload_texture_2d(struct gs_texture_2d *tex, const void **data)
|
||||
static bool upload_texture_2d(struct gs_texture_2d *tex, const uint8_t **data)
|
||||
{
|
||||
uint32_t row_size = tex->width * gs_get_format_bpp(tex->base.format);
|
||||
uint32_t tex_size = tex->height * row_size / 8;
|
||||
|
@ -76,7 +76,7 @@ static bool create_pixel_unpack_buffer(struct gs_texture_2d *tex)
|
|||
|
||||
texture_t device_create_texture(device_t device, uint32_t width,
|
||||
uint32_t height, enum gs_color_format color_format,
|
||||
uint32_t levels, const void **data, uint32_t flags)
|
||||
uint32_t levels, const uint8_t **data, uint32_t flags)
|
||||
{
|
||||
struct gs_texture_2d *tex = bzalloc(sizeof(struct gs_texture_2d));
|
||||
tex->base.device = device;
|
||||
|
@ -164,7 +164,7 @@ enum gs_color_format texture_getcolorformat(texture_t tex)
|
|||
return tex->format;
|
||||
}
|
||||
|
||||
bool texture_map(texture_t tex, void **ptr, uint32_t *linesize)
|
||||
bool texture_map(texture_t tex, uint8_t **ptr, uint32_t *linesize)
|
||||
{
|
||||
struct gs_texture_2d *tex2d = (struct gs_texture_2d*)tex;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "gl-subsystem.h"
|
||||
|
||||
static inline bool upload_texture_cube(struct gs_texture_cube *tex,
|
||||
const void **data)
|
||||
const uint8_t **data)
|
||||
{
|
||||
uint32_t row_size = tex->size * gs_get_format_bpp(tex->base.format);
|
||||
uint32_t tex_size = tex->size * row_size / 8;
|
||||
|
@ -60,7 +60,7 @@ static inline bool upload_texture_cube(struct gs_texture_cube *tex,
|
|||
|
||||
texture_t device_create_cubetexture(device_t device, uint32_t size,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags)
|
||||
const uint8_t **data, uint32_t flags)
|
||||
{
|
||||
struct gs_texture_cube *tex = bzalloc(sizeof(struct gs_texture_cube));
|
||||
tex->base.device = device;
|
||||
|
|
|
@ -36,14 +36,14 @@ EXPORT uint32_t device_getwidth(device_t device);
|
|||
EXPORT uint32_t device_getheight(device_t device);
|
||||
EXPORT texture_t device_create_texture(device_t device, uint32_t width,
|
||||
uint32_t height, enum gs_color_format color_format,
|
||||
uint32_t levels, const void **data, uint32_t flags);
|
||||
uint32_t levels, const uint8_t **data, uint32_t flags);
|
||||
EXPORT texture_t device_create_cubetexture(device_t device, uint32_t size,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags);
|
||||
const uint8_t **data, uint32_t flags);
|
||||
EXPORT texture_t device_create_volumetexture(device_t device, uint32_t width,
|
||||
uint32_t height, uint32_t depth,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags);
|
||||
const uint8_t **data, uint32_t flags);
|
||||
EXPORT zstencil_t device_create_zstencil(device_t device, uint32_t width,
|
||||
uint32_t height, enum gs_zstencil_format format);
|
||||
EXPORT stagesurf_t device_create_stagesurface(device_t device, uint32_t width,
|
||||
|
|
|
@ -37,14 +37,14 @@ struct gs_exports {
|
|||
uint32_t (*device_getheight)(device_t device);
|
||||
texture_t (*device_create_texture)(device_t device, uint32_t width,
|
||||
uint32_t height, enum gs_color_format color_format,
|
||||
uint32_t levels, const void **data, uint32_t flags);
|
||||
uint32_t levels, const uint8_t **data, uint32_t flags);
|
||||
texture_t (*device_create_cubetexture)(device_t device, uint32_t size,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags);
|
||||
const uint8_t **data, uint32_t flags);
|
||||
texture_t (*device_create_volumetexture)(device_t device,
|
||||
uint32_t width, uint32_t height, uint32_t depth,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags);
|
||||
const uint8_t **data, uint32_t flags);
|
||||
zstencil_t (*device_create_zstencil)(device_t device,
|
||||
uint32_t width, uint32_t height,
|
||||
enum gs_zstencil_format format);
|
||||
|
@ -134,7 +134,7 @@ struct gs_exports {
|
|||
uint32_t (*texture_getwidth)(texture_t tex);
|
||||
uint32_t (*texture_getheight)(texture_t tex);
|
||||
enum gs_color_format (*texture_getcolorformat)(texture_t tex);
|
||||
bool (*texture_map)(texture_t tex, void **ptr,
|
||||
bool (*texture_map)(texture_t tex, uint8_t **ptr,
|
||||
uint32_t *linesize);
|
||||
void (*texture_unmap)(texture_t tex);
|
||||
bool (*texture_isrect)(texture_t tex);
|
||||
|
|
|
@ -845,17 +845,19 @@ void gs_viewport_pop(void)
|
|||
da_pop_back(thread_graphics->viewport_stack);
|
||||
}
|
||||
|
||||
void texture_setimage(texture_t tex, const void *data, uint32_t linesize,
|
||||
void texture_setimage(texture_t tex, const uint8_t *data, uint32_t linesize,
|
||||
bool flip)
|
||||
{
|
||||
uint8_t *ptr;
|
||||
uint32_t linesize_out;
|
||||
uint32_t row_copy;
|
||||
int32_t height;
|
||||
int32_t y;
|
||||
|
||||
if (!thread_graphics || !tex)
|
||||
return;
|
||||
|
||||
void *ptr;
|
||||
uint32_t linesize_out;
|
||||
uint32_t row_copy;
|
||||
int32_t height = (int32_t)texture_getheight(tex);
|
||||
int32_t y;
|
||||
height = (int32_t)texture_getheight(tex);
|
||||
|
||||
if (!texture_map(tex, &ptr, &linesize_out))
|
||||
return;
|
||||
|
@ -864,8 +866,8 @@ void texture_setimage(texture_t tex, const void *data, uint32_t linesize,
|
|||
|
||||
if (flip) {
|
||||
for (y = height-1; y >= 0; y--)
|
||||
memcpy((uint8_t*)ptr + (uint32_t)y * linesize_out,
|
||||
(uint8_t*)data + (uint32_t)y * linesize,
|
||||
memcpy(ptr + (uint32_t)y * linesize_out,
|
||||
data + (uint32_t)y * linesize,
|
||||
row_copy);
|
||||
|
||||
} else if (linesize == linesize_out) {
|
||||
|
@ -873,8 +875,8 @@ void texture_setimage(texture_t tex, const void *data, uint32_t linesize,
|
|||
|
||||
} else {
|
||||
for (y = 0; y < height; y++)
|
||||
memcpy((uint8_t*)ptr + (uint32_t)y * linesize_out,
|
||||
(uint8_t*)data + (uint32_t)y * linesize,
|
||||
memcpy(ptr + (uint32_t)y * linesize_out,
|
||||
data + (uint32_t)y * linesize,
|
||||
row_copy);
|
||||
}
|
||||
|
||||
|
@ -967,7 +969,7 @@ static inline bool is_pow2(uint32_t size)
|
|||
|
||||
texture_t gs_create_texture(uint32_t width, uint32_t height,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags)
|
||||
const uint8_t **data, uint32_t flags)
|
||||
{
|
||||
graphics_t graphics = thread_graphics;
|
||||
bool pow2tex = is_pow2(width) && is_pow2(height);
|
||||
|
@ -999,7 +1001,7 @@ texture_t gs_create_texture(uint32_t width, uint32_t height,
|
|||
|
||||
texture_t gs_create_cubetexture(uint32_t size,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags)
|
||||
const uint8_t **data, uint32_t flags)
|
||||
{
|
||||
graphics_t graphics = thread_graphics;
|
||||
bool pow2tex = is_pow2(size);
|
||||
|
@ -1032,7 +1034,7 @@ texture_t gs_create_cubetexture(uint32_t size,
|
|||
|
||||
texture_t gs_create_volumetexture(uint32_t width, uint32_t height,
|
||||
uint32_t depth, enum gs_color_format color_format,
|
||||
uint32_t levels, const void **data, uint32_t flags)
|
||||
uint32_t levels, const uint8_t **data, uint32_t flags)
|
||||
{
|
||||
graphics_t graphics = thread_graphics;
|
||||
if (!graphics) return NULL;
|
||||
|
@ -1653,7 +1655,7 @@ enum gs_color_format texture_getcolorformat(texture_t tex)
|
|||
return graphics->exports.texture_getcolorformat(tex);
|
||||
}
|
||||
|
||||
bool texture_map(texture_t tex, void **ptr, uint32_t *linesize)
|
||||
bool texture_map(texture_t tex, uint8_t **ptr, uint32_t *linesize)
|
||||
{
|
||||
graphics_t graphics = thread_graphics;
|
||||
if (!graphics || !tex) return false;
|
||||
|
|
|
@ -495,7 +495,7 @@ EXPORT void gs_set3dmode(double fovy, double znear, double zvar);
|
|||
EXPORT void gs_viewport_push(void);
|
||||
EXPORT void gs_viewport_pop(void);
|
||||
|
||||
EXPORT void texture_setimage(texture_t tex, const void *data,
|
||||
EXPORT void texture_setimage(texture_t tex, const uint8_t *data,
|
||||
uint32_t linesize, bool invert);
|
||||
EXPORT void cubetexture_setimage(texture_t cubetex, uint32_t side,
|
||||
const void *data, uint32_t linesize, bool invert);
|
||||
|
@ -514,13 +514,13 @@ EXPORT uint32_t gs_getheight(void);
|
|||
|
||||
EXPORT texture_t gs_create_texture(uint32_t width, uint32_t height,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags);
|
||||
const uint8_t **data, uint32_t flags);
|
||||
EXPORT texture_t gs_create_cubetexture(uint32_t size,
|
||||
enum gs_color_format color_format, uint32_t levels,
|
||||
const void **data, uint32_t flags);
|
||||
const uint8_t **data, uint32_t flags);
|
||||
EXPORT texture_t gs_create_volumetexture(uint32_t width, uint32_t height,
|
||||
uint32_t depth, enum gs_color_format color_format,
|
||||
uint32_t levels, const void **data, uint32_t flags);
|
||||
uint32_t levels, const uint8_t **data, uint32_t flags);
|
||||
|
||||
EXPORT zstencil_t gs_create_zstencil(uint32_t width, uint32_t height,
|
||||
enum gs_zstencil_format format);
|
||||
|
@ -618,7 +618,7 @@ EXPORT void texture_destroy(texture_t tex);
|
|||
EXPORT uint32_t texture_getwidth(texture_t tex);
|
||||
EXPORT uint32_t texture_getheight(texture_t tex);
|
||||
EXPORT enum gs_color_format texture_getcolorformat(texture_t tex);
|
||||
EXPORT bool texture_map(texture_t tex, void **ptr, uint32_t *linesize);
|
||||
EXPORT bool texture_map(texture_t tex, uint8_t **ptr, uint32_t *linesize);
|
||||
EXPORT void texture_unmap(texture_t tex);
|
||||
/** special-case function (GL only) - specifies whether the texture is a
|
||||
* GL_TEXTURE_RECTANGLE type, which doesn't use normalized texture
|
||||
|
|
|
@ -909,7 +909,7 @@ static bool update_async_texture(struct obs_source *source,
|
|||
texture_t tex = source->async_texture;
|
||||
texrender_t texrender = source->async_convert_texrender;
|
||||
enum convert_type type = get_convert_type(frame->format);
|
||||
void *ptr;
|
||||
uint8_t *ptr;
|
||||
uint32_t linesize;
|
||||
|
||||
source->async_format = frame->format;
|
||||
|
|
|
@ -317,7 +317,7 @@ void XCompcapMain::updateSettings(obs_data_t settings)
|
|||
const uint8_t* texDataArr[] = { texData, 0 };
|
||||
|
||||
p->tex = gs_create_texture(width(), height(), cf, 1,
|
||||
(const void**)texDataArr, 0);
|
||||
texDataArr, 0);
|
||||
|
||||
delete[] texData;
|
||||
|
||||
|
|
|
@ -48,14 +48,14 @@ static void xcursor_create(xcursor_t *data, XFixesCursorImage *xc) {
|
|||
if (data->tex
|
||||
&& data->last_height == xc->width
|
||||
&& data->last_width == xc->height) {
|
||||
texture_setimage(data->tex, (void **) pixels,
|
||||
texture_setimage(data->tex, (const uint8_t *) pixels,
|
||||
xc->width * sizeof(uint32_t), False);
|
||||
} else {
|
||||
if (data->tex)
|
||||
texture_destroy(data->tex);
|
||||
|
||||
data->tex = gs_create_texture(xc->width, xc->height,
|
||||
GS_BGRA, 1, (const void **) &pixels, GS_DYNAMIC);
|
||||
GS_BGRA, 1, (const uint8_t **) &pixels, GS_DYNAMIC);
|
||||
}
|
||||
|
||||
bfree(pixels);
|
||||
|
|
Loading…
Reference in New Issue