add "intel texture compression"

This commit is contained in:
hyzboy 2020-07-29 22:12:44 +08:00
parent 43e336f964
commit ec9fc767d9
14 changed files with 4706 additions and 0 deletions

View File

@ -0,0 +1 @@
ispc -O2 intel_texture_compression.ispc -o intel_texture_compression.obj -h intel_texture_compression.h --arch=x86-64 --target=sse2,sse4,avx,avx2 --opt=fast-math

View File

@ -0,0 +1,105 @@
//
// intel_texture_compression.h
// (Header automatically generated by the ispc compiler.)
// DO NOT EDIT THIS FILE.
//
#pragma once
#include <stdint.h>
#ifdef __cplusplus
namespace ispc { /* namespace */
#endif // __cplusplus
#ifndef __ISPC_ALIGN__
#if defined(__clang__) || !defined(_MSC_VER)
// Clang, GCC, ICC
#define __ISPC_ALIGN__(s) __attribute__((aligned(s)))
#define __ISPC_ALIGNED_STRUCT__(s) struct __ISPC_ALIGN__(s)
#else
// Visual Studio
#define __ISPC_ALIGN__(s) __declspec(align(s))
#define __ISPC_ALIGNED_STRUCT__(s) __ISPC_ALIGN__(s) struct
#endif
#endif
#ifndef __ISPC_STRUCT_rgba_surface__
#define __ISPC_STRUCT_rgba_surface__
struct rgba_surface {
uint8_t * ptr;
int32_t width;
int32_t height;
int32_t stride;
};
#endif
#ifndef __ISPC_STRUCT_bc6h_enc_settings__
#define __ISPC_STRUCT_bc6h_enc_settings__
struct bc6h_enc_settings {
bool slow_mode;
bool fast_mode;
int32_t refineIterations_1p;
int32_t refineIterations_2p;
int32_t fastSkipTreshold;
};
#endif
#ifndef __ISPC_STRUCT_bc7_enc_settings__
#define __ISPC_STRUCT_bc7_enc_settings__
struct bc7_enc_settings {
bool mode_selection[4];
int32_t refineIterations[8];
bool skip_mode2;
int32_t fastSkipTreshold_mode1;
int32_t fastSkipTreshold_mode3;
int32_t fastSkipTreshold_mode7;
int32_t mode45_channel0;
int32_t refineIterations_channel;
int32_t channels;
};
#endif
#ifndef __ISPC_STRUCT_etc_enc_settings__
#define __ISPC_STRUCT_etc_enc_settings__
struct etc_enc_settings {
int32_t fastSkipTreshold;
};
#endif
///////////////////////////////////////////////////////////////////////////
// Functions exported from ispc code
///////////////////////////////////////////////////////////////////////////
#if defined(__cplusplus) && (! defined(__ISPC_NO_EXTERN_C) || !__ISPC_NO_EXTERN_C )
extern "C" {
#endif // __cplusplus
extern void CompressBlocksBC1_ispc(struct rgba_surface * src, uint8_t * dst);
extern void CompressBlocksBC3_ispc(struct rgba_surface * src, uint8_t * dst);
extern void CompressBlocksBC6H_ispc(struct rgba_surface * src, uint8_t * dst, struct bc6h_enc_settings * settings);
extern void CompressBlocksBC7_ispc(struct rgba_surface * src, uint8_t * dst, struct bc7_enc_settings * settings);
extern void CompressBlocksETC1_ispc(struct rgba_surface * src, uint8_t * dst, struct etc_enc_settings * settings);
#if defined(__cplusplus) && (! defined(__ISPC_NO_EXTERN_C) || !__ISPC_NO_EXTERN_C )
} /* end extern C */
#endif // __cplusplus
#ifndef __ISPC_ALIGN__
#if defined(__clang__) || !defined(_MSC_VER)
// Clang, GCC, ICC
#define __ISPC_ALIGN__(s) __attribute__((aligned(s)))
#define __ISPC_ALIGNED_STRUCT__(s) struct __ISPC_ALIGN__(s)
#else
// Visual Studio
#define __ISPC_ALIGN__(s) __declspec(align(s))
#define __ISPC_ALIGNED_STRUCT__(s) __ISPC_ALIGN__(s) struct
#endif
#endif
#ifdef __cplusplus
} /* namespace */
#endif // __cplusplus

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,90 @@
//
// intel_texture_compression_avx.h
// (Header automatically generated by the ispc compiler.)
// DO NOT EDIT THIS FILE.
//
#pragma once
#include <stdint.h>
#ifdef __cplusplus
namespace ispc { /* namespace */
#endif // __cplusplus
#ifndef __ISPC_ALIGN__
#if defined(__clang__) || !defined(_MSC_VER)
// Clang, GCC, ICC
#define __ISPC_ALIGN__(s) __attribute__((aligned(s)))
#define __ISPC_ALIGNED_STRUCT__(s) struct __ISPC_ALIGN__(s)
#else
// Visual Studio
#define __ISPC_ALIGN__(s) __declspec(align(s))
#define __ISPC_ALIGNED_STRUCT__(s) __ISPC_ALIGN__(s) struct
#endif
#endif
#ifndef __ISPC_STRUCT_rgba_surface__
#define __ISPC_STRUCT_rgba_surface__
struct rgba_surface {
uint8_t * ptr;
int32_t width;
int32_t height;
int32_t stride;
};
#endif
#ifndef __ISPC_STRUCT_bc6h_enc_settings__
#define __ISPC_STRUCT_bc6h_enc_settings__
struct bc6h_enc_settings {
bool slow_mode;
bool fast_mode;
int32_t refineIterations_1p;
int32_t refineIterations_2p;
int32_t fastSkipTreshold;
};
#endif
#ifndef __ISPC_STRUCT_bc7_enc_settings__
#define __ISPC_STRUCT_bc7_enc_settings__
struct bc7_enc_settings {
bool mode_selection[4];
int32_t refineIterations[8];
bool skip_mode2;
int32_t fastSkipTreshold_mode1;
int32_t fastSkipTreshold_mode3;
int32_t fastSkipTreshold_mode7;
int32_t mode45_channel0;
int32_t refineIterations_channel;
int32_t channels;
};
#endif
#ifndef __ISPC_STRUCT_etc_enc_settings__
#define __ISPC_STRUCT_etc_enc_settings__
struct etc_enc_settings {
int32_t fastSkipTreshold;
};
#endif
///////////////////////////////////////////////////////////////////////////
// Functions exported from ispc code
///////////////////////////////////////////////////////////////////////////
#if defined(__cplusplus) && (! defined(__ISPC_NO_EXTERN_C) || !__ISPC_NO_EXTERN_C )
extern "C" {
#endif // __cplusplus
extern void CompressBlocksBC1_ispc(struct rgba_surface * src, uint8_t * dst);
extern void CompressBlocksBC3_ispc(struct rgba_surface * src, uint8_t * dst);
extern void CompressBlocksBC6H_ispc(struct rgba_surface * src, uint8_t * dst, struct bc6h_enc_settings * settings);
extern void CompressBlocksBC7_ispc(struct rgba_surface * src, uint8_t * dst, struct bc7_enc_settings * settings);
extern void CompressBlocksETC1_ispc(struct rgba_surface * src, uint8_t * dst, struct etc_enc_settings * settings);
#if defined(__cplusplus) && (! defined(__ISPC_NO_EXTERN_C) || !__ISPC_NO_EXTERN_C )
} /* end extern C */
#endif // __cplusplus
#ifdef __cplusplus
} /* namespace */
#endif // __cplusplus

View File

@ -0,0 +1,90 @@
//
// intel_texture_compression_avx2.h
// (Header automatically generated by the ispc compiler.)
// DO NOT EDIT THIS FILE.
//
#pragma once
#include <stdint.h>
#ifdef __cplusplus
namespace ispc { /* namespace */
#endif // __cplusplus
#ifndef __ISPC_ALIGN__
#if defined(__clang__) || !defined(_MSC_VER)
// Clang, GCC, ICC
#define __ISPC_ALIGN__(s) __attribute__((aligned(s)))
#define __ISPC_ALIGNED_STRUCT__(s) struct __ISPC_ALIGN__(s)
#else
// Visual Studio
#define __ISPC_ALIGN__(s) __declspec(align(s))
#define __ISPC_ALIGNED_STRUCT__(s) __ISPC_ALIGN__(s) struct
#endif
#endif
#ifndef __ISPC_STRUCT_rgba_surface__
#define __ISPC_STRUCT_rgba_surface__
struct rgba_surface {
uint8_t * ptr;
int32_t width;
int32_t height;
int32_t stride;
};
#endif
#ifndef __ISPC_STRUCT_bc6h_enc_settings__
#define __ISPC_STRUCT_bc6h_enc_settings__
struct bc6h_enc_settings {
bool slow_mode;
bool fast_mode;
int32_t refineIterations_1p;
int32_t refineIterations_2p;
int32_t fastSkipTreshold;
};
#endif
#ifndef __ISPC_STRUCT_bc7_enc_settings__
#define __ISPC_STRUCT_bc7_enc_settings__
struct bc7_enc_settings {
bool mode_selection[4];
int32_t refineIterations[8];
bool skip_mode2;
int32_t fastSkipTreshold_mode1;
int32_t fastSkipTreshold_mode3;
int32_t fastSkipTreshold_mode7;
int32_t mode45_channel0;
int32_t refineIterations_channel;
int32_t channels;
};
#endif
#ifndef __ISPC_STRUCT_etc_enc_settings__
#define __ISPC_STRUCT_etc_enc_settings__
struct etc_enc_settings {
int32_t fastSkipTreshold;
};
#endif
///////////////////////////////////////////////////////////////////////////
// Functions exported from ispc code
///////////////////////////////////////////////////////////////////////////
#if defined(__cplusplus) && (! defined(__ISPC_NO_EXTERN_C) || !__ISPC_NO_EXTERN_C )
extern "C" {
#endif // __cplusplus
extern void CompressBlocksBC1_ispc(struct rgba_surface * src, uint8_t * dst);
extern void CompressBlocksBC3_ispc(struct rgba_surface * src, uint8_t * dst);
extern void CompressBlocksBC6H_ispc(struct rgba_surface * src, uint8_t * dst, struct bc6h_enc_settings * settings);
extern void CompressBlocksBC7_ispc(struct rgba_surface * src, uint8_t * dst, struct bc7_enc_settings * settings);
extern void CompressBlocksETC1_ispc(struct rgba_surface * src, uint8_t * dst, struct etc_enc_settings * settings);
#if defined(__cplusplus) && (! defined(__ISPC_NO_EXTERN_C) || !__ISPC_NO_EXTERN_C )
} /* end extern C */
#endif // __cplusplus
#ifdef __cplusplus
} /* namespace */
#endif // __cplusplus

View File

@ -0,0 +1,90 @@
//
// intel_texture_compression_sse2.h
// (Header automatically generated by the ispc compiler.)
// DO NOT EDIT THIS FILE.
//
#pragma once
#include <stdint.h>
#ifdef __cplusplus
namespace ispc { /* namespace */
#endif // __cplusplus
#ifndef __ISPC_ALIGN__
#if defined(__clang__) || !defined(_MSC_VER)
// Clang, GCC, ICC
#define __ISPC_ALIGN__(s) __attribute__((aligned(s)))
#define __ISPC_ALIGNED_STRUCT__(s) struct __ISPC_ALIGN__(s)
#else
// Visual Studio
#define __ISPC_ALIGN__(s) __declspec(align(s))
#define __ISPC_ALIGNED_STRUCT__(s) __ISPC_ALIGN__(s) struct
#endif
#endif
#ifndef __ISPC_STRUCT_rgba_surface__
#define __ISPC_STRUCT_rgba_surface__
struct rgba_surface {
uint8_t * ptr;
int32_t width;
int32_t height;
int32_t stride;
};
#endif
#ifndef __ISPC_STRUCT_bc6h_enc_settings__
#define __ISPC_STRUCT_bc6h_enc_settings__
struct bc6h_enc_settings {
bool slow_mode;
bool fast_mode;
int32_t refineIterations_1p;
int32_t refineIterations_2p;
int32_t fastSkipTreshold;
};
#endif
#ifndef __ISPC_STRUCT_bc7_enc_settings__
#define __ISPC_STRUCT_bc7_enc_settings__
struct bc7_enc_settings {
bool mode_selection[4];
int32_t refineIterations[8];
bool skip_mode2;
int32_t fastSkipTreshold_mode1;
int32_t fastSkipTreshold_mode3;
int32_t fastSkipTreshold_mode7;
int32_t mode45_channel0;
int32_t refineIterations_channel;
int32_t channels;
};
#endif
#ifndef __ISPC_STRUCT_etc_enc_settings__
#define __ISPC_STRUCT_etc_enc_settings__
struct etc_enc_settings {
int32_t fastSkipTreshold;
};
#endif
///////////////////////////////////////////////////////////////////////////
// Functions exported from ispc code
///////////////////////////////////////////////////////////////////////////
#if defined(__cplusplus) && (! defined(__ISPC_NO_EXTERN_C) || !__ISPC_NO_EXTERN_C )
extern "C" {
#endif // __cplusplus
extern void CompressBlocksBC1_ispc(struct rgba_surface * src, uint8_t * dst);
extern void CompressBlocksBC3_ispc(struct rgba_surface * src, uint8_t * dst);
extern void CompressBlocksBC6H_ispc(struct rgba_surface * src, uint8_t * dst, struct bc6h_enc_settings * settings);
extern void CompressBlocksBC7_ispc(struct rgba_surface * src, uint8_t * dst, struct bc7_enc_settings * settings);
extern void CompressBlocksETC1_ispc(struct rgba_surface * src, uint8_t * dst, struct etc_enc_settings * settings);
#if defined(__cplusplus) && (! defined(__ISPC_NO_EXTERN_C) || !__ISPC_NO_EXTERN_C )
} /* end extern C */
#endif // __cplusplus
#ifdef __cplusplus
} /* namespace */
#endif // __cplusplus

View File

@ -0,0 +1,90 @@
//
// intel_texture_compression_sse4.h
// (Header automatically generated by the ispc compiler.)
// DO NOT EDIT THIS FILE.
//
#pragma once
#include <stdint.h>
#ifdef __cplusplus
namespace ispc { /* namespace */
#endif // __cplusplus
#ifndef __ISPC_ALIGN__
#if defined(__clang__) || !defined(_MSC_VER)
// Clang, GCC, ICC
#define __ISPC_ALIGN__(s) __attribute__((aligned(s)))
#define __ISPC_ALIGNED_STRUCT__(s) struct __ISPC_ALIGN__(s)
#else
// Visual Studio
#define __ISPC_ALIGN__(s) __declspec(align(s))
#define __ISPC_ALIGNED_STRUCT__(s) __ISPC_ALIGN__(s) struct
#endif
#endif
#ifndef __ISPC_STRUCT_rgba_surface__
#define __ISPC_STRUCT_rgba_surface__
struct rgba_surface {
uint8_t * ptr;
int32_t width;
int32_t height;
int32_t stride;
};
#endif
#ifndef __ISPC_STRUCT_bc6h_enc_settings__
#define __ISPC_STRUCT_bc6h_enc_settings__
struct bc6h_enc_settings {
bool slow_mode;
bool fast_mode;
int32_t refineIterations_1p;
int32_t refineIterations_2p;
int32_t fastSkipTreshold;
};
#endif
#ifndef __ISPC_STRUCT_bc7_enc_settings__
#define __ISPC_STRUCT_bc7_enc_settings__
struct bc7_enc_settings {
bool mode_selection[4];
int32_t refineIterations[8];
bool skip_mode2;
int32_t fastSkipTreshold_mode1;
int32_t fastSkipTreshold_mode3;
int32_t fastSkipTreshold_mode7;
int32_t mode45_channel0;
int32_t refineIterations_channel;
int32_t channels;
};
#endif
#ifndef __ISPC_STRUCT_etc_enc_settings__
#define __ISPC_STRUCT_etc_enc_settings__
struct etc_enc_settings {
int32_t fastSkipTreshold;
};
#endif
///////////////////////////////////////////////////////////////////////////
// Functions exported from ispc code
///////////////////////////////////////////////////////////////////////////
#if defined(__cplusplus) && (! defined(__ISPC_NO_EXTERN_C) || !__ISPC_NO_EXTERN_C )
extern "C" {
#endif // __cplusplus
extern void CompressBlocksBC1_ispc(struct rgba_surface * src, uint8_t * dst);
extern void CompressBlocksBC3_ispc(struct rgba_surface * src, uint8_t * dst);
extern void CompressBlocksBC6H_ispc(struct rgba_surface * src, uint8_t * dst, struct bc6h_enc_settings * settings);
extern void CompressBlocksBC7_ispc(struct rgba_surface * src, uint8_t * dst, struct bc7_enc_settings * settings);
extern void CompressBlocksETC1_ispc(struct rgba_surface * src, uint8_t * dst, struct etc_enc_settings * settings);
#if defined(__cplusplus) && (! defined(__ISPC_NO_EXTERN_C) || !__ISPC_NO_EXTERN_C )
} /* end extern C */
#endif // __cplusplus
#ifdef __cplusplus
} /* namespace */
#endif // __cplusplus

View File

@ -0,0 +1,440 @@
////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
////////////////////////////////////////////////////////////////////////////////
#include "ispc_texcomp.h"
#include "intel_texture_compression.h"
void GetProfile_ultrafast(bc7_enc_settings* settings)
{
settings->channels = 3;
// mode02
settings->mode_selection[0] = false;
settings->skip_mode2 = true;
settings->refineIterations[0] = 2;
settings->refineIterations[2] = 2;
// mode13
settings->mode_selection[1] = false;
settings->fastSkipTreshold_mode1 = 3;
settings->fastSkipTreshold_mode3 = 1;
settings->fastSkipTreshold_mode7 = 0;
settings->refineIterations[1] = 2;
settings->refineIterations[3] = 1;
// mode45
settings->mode_selection[2] = false;
settings->mode45_channel0 = 0;
settings->refineIterations_channel = 0;
settings->refineIterations[4] = 2;
settings->refineIterations[5] = 2;
// mode6
settings->mode_selection[3] = true;
settings->refineIterations[6] = 1;
}
void GetProfile_veryfast(bc7_enc_settings* settings)
{
settings->channels = 3;
// mode02
settings->mode_selection[0] = false;
settings->skip_mode2 = true;
settings->refineIterations[0] = 2;
settings->refineIterations[2] = 2;
// mode13
settings->mode_selection[1] = true;
settings->fastSkipTreshold_mode1 = 3;
settings->fastSkipTreshold_mode3 = 1;
settings->fastSkipTreshold_mode7 = 0;
settings->refineIterations[1] = 2;
settings->refineIterations[3] = 1;
// mode45
settings->mode_selection[2] = false;
settings->mode45_channel0 = 0;
settings->refineIterations_channel = 0;
settings->refineIterations[4] = 2;
settings->refineIterations[5] = 2;
// mode6
settings->mode_selection[3] = true;
settings->refineIterations[6] = 1;
}
void GetProfile_fast(bc7_enc_settings* settings)
{
settings->channels = 3;
// mode02
settings->mode_selection[0] = false;
settings->skip_mode2 = true;
settings->refineIterations[0] = 2;
settings->refineIterations[2] = 2;
// mode13
settings->mode_selection[1] = true;
settings->fastSkipTreshold_mode1 = 12;
settings->fastSkipTreshold_mode3 = 4;
settings->fastSkipTreshold_mode7 = 0;
settings->refineIterations[1] = 2;
settings->refineIterations[3] = 1;
// mode45
settings->mode_selection[2] = false;
settings->mode45_channel0 = 0;
settings->refineIterations_channel = 0;
settings->refineIterations[4] = 2;
settings->refineIterations[5] = 2;
// mode6
settings->mode_selection[3] = true;
settings->refineIterations[6] = 2;
}
void GetProfile_basic(bc7_enc_settings* settings)
{
settings->channels = 3;
// mode02
settings->mode_selection[0] = true;
settings->skip_mode2 = true;
settings->refineIterations[0] = 2;
settings->refineIterations[2] = 2;
// mode13
settings->mode_selection[1] = true;
settings->fastSkipTreshold_mode1 = 8+4;
settings->fastSkipTreshold_mode3 = 8;
settings->fastSkipTreshold_mode7 = 0;
settings->refineIterations[1] = 2;
settings->refineIterations[3] = 2;
// mode45
settings->mode_selection[2] = true;
settings->mode45_channel0 = 0;
settings->refineIterations_channel = 2;
settings->refineIterations[4] = 2;
settings->refineIterations[5] = 2;
// mode6
settings->mode_selection[3] = true;
settings->refineIterations[6] = 2;
}
void GetProfile_slow(bc7_enc_settings* settings)
{
settings->channels = 3;
int moreRefine = 2;
// mode02
settings->mode_selection[0] = true;
settings->skip_mode2 = false;
settings->refineIterations[0] = 2+moreRefine;
settings->refineIterations[2] = 2+moreRefine;
// mode13
settings->mode_selection[1] = true;
settings->fastSkipTreshold_mode1 = 64;
settings->fastSkipTreshold_mode3 = 64;
settings->fastSkipTreshold_mode7 = 0;
settings->refineIterations[1] = 2+moreRefine;
settings->refineIterations[3] = 2+moreRefine;
// mode45
settings->mode_selection[2] = true;
settings->mode45_channel0 = 0;
settings->refineIterations_channel = 2+moreRefine;
settings->refineIterations[4] = 2+moreRefine;
settings->refineIterations[5] = 2+moreRefine;
// mode6
settings->mode_selection[3] = true;
settings->refineIterations[6] = 2+moreRefine;
}
void GetProfile_alpha_ultrafast(bc7_enc_settings* settings)
{
settings->channels = 4;
// mode02
settings->mode_selection[0] = false;
settings->skip_mode2 = true;
settings->refineIterations[0] = 2;
settings->refineIterations[2] = 2;
// mode137
settings->mode_selection[1] = false;
settings->fastSkipTreshold_mode1 = 0;
settings->fastSkipTreshold_mode3 = 0;
settings->fastSkipTreshold_mode7 = 4;
settings->refineIterations[1] = 1;
settings->refineIterations[3] = 1;
settings->refineIterations[7] = 2;
// mode45
settings->mode_selection[2] = true;
settings->mode45_channel0 = 3;
settings->refineIterations_channel = 1;
settings->refineIterations[4] = 1;
settings->refineIterations[5] = 1;
// mode6
settings->mode_selection[3] = true;
settings->refineIterations[6] = 2;
}
void GetProfile_alpha_veryfast(bc7_enc_settings* settings)
{
settings->channels = 4;
// mode02
settings->mode_selection[0] = false;
settings->skip_mode2 = true;
settings->refineIterations[0] = 2;
settings->refineIterations[2] = 2;
// mode137
settings->mode_selection[1] = true;
settings->fastSkipTreshold_mode1 = 0;
settings->fastSkipTreshold_mode3 = 0;
settings->fastSkipTreshold_mode7 = 4;
settings->refineIterations[1] = 1;
settings->refineIterations[3] = 1;
settings->refineIterations[7] = 2;
// mode45
settings->mode_selection[2] = true;
settings->mode45_channel0 = 3;
settings->refineIterations_channel = 2;
settings->refineIterations[4] = 2;
settings->refineIterations[5] = 2;
// mode6
settings->mode_selection[3] = true;
settings->refineIterations[6] = 2;
}
void GetProfile_alpha_fast(bc7_enc_settings* settings)
{
settings->channels = 4;
// mode02
settings->mode_selection[0] = false;
settings->skip_mode2 = true;
settings->refineIterations[0] = 2;
settings->refineIterations[2] = 2;
// mode137
settings->mode_selection[1] = true;
settings->fastSkipTreshold_mode1 = 4;
settings->fastSkipTreshold_mode3 = 4;
settings->fastSkipTreshold_mode7 = 8;
settings->refineIterations[1] = 1;
settings->refineIterations[3] = 1;
settings->refineIterations[7] = 2;
// mode45
settings->mode_selection[2] = true;
settings->mode45_channel0 = 3;
settings->refineIterations_channel = 2;
settings->refineIterations[4] = 2;
settings->refineIterations[5] = 2;
// mode6
settings->mode_selection[3] = true;
settings->refineIterations[6] = 2;
}
void GetProfile_alpha_basic(bc7_enc_settings* settings)
{
settings->channels = 4;
// mode02
settings->mode_selection[0] = true;
settings->skip_mode2 = true;
settings->refineIterations[0] = 2;
settings->refineIterations[2] = 2;
// mode137
settings->mode_selection[1] = true;
settings->fastSkipTreshold_mode1 = 8+4;
settings->fastSkipTreshold_mode3 = 8;
settings->fastSkipTreshold_mode7 = 8;
settings->refineIterations[1] = 2;
settings->refineIterations[3] = 2;
settings->refineIterations[7] = 2;
// mode45
settings->mode_selection[2] = true;
settings->mode45_channel0 = 0;
settings->refineIterations_channel = 2;
settings->refineIterations[4] = 2;
settings->refineIterations[5] = 2;
// mode6
settings->mode_selection[3] = true;
settings->refineIterations[6] = 2;
}
void GetProfile_alpha_slow(bc7_enc_settings* settings)
{
settings->channels = 4;
int moreRefine = 2;
// mode02
settings->mode_selection[0] = true;
settings->skip_mode2 = false;
settings->refineIterations[0] = 2+moreRefine;
settings->refineIterations[2] = 2+moreRefine;
// mode137
settings->mode_selection[1] = true;
settings->fastSkipTreshold_mode1 = 64;
settings->fastSkipTreshold_mode3 = 64;
settings->fastSkipTreshold_mode7 = 64;
settings->refineIterations[1] = 2+moreRefine;
settings->refineIterations[3] = 2+moreRefine;
settings->refineIterations[7] = 2+moreRefine;
// mode45
settings->mode_selection[2] = true;
settings->mode45_channel0 = 0;
settings->refineIterations_channel = 2+moreRefine;
settings->refineIterations[4] = 2+moreRefine;
settings->refineIterations[5] = 2+moreRefine;
// mode6
settings->mode_selection[3] = true;
settings->refineIterations[6] = 2+moreRefine;
}
void GetProfile_bc6h_veryfast(bc6h_enc_settings* settings)
{
settings->slow_mode = false;
settings->fast_mode = true;
settings->fastSkipTreshold = 0;
settings->refineIterations_1p = 0;
settings->refineIterations_2p = 0;
}
void GetProfile_bc6h_fast(bc6h_enc_settings* settings)
{
settings->slow_mode = false;
settings->fast_mode = true;
settings->fastSkipTreshold = 2;
settings->refineIterations_1p = 0;
settings->refineIterations_2p = 1;
}
void GetProfile_bc6h_basic(bc6h_enc_settings* settings)
{
settings->slow_mode = false;
settings->fast_mode = false;
settings->fastSkipTreshold = 4;
settings->refineIterations_1p = 2;
settings->refineIterations_2p = 2;
}
void GetProfile_bc6h_slow(bc6h_enc_settings* settings)
{
settings->slow_mode = true;
settings->fast_mode = false;
settings->fastSkipTreshold = 10;
settings->refineIterations_1p = 2;
settings->refineIterations_2p = 2;
}
void GetProfile_bc6h_veryslow(bc6h_enc_settings* settings)
{
settings->slow_mode = true;
settings->fast_mode = false;
settings->fastSkipTreshold = 32;
settings->refineIterations_1p = 2;
settings->refineIterations_2p = 2;
}
void GetProfile_etc_slow(etc_enc_settings* settings)
{
settings->fastSkipTreshold = 6;
}
void CompressBlocksBC1(const rgba_surface* src, uint8_t* dst)
{
ispc::CompressBlocksBC1_ispc((ispc::rgba_surface*)src, dst);
}
void CompressBlocksBC3(const rgba_surface* src, uint8_t* dst)
{
ispc::CompressBlocksBC3_ispc((ispc::rgba_surface*)src, dst);
}
void CompressBlocksBC7(const rgba_surface* src, uint8_t* dst, bc7_enc_settings* settings)
{
ispc::CompressBlocksBC7_ispc((ispc::rgba_surface*)src, dst, (ispc::bc7_enc_settings*)settings);
}
void CompressBlocksBC6H(const rgba_surface* src, uint8_t* dst, bc6h_enc_settings* settings)
{
ispc::CompressBlocksBC6H_ispc((ispc::rgba_surface*)src, dst, (ispc::bc6h_enc_settings*)settings);
}
void CompressBlocksETC1(const rgba_surface* src, uint8_t* dst, etc_enc_settings* settings)
{
ispc::CompressBlocksETC1_ispc((ispc::rgba_surface*)src, dst, (ispc::etc_enc_settings*)settings);
}

View File

@ -0,0 +1,109 @@
////////////////////////////////////////////////////////////////////////////////
// Copyright 2017 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy
// of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
////////////////////////////////////////////////////////////////////////////////
#include <cstdint>
struct rgba_surface
{
uint8_t* ptr;
int32_t width;
int32_t height;
int32_t stride;
};
struct bc7_enc_settings
{
bool mode_selection[4];
int refineIterations[8];
bool skip_mode2;
int fastSkipTreshold_mode1;
int fastSkipTreshold_mode3;
int fastSkipTreshold_mode7;
int mode45_channel0;
int refineIterations_channel;
int channels;
};
struct bc6h_enc_settings
{
bool slow_mode;
bool fast_mode;
int refineIterations_1p;
int refineIterations_2p;
int fastSkipTreshold;
};
struct etc_enc_settings
{
int fastSkipTreshold;
};
struct astc_enc_settings
{
int block_width;
int block_height;
int fastSkipTreshold;
int refineIterations;
};
// profiles for RGB data (alpha channel will be ignored)
extern "C" void GetProfile_ultrafast(bc7_enc_settings* settings);
extern "C" void GetProfile_veryfast(bc7_enc_settings* settings);
extern "C" void GetProfile_fast(bc7_enc_settings* settings);
extern "C" void GetProfile_basic(bc7_enc_settings* settings);
extern "C" void GetProfile_slow(bc7_enc_settings* settings);
// profiles for RGBA inputs
extern "C" void GetProfile_alpha_ultrafast(bc7_enc_settings* settings);
extern "C" void GetProfile_alpha_veryfast(bc7_enc_settings* settings);
extern "C" void GetProfile_alpha_fast(bc7_enc_settings* settings);
extern "C" void GetProfile_alpha_basic(bc7_enc_settings* settings);
extern "C" void GetProfile_alpha_slow(bc7_enc_settings* settings);
// profiles for BC6H (RGB HDR)
extern "C" void GetProfile_bc6h_veryfast(bc6h_enc_settings* settings);
extern "C" void GetProfile_bc6h_fast(bc6h_enc_settings* settings);
extern "C" void GetProfile_bc6h_basic(bc6h_enc_settings* settings);
extern "C" void GetProfile_bc6h_slow(bc6h_enc_settings* settings);
extern "C" void GetProfile_bc6h_veryslow(bc6h_enc_settings* settings);
// profiles for ETC
extern "C" void GetProfile_etc_slow(etc_enc_settings* settings);
// profiles for ASTC
extern "C" void GetProfile_astc_fast(astc_enc_settings* settings, int block_width, int block_height);
/*
Notes:
- input width and height need to be a multiple of block size
- LDR input is 32 bit/pixel (sRGB), HDR is 64 bit/pixel (half float)
- dst buffer must be allocated with enough space for the compressed texture:
4 bytes/block for BC1/ETC1, 8 bytes/block for BC3/BC6H/BC7/ASTC
the blocks are stored in raster scan order (natural CPU texture layout)
- you can use GetProfile_* functions to select various speed/quality tradeoffs.
- the RGB profiles are slightly faster as they ignore the alpha channel
*/
extern "C" void CompressBlocksBC1(const rgba_surface* src, uint8_t* dst);
extern "C" void CompressBlocksBC3(const rgba_surface* src, uint8_t* dst);
extern "C" void CompressBlocksBC6H(const rgba_surface* src, uint8_t* dst, bc6h_enc_settings* settings);
extern "C" void CompressBlocksBC7(const rgba_surface* src, uint8_t* dst, bc7_enc_settings* settings);
extern "C" void CompressBlocksETC1(const rgba_surface* src, uint8_t* dst, etc_enc_settings* settings);
extern "C" void CompressBlocksASTC(const rgba_surface* src, uint8_t* dst, astc_enc_settings* settings);