This commit is contained in:
lachrymaL 2022-08-18 12:17:43 -04:00
parent 0691a4d690
commit a9ed7e44d5
No known key found for this signature in database
GPG key ID: F3640ACFA174B1C1
4080 changed files with 1779729 additions and 171 deletions

5
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,5 @@
{
"files.associations": {
"xstring": "cpp"
}
}

View file

@ -1,63 +1,118 @@
#include "ADVect.h"
#include "Graphics.h"
#include <SDL2/SDL_syswm.h>
#include <bgfx/bgfx.h>
#include <bgfx/platform.h>
#include <iostream>
#include <Environment.h>
namespace {
SDL_Window* window;
// SDL_Renderer* renderer;
std::string m_name;
bool running = false;
u16 m_width = 1280;
u16 m_height = 720;
bool m_keys[65536]{};
std::vector<NVL::Parse::Scene> scenes;
u32 current_scene = 0;
std::vector<NVL::Environment::Variable> m_text{};
NVL::String speaker;
u32 scene_pos = 0;
}
namespace ADVect {
Game::Game(std::string name, std::vector<NVL::Parse::Scene>& scenes) :
m_name(name),
m_running(false),
m_scenes(scenes),
m_text(""),
m_scene_pos(0),
m_current_scene(0) {
if (SDL_Init(SDL_INIT_EVERYTHING)) {
std::cerr << "SDL shit itself : " << SDL_GetError() << std::endl;
void Init(std::string name, const std::vector<NVL::Parse::Scene>& sc) {
m_name = name;
scenes = sc; // sure make a copy whatever
if (SDL_Init(SDL_INIT_VIDEO)) {
std::cerr << "Failed to init SDL: " << SDL_GetError() << std::endl;
}
m_window = SDL_CreateWindow(m_name.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 800, 600, SDL_WINDOW_SHOWN);
m_surface = SDL_GetWindowSurface(m_window);
window = SDL_CreateWindow(m_name.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, m_width, m_height, SDL_WINDOW_SHOWN);
//renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
//SDL_SetRenderDrawColor(renderer, 50, 50, 50, 255);
bgfx::Init bgfxInit;
bgfxInit.type = bgfx::RendererType::Count; // Automatically choose a renderer.
bgfxInit.resolution.width = m_width;
bgfxInit.resolution.height = m_height;
bgfxInit.resolution.reset = BGFX_RESET_VSYNC;
#if !BX_PLATFORM_EMSCRIPTEN
SDL_SysWMinfo wmi;
SDL_VERSION(&wmi.version);
if (!SDL_GetWindowWMInfo(window, &wmi)) {
std::cerr << "SDL_SysWMinfo could not be retrieved: " << SDL_GetError() << std::endl;
}
#endif
#if BX_PLATFORM_WINDOWS
bgfxInit.platformData.nwh = wmi.info.win.window;
#elif BX_PLATFORM_OSX
bgfxInit.platformData.nwh = wmi.info.cocoa.window;
#elif BX_PLATFORM_LINUX
bgfxInit.platformData.ndt = wmi.info.x11.display;
bgfxInit.platformData.nwh = (void*)(uintptr_t)wmi.info.x11.window;
#elif BX_PLATFORM_EMSCRIPTEN
bgfxInit.platformData.nwh = (void*)"#canvas";
#endif
bgfx::init(bgfxInit);
bgfx::setDebug(BGFX_DEBUG_TEXT);
bgfx::setViewClear(0, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH, 0x443355ff, 1.0f, 0);
bgfx::setViewRect(0, 0, 0, m_width, m_height);
ADVect::Graphics::Init();
NVL::Environment::ENVIRONMENT.enter("Say", NVL::Environment::Variable([&](std::vector<NVL::Environment::Variable> args) {
m_text = std::get<std::string>(NVL::Environment::Variable(args[0]).value);
m_text = args;
return NVL::Environment::Type::Nil;
}, 1));
}, 2));
NVL::Environment::ENVIRONMENT.enter("SwitchSpeaker", NVL::Environment::Variable([&](std::vector<NVL::Environment::Variable> args) {
m_speaker = std::get<std::string>(NVL::Environment::Variable(args[0]).value);
speaker = std::get<NVL::String>(NVL::Environment::Variable(args[0]).value);
return NVL::Environment::Type::Nil;
}, 1));
Advance();
}
Game::~Game() {
SDL_DestroyWindow(m_window);
void Shutdown() {
bgfx::shutdown();
// SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
}
void Game::Advance() {
int curr_size = m_scenes[m_current_scene].get().size();
while (m_scene_pos < curr_size) {
if (std::get<std::string>(m_scenes[m_current_scene].get()[m_scene_pos][0].value) == "Say") {
NVL::Environment::Apply(m_scenes[m_current_scene].get()[m_scene_pos]);
m_scene_pos++;
void Advance() {
int curr_size = scenes[current_scene].get().size();
while (scene_pos < curr_size) {
if (std::get<std::string>(scenes[current_scene].get()[scene_pos][0].value) == "Say") {
NVL::Environment::Apply(scenes[current_scene].get()[scene_pos]);
scene_pos++;
return;
}
else {
NVL::Environment::Apply(m_scenes[m_current_scene].get()[m_scene_pos]);
m_scene_pos++;
NVL::Environment::Apply(scenes[current_scene].get()[scene_pos]);
scene_pos++;
}
switch (curr_size - m_scene_pos) {
switch (curr_size - scene_pos) {
case 0:
m_current_scene = -1;
current_scene = -1;
return;
case 1:
return;
default:
if (std::get<std::string>(m_scenes[m_current_scene].get()[m_scene_pos + 1][0].value) == "Say") {
NVL::Environment::Apply(m_scenes[m_current_scene].get()[m_scene_pos]);
m_scene_pos++;
if (std::get<std::string>(scenes[current_scene].get()[scene_pos + 1][0].value) == "Say") {
NVL::Environment::Apply(scenes[current_scene].get()[scene_pos]);
scene_pos++;
return;
}
break;
@ -65,10 +120,10 @@ namespace ADVect {
}
}
void Game::Update() {
void Update() {
if (m_keys[SDL_SCANCODE_SPACE]) {
if (m_current_scene == -1) {
m_running = false;
if (current_scene == -1) {
running = false;
return;
}
Advance();
@ -76,23 +131,29 @@ namespace ADVect {
}
}
void Game::Render() {
SDL_FillRect(m_surface, nullptr, SDL_MapRGBA(m_surface->format, 0, 0, 0, 255));
void Render() {
//SDL_RenderClear(renderer);
bgfx::touch(0);
ADVect::Graphics::RenderString(m_speaker, m_surface, 10, 250);
ADVect::Graphics::RenderString(m_text, m_surface, 10, 300);
ADVect::Graphics::RenderString(speaker, 50, 300, { 255, 255, 255, 255 });
ADVect::Graphics::RenderStringMarkdown(m_text[0], 50, 600, { 255, 255, 255, 255 });
bgfx::dbgTextClear();
bgfx::dbgTextPrintf(5, 35, 0xf0, "alivemaster TNBL");
//SDL_RenderPresent(renderer);
//SDL_Delay(10);
bgfx::frame();
SDL_UpdateWindowSurface(m_window);
SDL_Delay(10);
}
void Game::Run() {
m_running = true;
while (m_running) {
void Run() {
running = true;
while (running) {
for (SDL_Event event; SDL_PollEvent(&event);) {
switch (event.type) {
case SDL_QUIT:
m_running = false;
running = false;
break;
case SDL_KEYDOWN:
m_keys[event.key.keysym.scancode] = true;
@ -113,8 +174,9 @@ int main(int argc, char* argv[]) {
const std::string PJ_DIR = "E:\\Archive\\Projects\\NouVeL\\NVL\\";
std::vector<NVL::Parse::Scene> SCENES = NVL::Parse::ParseFile(PJ_DIR + "dialogue.nvl");
ADVect::Game game("Test", SCENES);
game.Run();
ADVect::Init("Test", SCENES);
ADVect::Run();
ADVect::Shutdown();
return 0;
}

View file

@ -1,31 +1,19 @@
#include <vector>
#include <string>
#include <Parser.h>
#include <SDL2/SDL.h>
#include <Environment.h>
#include <Common.h>
namespace ADVect {
class Game {
public:
Game(std::string name, std::vector<NVL::Parse::Scene>& scenes);
~Game();
void Run();
void Update();
void Render();
void Init(std::string name, const std::vector<NVL::Parse::Scene>& sc);
void Shutdown();
void Advance();
private:
SDL_Window* m_window;
std::string m_name;
bool m_running;
void Run();
void Update();
void Render();
int m_keys[65536] = {};
SDL_Surface* m_surface;
std::vector<NVL::Parse::Scene>& m_scenes;
int m_current_scene;
std::string m_text;
std::string m_speaker;
int m_scene_pos;
};
void Advance();
}

View file

@ -10,9 +10,10 @@ add_executable (Game "ADVect.cpp" "Graphics.cpp" "Bindings.cpp")
# TODO: Add tests and install targets if needed.
include_directories ("include" "../NVL/")
add_subdirectory("ext/freetype")
add_subdirectory("ext/bgfx")
if (WIN32)
target_link_libraries (Game ${PROJECT_SOURCE_DIR}/lib/SDL2.lib ${PROJECT_SOURCE_DIR}/lib/SDL2main.lib NVL freetype)
target_link_libraries (Game ${PROJECT_SOURCE_DIR}/lib/SDL2.lib ${PROJECT_SOURCE_DIR}/lib/SDL2main.lib NVL freetype bgfx bx)
else ()
target_link_libraries (Game NVL freetype)
target_link_libraries (Game NVL freetype bgfx bx)
add_compile_options(-lSDL2)
endif ()

View file

@ -1,16 +1,13 @@
#include <ft2build.h>
#include FT_FREETYPE_H
#include "Graphics.h"
#include <iostream>
#include <locale>
#include <codecvt>
namespace {
FT_Library library;
FT_Error error;
FT_Face face;
SDL_Color colors[256];
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
}
namespace ADVect::Graphics {
@ -24,7 +21,7 @@ namespace ADVect::Graphics {
if (error == FT_Err_Unknown_File_Format) {
std::cerr << "FreeType Unknown_File_Format: " << error << std::endl;
}
else if (error) {
else if (error) {
std::cerr << "FreeType font loading error: " << error << std::endl;
}
@ -32,45 +29,55 @@ namespace ADVect::Graphics {
if (error == FT_Err_Unknown_File_Format) {
std::cerr << "FreeType Set_Char_Size error: " << error << std::endl;
}
for (int i = 0; i < 256; i++)
{
colors[i].r = colors[i].g = colors[i].b = i;
}
}
void Destroy() {
FT_Done_Face(face);
FT_Done_FreeType(library);
}
void RenderString(const std::string& s, SDL_Surface* surface, int pos_x, int pos_y) {
std::wstring w = converter.from_bytes(s);
void RenderString(const NVL::String& s, u32 pos_x, u32 pos_y, const SDL_Color& attr) {
FT_GlyphSlot slot = face->glyph;
SDL_Rect pos = { pos_x, pos_y, 0, 0 };
for (const auto& c : w) {
SDL_Color colors[256];
for (u16 i = 0; i < 256; i++) {
colors[i].r = f32(i) / 255.f * (f32)attr.r;
colors[i].g = f32(i) / 255.f * (f32)attr.g;
colors[i].b = f32(i) / 255.f * (f32)attr.b;
}
for (const auto& c : s) {
error = FT_Load_Char(face, c, FT_LOAD_RENDER);
if (error)
continue;
if (error) continue;
SDL_Surface* glyph = SDL_CreateRGBSurfaceFrom(
slot->bitmap.buffer,
slot->bitmap.width,
slot->bitmap.rows,
8,
slot->bitmap.pitch,
0, 0, 0, 255);
//SDL_Surface* surface = SDL_CreateRGBSurfaceFrom(
// slot->bitmap.buffer,
// slot->bitmap.width,
// slot->bitmap.rows,
// 8,
// slot->bitmap.pitch,
// 0, 0, 0, 255);
SDL_SetPaletteColors(glyph->format->palette, colors, 0, 256);
//SDL_SetPaletteColors(surface->format->palette, colors, 0, 256);
SDL_SetSurfaceBlendMode(glyph, SDL_BlendMode::SDL_BLENDMODE_NONE);
SDL_Rect pos = { pos_x + slot->bitmap_left, pos_y - slot->bitmap_top, 0, 0 };
SDL_BlitSurface(glyph, nullptr, surface, &pos);
SDL_FreeSurface(glyph);
//SDL_Texture* glyph = SDL_CreateTextureFromSurface(renderer, surface);
pos_x += slot->advance.x >> 6;
pos_y += slot->advance.y >> 6;
//SDL_SetTextureBlendMode(glyph, SDL_BlendMode::SDL_BLENDMODE_NONE);
// SDL_SetTextureAlphaMod(glyph, attr.a);
pos.x += slot->bitmap_left;
pos.y -= slot->bitmap_top;
//SDL_RenderCopy(renderer, glyph, nullptr, &pos);
//SDL_DestroyTexture(glyph);
//SDL_FreeSurface(surface);
pos.x += slot->advance.x >> 6;
pos.y += slot->advance.y >> 6;
}
}
}
void RenderStringMarkdown(const NVL::Environment::Variable& s, u32 pos_x, u32 pos_y, const SDL_Color& attr) {
NVL::String str = std::get<NVL::String>(s.value);
RenderString(str, pos_x, pos_y, attr);
}
}

View file

@ -1,11 +1,11 @@
#include <ft2build.h>
#include FT_FREETYPE_H
#include <SDL2/SDL.h>
#include <string>
#include <Common.h>
#include <Environment.h>
namespace ADVect::Graphics {
void Init();
void Destroy();
void RenderString(const std::string& s, SDL_Surface* surface, int pos_x, int pos_y);
void RenderString(const NVL::String& s, u32 pos_x, u32 pos_y, const SDL_Color& attr);
void RenderStringMarkdown(const NVL::Environment::Variable& s, u32 pos_x, u32 pos_y, const SDL_Color& attr);
}

View file

@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "gitsubmodule"
directory: "/"
schedule:
interval: "monthly"

View file

@ -0,0 +1,58 @@
# https://github.com/openblack/bgfx.cmake/blob/master/.github/workflows/ci.yml
name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
job:
name: ${{ matrix.os }} ${{ matrix.cc }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
- os: ubuntu-latest
cc: gcc
cxx: g++
- os: ubuntu-latest
cc: clang
cxx: clang++
- os: macos-latest
env:
# Indicates the CMake build directory where project files and binaries are being produced.
CMAKE_BUILD_DIR: ${{ github.workspace }}/build/
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt install -y libgl1-mesa-dev
if: matrix.os == 'ubuntu-latest'
# Setup the build machine with the most recent versions of CMake and Ninja. Both are cached if not already: on subsequent runs both will be quickly restored from GitHub cache service.
- uses: lukka/get-cmake@latest
# On Windows runners, let's ensure to have the Developer Command Prompt environment setup correctly. As used here the Developer Command Prompt created is targeting x64 and using the default the Windows SDK.
- uses: ilammy/msvc-dev-cmd@v1
# Run CMake to generate Ninja project files
- name: Generate project files
run: |
cmake -B "${{ env.CMAKE_BUILD_DIR }}" -GNinja -DCMAKE_BUILD_TYPE=Release
# Build the whole project with Ninja (which is spawn by CMake).
- name: Build
run: |
cmake --build "${{ env.CMAKE_BUILD_DIR }}"

View file

@ -0,0 +1,100 @@
# https://github.com/openblack/bgfx.cmake/blob/master/.github/workflows/release.yml
name: Release
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
version:
name: version
runs-on: ubuntu-latest
outputs:
revision: ${{ steps.version.outputs.revision }}
sha: ${{ steps.version.outputs.sha }}
tag: ${{ steps.version.outputs.tag }}
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
fetch-depth: 0
- id: version
run: |
API_VERSION=$(grep -Eo "BGFX_API_VERSION UINT32_C\([0-9]+\)" bgfx/include/bgfx/defines.h | grep -Eo "[0-9]+" | tail -1)
REVISION=$(cd bgfx && git rev-list HEAD --count)
SHA=$(cd bgfx && git rev-parse HEAD)
SHA7="${GITHUB_SHA::7}"
TAG="v1.${API_VERSION}.${REVISION}-${SHA7}"
echo "::set-output name=revision::${REVISION}"
echo "::set-output name=sha::${SHA}"
echo "::set-output name=tag::${TAG}"
build:
name: ${{ matrix.os }}
needs: [ version ]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
- os: ubuntu-latest
- os: macos-latest
env:
# Indicates the CMake build directory where project files and binaries are being produced.
CMAKE_BUILD_DIR: ${{ github.workspace }}/build/
CMAKE_INSTALL_DIR: ${{ github.workspace }}/install/
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt install -y libgl1-mesa-dev
if: matrix.os == 'ubuntu-latest'
# Setup the build machine with the most recent versions of CMake and Ninja. Both are cached if not already: on subsequent runs both will be quickly restored from GitHub cache service.
- uses: lukka/get-cmake@latest
# On Windows runners, let's ensure to have the Developer Command Prompt environment setup correctly. As used here the Developer Command Prompt created is targeting x64 and using the default the Windows SDK.
- uses: ilammy/msvc-dev-cmd@v1
# Update version
- name: Update version.h
run: |
sed "s/ BGFX_REV_NUMBER .*/ BGFX_REV_NUMBER ${{ needs.version.outputs.revision }}/g" bgfx/src/version.h > version.tmp && mv version.tmp bgfx/src/version.h
sed "s/ BGFX_REV_SHA1 .*/ BGFX_REV_SHA1 \"${{ needs.version.outputs.sha }}\"/g" bgfx/src/version.h > version.tmp && mv version.tmp bgfx/src/version.h
shell: bash
# Run CMake to generate project files
- name: Generate project files
run: |
cmake -B "${{ env.CMAKE_BUILD_DIR }}" -DCMAKE_INSTALL_PREFIX="${{ env.CMAKE_INSTALL_DIR }}" -DCMAKE_DEBUG_POSTFIX=d -DBGFX_BUILD_EXAMPLES=OFF -DBGFX_BUILD_TOOLS=ON -DBGFX_INSTALL=ON -DBGFX_AMALGAMATED=ON -DCMAKE_BUILD_TYPE=Release
# Build the install targets
- name: Build
run: |
cmake --build "${{ env.CMAKE_BUILD_DIR }}" --target install --config Release
- uses: actions/upload-artifact@v2
with:
name: ${{ matrix.os }}
path: ${{ github.workspace }}/install/
release:
name: release
runs-on: ubuntu-latest
needs: [ version, build ]
if: github.repository == 'bkaradzic/bgfx.cmake' && github.event_name == 'push'
steps:
- name: Create Release
uses: actions/create-release@v1
with:
tag_name: ${{ needs.version.outputs.tag }}
release_name: ${{ needs.version.outputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

16
ADVect/ext/bgfx/.gitignore vendored Normal file
View file

@ -0,0 +1,16 @@
[Bb]uild/
*.swp
CMakeCache.txt
CMakeFiles/
Debug/
Release/
*.vcxproj
*.vcxproj.filters
*.dir/
*.sln
install/
install_manifest.txt
generated/*
!generated/*.in
cmake_install.cmake
.cache/

9
ADVect/ext/bgfx/.gitmodules vendored Normal file
View file

@ -0,0 +1,9 @@
[submodule "bgfx"]
path = bgfx
url = https://github.com/bkaradzic/bgfx.git
[submodule "bx"]
path = bx
url = https://github.com/bkaradzic/bx.git
[submodule "bimg"]
path = bimg
url = https://github.com/bkaradzic/bimg.git

View file

@ -0,0 +1,204 @@
# bgfx.cmake - bgfx building in cmake
# Written in 2017 by Joshua Brookover <joshua.al.brookover@gmail.com>
# To the extent possible under law, the author(s) have dedicated all copyright
# and related and neighboring rights to this software to the public domain
# worldwide. This software is distributed without any warranty.
# You should have received a copy of the CC0 Public Domain Dedication along with
# this software. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
cmake_minimum_required( VERSION 3.0 )
project(bgfx)
set_property( GLOBAL PROPERTY USE_FOLDERS ON )
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Makefile generators on apple need this flag to compile mixed objective/c++
if( APPLE AND NOT XCODE )
set( CMAKE_CXX_FLAGS "-ObjC++" )
endif()
if (MSVC AND (MSVC_VERSION GREATER_EQUAL 1914))
add_compile_options("/Zc:__cplusplus")
endif()
option( BGFX_BUILD_TOOLS "Build bgfx tools." ON )
option( BGFX_BUILD_EXAMPLES "Build bgfx examples." OFF )
option( BGFX_INSTALL "Create installation target." ON )
option( BGFX_INSTALL_EXAMPLES "Install examples and their runtimes." OFF )
option( BGFX_CUSTOM_TARGETS "Include convenience custom targets." ON )
option( BGFX_AMALGAMATED "Amalgamated bgfx build for faster compilation" OFF )
option( BX_AMALGAMATED "Amalgamated bx build for faster compilation" OFF )
option( BGFX_CONFIG_MULTITHREADED "Build bgfx with multithreaded configuration" ON )
option( BGFX_CONFIG_RENDERER_WEBGPU "Enables the webgpu renderer" OFF )
option( BX_CONFIG_DEBUG "Log debug messages (default: on in debug)" OFF )
set( BGFX_OPENGL_VERSION "" CACHE STRING "Specify minimum opengl version" )
set( BGFX_OPENGLES_VERSION "" CACHE STRING "Specify minimum OpenGL ES version" )
set( BGFX_LIBRARY_TYPE "STATIC" CACHE STRING "Linking type for library" )
set_property( CACHE BGFX_LIBRARY_TYPE PROPERTY STRINGS STATIC SHARED )
if( BGFX_LIBRARY_TYPE MATCHES "SHARED" )
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
if( NOT BX_DIR )
set( BX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bx" CACHE STRING "Location of bx." )
elseif( NOT IS_ABSOLUTE "${BX_DIR}")
get_filename_component(BX_DIR "${BX_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
if( NOT BIMG_DIR )
set( BIMG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bimg" CACHE STRING "Location of bimg." )
elseif( NOT IS_ABSOLUTE "${BIMG_DIR}")
get_filename_component(BIMG_DIR "${BIMG_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
if( NOT BGFX_DIR )
set( BGFX_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bgfx" CACHE STRING "Location of bgfx." )
elseif( NOT IS_ABSOLUTE "${BGFX_DIR}")
get_filename_component(BGFX_DIR "${BGFX_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
endif()
# sets project version from api ver / git rev
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.cmake )
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/shared.cmake )
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bx.cmake )
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bimg.cmake )
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/bgfx.cmake )
if( BGFX_BUILD_TOOLS )
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/tools.cmake )
endif()
if( BGFX_BUILD_TOOLS OR BGFX_BUILD_EXAMPLES )
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/examples.cmake )
endif()
if( BGFX_INSTALL )
include(GNUInstallDirs)
# Layout. This works for all platforms:
# * <prefix>/lib*/cmake/<PROJECT-NAME>
# * <prefix>/lib*/
# * <prefix>/include/
set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
# Configuration
set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
set(namespace "${PROJECT_NAME}::")
# Include module with fuction 'write_basic_package_version_file'
include(CMakePackageConfigHelpers)
# Configure '<PROJECT-NAME>ConfigVersion.cmake'
# Use:
# * PROJECT_VERSION
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
set(BGFX_COMPATIBILITY SameMajorVersion)
else()
set(BGFX_COMPATIBILITY SameMinorVersion)
endif()
write_basic_package_version_file(
"${version_config}"
VERSION ${PROJECT_VERSION}
COMPATIBILITY ${BGFX_COMPATIBILITY}
)
# Configure '<PROJECT-NAME>Config.cmake'
# Use variables:
# * TARGETS_EXPORT_NAME
# * PROJECT_NAME
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in"
"${project_config}"
INSTALL_DESTINATION "${config_install_dir}"
)
install(FILES ${BGFX_DIR}/LICENSE DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/licences/${PROJECT_NAME})
install( TARGETS bgfx
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
if( NOT BGFX_LIBRARY_TYPE MATCHES "SHARED" )
install( TARGETS bimg bx astc-codec astc edtaa3 etc1 etc2 iqa squish nvtt pvrtc tinyexr
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
endif()
if (BGFX_CONFIG_RENDERER_WEBGPU)
install( TARGETS webgpu
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
endif()
# install headers (this should be done as a target probably... ^)
install( DIRECTORY ${BX_DIR}/include/bx ${BX_DIR}/include/compat ${BX_DIR}/include/tinystl DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install( DIRECTORY ${BIMG_DIR}/include/bimg DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install( DIRECTORY ${BGFX_DIR}/include/bgfx DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
# header required for shader compilation
install( FILES ${BGFX_DIR}/src/bgfx_shader.sh ${BGFX_DIR}/src/bgfx_compute.sh
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/bgfx"
)
# install tools
if( BGFX_BUILD_TOOLS )
install( TARGETS shaderc
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
install( TARGETS geometryc
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
install( TARGETS geometryv
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
install( TARGETS texturec
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
install( TARGETS texturev
EXPORT "${TARGETS_EXPORT_NAME}"
DESTINATION "${CMAKE_INSTALL_BINDIR}" )
endif()
# install examples
if( BGFX_BUILD_EXAMPLES AND BGFX_INSTALL_EXAMPLES )
install( DIRECTORY ${BGFX_DIR}/examples/runtime/ DESTINATION examples )
foreach( EXAMPLE ${BGFX_EXAMPLES} )
install( TARGETS example-${EXAMPLE} DESTINATION examples )
endforeach()
endif()
# Config
# * <prefix>/lib/cmake/bgfx/bgfxConfig.cmake
# * <prefix>/lib/cmake/bgfx/bgfxConfigVersion.cmake
install(
FILES "${project_config}" "${version_config}"
DESTINATION "${config_install_dir}"
)
# Config
# * <prefix>/lib/cmake/bgfx/bgfxTargets.cmake
install(
EXPORT "${TARGETS_EXPORT_NAME}"
NAMESPACE "${namespace}"
DESTINATION "${config_install_dir}"
)
endif()

121
ADVect/ext/bgfx/LICENSE Normal file
View file

@ -0,0 +1,121 @@
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.

37
ADVect/ext/bgfx/README.md Normal file
View file

@ -0,0 +1,37 @@
bgfx.cmake
===================
[![Build Status](https://github.com/bkaradzic/bgfx.cmake/workflows/Release/badge.svg)](https://github.com/bkaradzic/bgfx.cmake/workflows/Release/badge.svg)
**NOTE: This port only made to be used as C++ library, some features (such as bindings, examples) might not work! Please use original repo with GENie instead.**
This repo contains a bunch of cmake files that can be used to build bgfx with CMake.
Building
-------------
```bash
git clone https://github.com/bkaradzic/bgfx.cmake.git
cd bgfx.cmake
git submodule init
git submodule update
mkdir build
cd build
cmake ..
```
If downloading via zip (instead of using git submodules) manually download bx, bimg and bgfx and copy them into the root directory, or locate them via `BX_DIR`, `BIMG_DIR` and `BGFX_DIR` CMake variables.
How To Use
-------------
This project is setup to be included a few different ways. To include bgfx source code in your project simply use add_subdirectory to include this project. To build bgfx binaries build the `INSTALL` target (or `make install`). The installed files will be in the directory specified by `CMAKE_INSTALL_PREFIX` which I recommend you set to `./install` so it will export to your build directory. Note you may want to build install on both `Release` and `Debug` configurations.
Features
-------------
* No outside dependencies besides bx, bimg, bgfx, and CMake.
* Tested on Visual Studio 2015, Xcode, gcc 5.4, clang 3.8.
* Compiles bgfx, tools & examples.
* Detects shader modifications and automatically rebuilds them for all examples.
Does this work with latest bx/bgfx/bimg?
-------------
Probably! This project needs to be updated if a dependency is added or the bgfx build system changes. The bgfx repository is very active but these types of changes are rare. New examples have to be added manually as well, but not doing so will merely result in that example not showing up and won't break anything else. If pulling latest causes issues, be sure to manually reconfigure CMake as the glob patterns may need to be refreshed (the use of glob patterns in CMake is generally discouraged but in this project it helps to ensure upwards compatibilty with newer bgfx updates).

View file

@ -0,0 +1,25 @@
shallow_clone: true
os:
- Visual Studio 2019
environment:
matrix:
- TOOLSET: vs2017
# - TOOLSET: vs2019
platform:
- Win32
- x64
configuration:
- Debug
- Release
install:
- git clone --depth 1 https://github.com/bkaradzic/bx ..\bx
- git clone --depth 1 https://github.com/bkaradzic/bimg ..\bimg
- ..\bx\tools\bin\windows\genie --with-tools --with-examples %TOOLSET%
build:
project: .build/projects/$(TOOLSET)/bgfx.sln

View file

@ -0,0 +1,20 @@
root = true
[*]
charset = utf-8
indent_style = tab
indent_size = 4
end_of_line = lf
max_line_length = 100
insert_final_newline = true
trim_trailing_whitespace = true
[include/bgfx/c99/*.h]
indent_style = space
[*.ninja]
indent_style = space
[*.md]
trim_trailing_whitespace = false
max_line_length = 80

11
ADVect/ext/bgfx/bgfx/.gitattributes vendored Normal file
View file

@ -0,0 +1,11 @@
*.c eol=lf
*.cpp eol=lf
*.h eol=lf
*.sc eol=lf
*.sh eol=lf
*.m eol=lf
*.mm eol=lf
*.md eol=lf
*.lua eol=lf
*.mk eol=lf
makefile eol=lf

View file

@ -0,0 +1,48 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
<!---
###########################################################################
**IMPORTANT: READ FIRST!**
Issue tracker is **ONLY** used for reporting bugs.
If you have any questions please **do not** open issue, rather:
- If you have quick question, ask on Discord: https://discord.gg/9eMbv7J
- Ask in discussions: https://github.com/bkaradzic/bgfx/discussions
- Search documentation: https://bkaradzic.github.io/bgfx/
New features should be discussed on:
- GitHub Discussions https://github.com/bkaradzic/bgfx/discussions
- Discord Chat https://discord.gg/9eMbv7J
###########################################################################
-->
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Additional context**
Add any other context about the problem here. OS, drivers, etc.

9
ADVect/ext/bgfx/bgfx/.gitignore vendored Normal file
View file

@ -0,0 +1,9 @@
.build
.debug
.DS_Store
.git
.svn
tags
.gdb_history
.vscode
*.TMP

View file

@ -0,0 +1,37 @@
root = true
[etc1/*]
indent_style = space
indent_size = 4
[fcpp/*]
indent_style = space
indent_size = 2
[iqa/*]
indent_style = tab
indent_size = 4
[libsquish/*]
indent_style = tab
indent_size = 4
[dear-imgui/*]
indent_style = space
indent_size = 4
[dear-imgui/*.inl]
indent_style = space
indent_size = 4
[pvrtc/*]
indent_style = space
indent_size = 4
[remotery/*]
indent_style = space
indent_size = 4
[glsl-optimizer/*]
indent_style = space
indent_size = 3

View file

@ -0,0 +1,7 @@
Copyright (c) 2018 Johannes Kuhlmann
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.

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,67 @@
//-----------------------------------------------------------------------------
// USER IMPLEMENTATION
// This file contains compile-time options for ImGui.
// Other options (memory allocation overrides, callbacks, etc.) can be set at runtime via the ImGuiIO structure - ImGui::GetIO().
//-----------------------------------------------------------------------------
#pragma once
#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
#define IMGUI_DISABLE_OBSOLETE_KEYIO
#define IMGUI_DISABLE_DEFAULT_ALLOCATORS
//---- Define your own ImVector<> type if you don't want to use the provided implementation defined in imgui.h
//#include <vector>
//#define ImVector std::vector
//#define ImVector MyVector
//---- Define assertion handler. Defaults to calling assert().
#include <assert.h>
#define IM_ASSERT(_EXPR) assert(_EXPR)
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows.
//#define IMGUI_API __declspec( dllexport )
//#define IMGUI_API __declspec( dllimport )
//---- Don't implement default handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions)
#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
//---- Include imgui_user.inl at the end of imgui.cpp so you can include code that extends ImGui using its private data/functions.
#define IMGUI_INCLUDE_IMGUI_USER_INL
//---- Include imgui_user.h at the end of imgui.h
#define IMGUI_INCLUDE_IMGUI_USER_H
//---- Don't implement default handlers for Windows (so as not to link with OpenClipboard() and others Win32 functions)
#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS
#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS
//---- Don't implement help and test window functionality (ShowUserGuide()/ShowStyleEditor()/ShowTestWindow() methods will be empty)
//#define IMGUI_DISABLE_TEST_WINDOWS
//---- Implement STB libraries in a namespace to avoid conflicts
//#define IMGUI_STB_NAMESPACE ImStb
//---- Define constructor and implicit cast operators to convert back<>forth from your math types and ImVec2/ImVec4.
/*
#define IM_VEC2_CLASS_EXTRA \
ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \
operator MyVec2() const { return MyVec2(x,y); }
#define IM_VEC4_CLASS_EXTRA \
ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \
operator MyVec4() const { return MyVec4(x,y,z,w); }
*/
//---- Freely implement extra functions within the ImGui:: namespace.
//---- Declare helpers or widgets implemented in imgui_user.inl or elsewhere, so end-user doesn't need to include multiple files.
//---- e.g. you can create variants of the ImGui::Value() helper for your low-level math types, or your own widgets/helpers.
/*
namespace ImGui
{
void Value(const char* prefix, const MyVec2& v, const char* float_format = NULL);
void Value(const char* prefix, const MyVec4& v, const char* float_format = NULL);
}
*/

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,52 @@
#include <stdint.h>
#include <inttypes.h>
namespace ImGui
{
struct Font
{
enum Enum
{
Regular,
Mono,
Count
};
};
void PushFont(Font::Enum _font);
// BK - simple string class for convenience.
class ImString
{
public:
ImString();
ImString(const ImString& rhs);
ImString(const char* rhs);
~ImString();
ImString& operator=(const ImString& rhs);
ImString& operator=(const char* rhs);
void Clear();
bool IsEmpty() const;
const char* CStr() const
{
return NULL == Ptr ? "" : Ptr;
}
private:
char* Ptr;
};
} // namespace ImGui
#include "widgets/color_picker.h"
#include "widgets/color_wheel.h"
#include "widgets/dock.h"
#include "widgets/file_list.h"
#include "widgets/gizmo.h"
#include "widgets/markdown.h"
#include "widgets/memory_editor.h"
#include "widgets/range_slider.h"

View file

@ -0,0 +1,81 @@
namespace ImGui
{
ImString::ImString()
: Ptr(NULL)
{
}
ImString::ImString(const ImString& rhs)
: Ptr(NULL)
{
if (NULL != rhs.Ptr
&& 0 != strcmp(rhs.Ptr, ""))
{
Ptr = ImStrdup(rhs.Ptr);
}
}
ImString::ImString(const char* rhs)
: Ptr(NULL)
{
if (NULL != rhs
&& 0 != strcmp(rhs, ""))
{
Ptr = ImStrdup(rhs);
}
}
ImString::~ImString()
{
Clear();
}
ImString& ImString::operator=(const ImString& rhs)
{
if (this != &rhs)
{
*this = rhs.Ptr;
}
return *this;
}
ImString& ImString::operator=(const char* rhs)
{
if (Ptr != rhs)
{
Clear();
if (NULL != rhs
&& 0 != strcmp(rhs, ""))
{
Ptr = ImStrdup(rhs);
}
}
return *this;
}
void ImString::Clear()
{
if (NULL != Ptr)
{
MemFree(Ptr);
Ptr = NULL;
}
}
bool ImString::IsEmpty() const
{
return NULL == Ptr;
}
} // namespace
#include "widgets/color_picker.inl"
#include "widgets/color_wheel.inl"
#include "widgets/dock.inl"
#include "widgets/file_list.inl"
#include "widgets/gizmo.inl"
#include "widgets/markdown.inl"
#include "widgets/memory_editor.inl"
#include "widgets/range_slider.inl"

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1 @@
#include <stb/stb_rect_pack.h>

View file

@ -0,0 +1 @@
#include <stb/stb_textedit.h>

View file

@ -0,0 +1 @@
#include <stb/stb_truetype.h>

View file

@ -0,0 +1,24 @@
namespace ImGui
{
bool ColorPicker4(float* col, bool show_alpha);
bool ColorPicker3(float col[3]);
inline bool ColorEdit4(const char* label, uint32_t* _rgba, bool show_alpha = true)
{
uint8_t* rgba = (uint8_t*)_rgba;
float col[4] =
{
rgba[0]/255.0f,
rgba[1]/255.0f,
rgba[2]/255.0f,
rgba[3]/255.0f,
};
bool result = ColorEdit4(label, col, show_alpha);
rgba[0] = uint8_t(col[0]*255.0f);
rgba[1] = uint8_t(col[1]*255.0f);
rgba[2] = uint8_t(col[2]*255.0f);
rgba[3] = uint8_t(col[3]*255.0f);
return result;
}
} // namespace ImGui

View file

@ -0,0 +1,122 @@
// https://github.com/ocornut/imgui/issues/346#issuecomment-171961296
// [src] https://github.com/ocornut/imgui/issues/346
namespace ImGui
{
bool ColorPicker4(float* col, bool show_alpha)
{
ImGuiIO& io = ImGui::GetIO();
ImGuiStyle& style = ImGui::GetStyle();
ImDrawList* draw_list = ImGui::GetWindowDrawList();
// Setup
ImVec2 picker_pos = ImGui::GetCursorScreenPos();
ImVec2 sv_picker_size = ImVec2(256.0f, 256.0f); // Saturation/Value picking box
float bars_width = ImGui::GetFontSize() + style.FramePadding.y*2.0f; // Width of Hue/Alpha picking bars (using Framepadding.y to match the ColorButton sides)
float bar0_pos_x = picker_pos.x + sv_picker_size.x + style.ItemInnerSpacing.x;
float bar1_pos_x = bar0_pos_x + bars_width + style.ItemInnerSpacing.x;
float H,S,V;
ImGui::ColorConvertRGBtoHSV(col[0], col[1], col[2], H, S, V);
// Color matrix logic
bool value_changed = false, hsv_changed = false;
ImGui::BeginGroup();
ImGui::InvisibleButton("sv", sv_picker_size);
if (ImGui::IsItemActive())
{
S = ImSaturate((io.MousePos.x - picker_pos.x) / (sv_picker_size.x-1));
V = 1.0f - ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size.y-1));
value_changed = hsv_changed = true;
}
// Hue bar logic
ImGui::SetCursorScreenPos(ImVec2(bar0_pos_x, picker_pos.y));
ImGui::InvisibleButton("hue", ImVec2(bars_width, sv_picker_size.y));
if (ImGui::IsItemActive())
{
H = ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size.y-1));
value_changed = hsv_changed = true;
}
// Alpha bar logic
if (show_alpha)
{
ImGui::SetCursorScreenPos(ImVec2(bar1_pos_x, picker_pos.y));
ImGui::InvisibleButton("alpha", ImVec2(bars_width, sv_picker_size.y));
if (ImGui::IsItemActive())
{
col[3] = 1.0f - ImSaturate((io.MousePos.y - picker_pos.y) / (sv_picker_size.y-1));
value_changed = true;
}
}
// Convert back to RGB
if (hsv_changed)
ImGui::ColorConvertHSVtoRGB(H >= 1.0f ? H - 10 * 1e-6f : H, S > 0.0f ? S : 10*1e-6f, V > 0.0f ? V : 1e-6f, col[0], col[1], col[2]);
// R,G,B or H,S,V color editor
ImGui::PushItemWidth((show_alpha ? bar1_pos_x : bar0_pos_x) + bars_width - picker_pos.x);
value_changed |= show_alpha ? ImGui::ColorEdit4("##edit", col) : ImGui::ColorEdit3("##edit", col);
ImGui::PopItemWidth();
// Try to cancel hue wrap (after ColorEdit), if any
if (value_changed)
{
float new_H, new_S, new_V;
ImGui::ColorConvertRGBtoHSV(col[0], col[1], col[2], new_H, new_S, new_V);
if (new_H <= 0 && H > 0)
{
if (new_V <= 0 && V != new_V)
ImGui::ColorConvertHSVtoRGB(H, S, new_V <= 0 ? V * 0.5f : new_V, col[0], col[1], col[2]);
else if (new_S <= 0)
ImGui::ColorConvertHSVtoRGB(H, new_S <= 0 ? S * 0.5f : new_S, new_V, col[0], col[1], col[2]);
}
}
// Render hue bar
ImU32 hue_colors[] = { IM_COL32(255,0,0,255), IM_COL32(255,255,0,255), IM_COL32(0,255,0,255), IM_COL32(0,255,255,255), IM_COL32(0,0,255,255), IM_COL32(255,0,255,255), IM_COL32(255,0,0,255) };
for (int i = 0; i < 6; ++i)
{
draw_list->AddRectFilledMultiColor(
ImVec2(bar0_pos_x, picker_pos.y + i * (sv_picker_size.y / 6)),
ImVec2(bar0_pos_x + bars_width, picker_pos.y + (i + 1) * (sv_picker_size.y / 6)),
hue_colors[i], hue_colors[i], hue_colors[i + 1], hue_colors[i + 1]);
}
float bar0_line_y = (float)(int)(picker_pos.y + H * sv_picker_size.y + 0.5f);
draw_list->AddLine(ImVec2(bar0_pos_x - 1, bar0_line_y), ImVec2(bar0_pos_x + bars_width + 1, bar0_line_y), IM_COL32_WHITE);
// Render alpha bar
if (show_alpha)
{
float alpha = ImSaturate(col[3]);
float bar1_line_y = (float)(int)(picker_pos.y + (1.0f-alpha) * sv_picker_size.y + 0.5f);
draw_list->AddRectFilledMultiColor(ImVec2(bar1_pos_x, picker_pos.y), ImVec2(bar1_pos_x + bars_width, picker_pos.y + sv_picker_size.y), IM_COL32_WHITE, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32_BLACK);
draw_list->AddLine(ImVec2(bar1_pos_x - 1, bar1_line_y), ImVec2(bar1_pos_x + bars_width + 1, bar1_line_y), IM_COL32_WHITE);
}
// Render color matrix
ImVec4 hue_color_f(1, 1, 1, 1);
ImGui::ColorConvertHSVtoRGB(H, 1, 1, hue_color_f.x, hue_color_f.y, hue_color_f.z);
ImU32 hue_color32 = ImGui::ColorConvertFloat4ToU32(hue_color_f);
draw_list->AddRectFilledMultiColor(picker_pos, picker_pos + sv_picker_size, IM_COL32_WHITE, hue_color32, hue_color32, IM_COL32_WHITE);
draw_list->AddRectFilledMultiColor(picker_pos, picker_pos + sv_picker_size, IM_COL32_BLACK_TRANS, IM_COL32_BLACK_TRANS, IM_COL32_BLACK, IM_COL32_BLACK);
// Render cross-hair
const float CROSSHAIR_SIZE = 7.0f;
ImVec2 p((float)(int)(picker_pos.x + S * sv_picker_size.x + 0.5f), (float)(int)(picker_pos.y + (1 - V) * sv_picker_size.y + 0.5f));
draw_list->AddLine(ImVec2(p.x - CROSSHAIR_SIZE, p.y), ImVec2(p.x - 2, p.y), IM_COL32_WHITE);
draw_list->AddLine(ImVec2(p.x + CROSSHAIR_SIZE, p.y), ImVec2(p.x + 2, p.y), IM_COL32_WHITE);
draw_list->AddLine(ImVec2(p.x, p.y + CROSSHAIR_SIZE), ImVec2(p.x, p.y + 2), IM_COL32_WHITE);
draw_list->AddLine(ImVec2(p.x, p.y - CROSSHAIR_SIZE), ImVec2(p.x, p.y - 2), IM_COL32_WHITE);
ImGui::EndGroup();
return value_changed;
}
bool ColorPicker3(float col[3])
{
return ColorPicker4(col, false);
}
} // namespace ImGui

View file

@ -0,0 +1,7 @@
namespace ImGui
{
void ColorWheel(const char* _text, float* _rgba, float _size);
void ColorWheel(const char* _text, uint32_t* _rgba, float _size);
} // namespace ImGui

View file

@ -0,0 +1,39 @@
namespace ImGui
{
void ColorWheel(const char* _text, float* _rgba, float _size)
{
(void)_size;
ColorEdit4(_text
, _rgba, 0
| ImGuiColorEditFlags_PickerHueWheel
| ImGuiColorEditFlags_Float
);
}
inline void decodeRgba(float* _dst, const uint32_t* _src)
{
uint8_t* src = (uint8_t*)_src;
_dst[0] = float(src[0] / 255.0f);
_dst[1] = float(src[1] / 255.0f);
_dst[2] = float(src[2] / 255.0f);
_dst[3] = float(src[3] / 255.0f);
}
inline void encodeRgba(uint32_t* _dst, const float* _src)
{
uint8_t* dst = (uint8_t*)_dst;
dst[0] = uint8_t(_src[0] * 255.0);
dst[1] = uint8_t(_src[1] * 255.0);
dst[2] = uint8_t(_src[2] * 255.0);
dst[3] = uint8_t(_src[3] * 255.0);
}
void ColorWheel(const char* _text, uint32_t* _rgba, float _size)
{
float rgba[4];
decodeRgba(rgba, _rgba);
ColorWheel(_text, rgba, _size);
encodeRgba(_rgba, rgba);
}
} // namespace ImGui

View file

@ -0,0 +1,21 @@
namespace ImGui
{
///
IMGUI_API void InitDockContext();
///
IMGUI_API void ShutdownDockContext();
///
IMGUI_API void RootDock(const ImVec2& pos, const ImVec2& size);
///
IMGUI_API bool BeginDock(const char* label, bool* opened = NULL, ImGuiWindowFlags extra_flags = 0);
///
IMGUI_API void EndDock();
///
IMGUI_API void SetDockActive();
} // namespace ImGui

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,28 @@
namespace ImGui
{
struct ImFileInfo
{
ImFileInfo(const char* name, int64_t size);
~ImFileInfo();
ImString Name;
int64_t Size;
};
struct ImFileList
{
typedef ImVector<ImFileInfo> FileInfoArray;
FileInfoArray FileList;
int Pos;
ImFileList(const char* path = ".")
: Pos(0)
{
ChDir(path);
}
void ChDir(const char* path);
void Draw();
};
} // namespace ImGui

View file

@ -0,0 +1,127 @@
#include <bx/bx.h>
#include <dirent.h>
#include <sys/stat.h>
namespace ImGui
{
ImFileInfo::ImFileInfo(const char* name, int64_t size)
: Name(name)
, Size(size)
{
}
ImFileInfo::~ImFileInfo()
{
}
void ImFileList::ChDir(const char* path)
{
#if BX_PLATFORM_PS4
BX_UNUSED(path);
#else
DIR* dir = opendir(path);
if (NULL != dir)
{
FileList.clear();
for (dirent* item = readdir(dir); NULL != item; item = readdir(dir) )
{
if (0 == ImStricmp(item->d_name, "..") )
{
FileList.push_back(ImFileInfo(item->d_name, -1) );
}
else if (0 != ImStricmp(item->d_name, ".") )
{
if (item->d_type & DT_DIR)
{
FileList.push_back(ImFileInfo(item->d_name, -1) );
}
else
{
struct stat statbuf;
stat(item->d_name, &statbuf);
FileList.push_back(ImFileInfo(item->d_name, statbuf.st_size) );
}
}
}
closedir(dir);
}
#endif // BX_PLATFORM_PS4
}
void ImFileList::Draw()
{
BeginChild("##file_list", ImVec2(0.0f, 0.0f) );
PushFont(Font::Mono);
PushItemWidth(-1);
if (BeginListBox("##empty", ImVec2(0.0f, 0.0f) ) )
{
const float lineHeight = GetTextLineHeightWithSpacing();
ImString chdir;
int pos = 0;
ImGuiListClipper clipper;
clipper.Begin(FileList.size(), lineHeight);
clipper.Step();
for (FileInfoArray::const_iterator it = FileList.begin(), itEnd = FileList.end()
; it != itEnd
; ++it
)
{
if (pos >= clipper.DisplayStart
&& pos < clipper.DisplayEnd)
{
PushID(pos);
const bool isDir = -1 == it->Size;
bool isSelected = Pos == pos;
bool clicked = Selectable(it->Name.CStr(), &isSelected);
SameLine(150);
if (isDir)
{
Text("%10s", "<DIR>");
}
else
{
Text("%10" PRId64, it->Size);
}
if (clicked)
{
if (0 == strcmp(it->Name.CStr(), "..") )
{
chdir = it->Name;
}
Pos = pos;
if (isDir)
{
chdir = it->Name;
}
}
PopID();
}
++pos;
}
clipper.End();
EndListBox();
if (!chdir.IsEmpty() )
{
ChDir(chdir.CStr() );
}
}
PopFont();
EndChild();
}
} // namespace ImGui

View file

@ -0,0 +1,223 @@
// https://github.com/CedricGuillemet/ImGuizmo
// v 1.84 WIP
//
// The MIT License(MIT)
//
// Copyright(c) 2021 Cedric Guillemet
//
// 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.
//
// -------------------------------------------------------------------------------------------
// History :
// 2019/11/03 View gizmo
// 2016/09/11 Behind camera culling. Scaling Delta matrix not multiplied by source matrix scales. local/world rotation and translation fixed. Display message is incorrect (X: ... Y:...) in local mode.
// 2016/09/09 Hatched negative axis. Snapping. Documentation update.
// 2016/09/04 Axis switch and translation plan autohiding. Scale transform stability improved
// 2016/09/01 Mogwai changed to Manipulate. Draw debug cube. Fixed inverted scale. Mixing scale and translation/rotation gives bad results.
// 2016/08/31 First version
//
// -------------------------------------------------------------------------------------------
// Future (no order):
//
// - Multi view
// - display rotation/translation/scale infos in local/world space and not only local
// - finish local/world matrix application
// - OPERATION as bitmask
//
// -------------------------------------------------------------------------------------------
// Example
#if 0
void EditTransform(const Camera& camera, matrix_t& matrix)
{
static ImGuizmo::OPERATION mCurrentGizmoOperation(ImGuizmo::ROTATE);
static ImGuizmo::MODE mCurrentGizmoMode(ImGuizmo::WORLD);
if (ImGui::IsKeyPressed(90))
mCurrentGizmoOperation = ImGuizmo::TRANSLATE;
if (ImGui::IsKeyPressed(69))
mCurrentGizmoOperation = ImGuizmo::ROTATE;
if (ImGui::IsKeyPressed(82)) // r Key
mCurrentGizmoOperation = ImGuizmo::SCALE;
if (ImGui::RadioButton("Translate", mCurrentGizmoOperation == ImGuizmo::TRANSLATE))
mCurrentGizmoOperation = ImGuizmo::TRANSLATE;
ImGui::SameLine();
if (ImGui::RadioButton("Rotate", mCurrentGizmoOperation == ImGuizmo::ROTATE))
mCurrentGizmoOperation = ImGuizmo::ROTATE;
ImGui::SameLine();
if (ImGui::RadioButton("Scale", mCurrentGizmoOperation == ImGuizmo::SCALE))
mCurrentGizmoOperation = ImGuizmo::SCALE;
float matrixTranslation[3], matrixRotation[3], matrixScale[3];
ImGuizmo::DecomposeMatrixToComponents(matrix.m16, matrixTranslation, matrixRotation, matrixScale);
ImGui::InputFloat3("Tr", matrixTranslation, 3);
ImGui::InputFloat3("Rt", matrixRotation, 3);
ImGui::InputFloat3("Sc", matrixScale, 3);
ImGuizmo::RecomposeMatrixFromComponents(matrixTranslation, matrixRotation, matrixScale, matrix.m16);
if (mCurrentGizmoOperation != ImGuizmo::SCALE)
{
if (ImGui::RadioButton("Local", mCurrentGizmoMode == ImGuizmo::LOCAL))
mCurrentGizmoMode = ImGuizmo::LOCAL;
ImGui::SameLine();
if (ImGui::RadioButton("World", mCurrentGizmoMode == ImGuizmo::WORLD))
mCurrentGizmoMode = ImGuizmo::WORLD;
}
static bool useSnap(false);
if (ImGui::IsKeyPressed(83))
useSnap = !useSnap;
ImGui::Checkbox("", &useSnap);
ImGui::SameLine();
vec_t snap;
switch (mCurrentGizmoOperation)
{
case ImGuizmo::TRANSLATE:
snap = config.mSnapTranslation;
ImGui::InputFloat3("Snap", &snap.x);
break;
case ImGuizmo::ROTATE:
snap = config.mSnapRotation;
ImGui::InputFloat("Angle Snap", &snap.x);
break;
case ImGuizmo::SCALE:
snap = config.mSnapScale;
ImGui::InputFloat("Scale Snap", &snap.x);
break;
}
ImGuiIO& io = ImGui::GetIO();
ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y);
ImGuizmo::Manipulate(camera.mView.m16, camera.mProjection.m16, mCurrentGizmoOperation, mCurrentGizmoMode, matrix.m16, NULL, useSnap ? &snap.x : NULL);
}
#endif
#pragma once
#ifdef USE_IMGUI_API
#include "imconfig.h"
#endif
#ifndef IMGUI_API
#define IMGUI_API
#endif
#ifndef IMGUIZMO_NAMESPACE
#define IMGUIZMO_NAMESPACE ImGuizmo
#endif
namespace IMGUIZMO_NAMESPACE
{
// call inside your own window and before Manipulate() in order to draw gizmo to that window.
// Or pass a specific ImDrawList to draw to (e.g. ImGui::GetForegroundDrawList()).
IMGUI_API void SetDrawlist(ImDrawList* drawlist = nullptr);
// call BeginFrame right after ImGui_XXXX_NewFrame();
IMGUI_API void BeginFrame();
// this is necessary because when imguizmo is compiled into a dll, and imgui into another
// globals are not shared between them.
// More details at https://stackoverflow.com/questions/19373061/what-happens-to-global-and-static-variables-in-a-shared-library-when-it-is-dynam
// expose method to set imgui context
IMGUI_API void SetImGuiContext(ImGuiContext* ctx);
// return true if mouse cursor is over any gizmo control (axis, plan or screen component)
IMGUI_API bool IsOver();
// return true if mouse IsOver or if the gizmo is in moving state
IMGUI_API bool IsUsing();
// enable/disable the gizmo. Stay in the state until next call to Enable.
// gizmo is rendered with gray half transparent color when disabled
IMGUI_API void Enable(bool enable);
// helper functions for manualy editing translation/rotation/scale with an input float
// translation, rotation and scale float points to 3 floats each
// Angles are in degrees (more suitable for human editing)
// example:
// float matrixTranslation[3], matrixRotation[3], matrixScale[3];
// ImGuizmo::DecomposeMatrixToComponents(gizmoMatrix.m16, matrixTranslation, matrixRotation, matrixScale);
// ImGui::InputFloat3("Tr", matrixTranslation, 3);
// ImGui::InputFloat3("Rt", matrixRotation, 3);
// ImGui::InputFloat3("Sc", matrixScale, 3);
// ImGuizmo::RecomposeMatrixFromComponents(matrixTranslation, matrixRotation, matrixScale, gizmoMatrix.m16);
//
// These functions have some numerical stability issues for now. Use with caution.
IMGUI_API void DecomposeMatrixToComponents(const float* matrix, float* translation, float* rotation, float* scale);
IMGUI_API void RecomposeMatrixFromComponents(const float* translation, const float* rotation, const float* scale, float* matrix);
IMGUI_API void SetRect(float x, float y, float width, float height);
// default is false
IMGUI_API void SetOrthographic(bool isOrthographic);
// Render a cube with face color corresponding to face normal. Usefull for debug/tests
IMGUI_API void DrawCubes(const float* view, const float* projection, const float* matrices, int matrixCount);
IMGUI_API void DrawGrid(const float* view, const float* projection, const float* matrix, const float gridSize);
// call it when you want a gizmo
// Needs view and projection matrices.
// matrix parameter is the source matrix (where will be gizmo be drawn) and might be transformed by the function. Return deltaMatrix is optional
// translation is applied in world space
enum OPERATION
{
TRANSLATE_X = (1u << 0),
TRANSLATE_Y = (1u << 1),
TRANSLATE_Z = (1u << 2),
ROTATE_X = (1u << 3),
ROTATE_Y = (1u << 4),
ROTATE_Z = (1u << 5),
ROTATE_SCREEN = (1u << 6),
SCALE_X = (1u << 7),
SCALE_Y = (1u << 8),
SCALE_Z = (1u << 9),
BOUNDS = (1u << 10),
SCALE_XU = (1u << 11),
SCALE_YU = (1u << 12),
SCALE_ZU = (1u << 13),
TRANSLATE = TRANSLATE_X | TRANSLATE_Y | TRANSLATE_Z,
ROTATE = ROTATE_X | ROTATE_Y | ROTATE_Z | ROTATE_SCREEN,
SCALE = SCALE_X | SCALE_Y | SCALE_Z,
SCALEU = SCALE_XU | SCALE_YU | SCALE_ZU, // universal
UNIVERSAL = TRANSLATE | ROTATE | SCALEU
};
inline OPERATION operator|(OPERATION lhs, OPERATION rhs)
{
return static_cast<OPERATION>(static_cast<int>(lhs) | static_cast<int>(rhs));
}
enum MODE
{
LOCAL,
WORLD
};
IMGUI_API bool Manipulate(const float* view, const float* projection, OPERATION operation, MODE mode, float* matrix, float* deltaMatrix = NULL, const float* snap = NULL, const float* localBounds = NULL, const float* boundsSnap = NULL);
//
// Please note that this cubeview is patented by Autodesk : https://patents.google.com/patent/US7782319B2/en
// It seems to be a defensive patent in the US. I don't think it will bring troubles using it as
// other software are using the same mechanics. But just in case, you are now warned!
//
IMGUI_API void ViewManipulate(float* view, float length, ImVec2 position, ImVec2 size, ImU32 backgroundColor);
IMGUI_API void SetID(int id);
// return true if the cursor is over the operation's gizmo
IMGUI_API bool IsOver(OPERATION op);
IMGUI_API void SetGizmoSizeClipSpace(float value);
// Allow axis to flip
// When true (default), the guizmo axis flip for better visibility
// When false, they always stay along the positive world/local axis
IMGUI_API void AllowAxisFlip(bool value);
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,146 @@
#pragma once
// License: zlib
// Copyright (c) 2019 Juliette Foucaut & Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
/*
imgui_markdown https://github.com/juliettef/imgui_markdown
Markdown for Dear ImGui
A permissively licensed markdown single-header library for https://github.com/ocornut/imgui
imgui_markdown currently supports the following markdown functionality:
- Wrapped text
- Headers H1, H2, H3
- Indented text, multi levels
- Unordered lists and sub-lists
- Links
Syntax
Wrapping:
Text wraps automatically. To add a new line, use 'Return'.
Headers:
# H1
## H2
### H3
Indents:
On a new line, at the start of the line, add two spaces per indent.
Indent level 1
Indent level 2
Unordered lists:
On a new line, at the start of the line, add two spaces, an asterisks and a space.
For nested lists, add two additional spaces in front of the asterisk per list level increment.
* Unordered List level 1
* Unordered List level 2
Links:
[link description](https://...)
===============================================================================
// Example use on Windows with links opening in a browser
#include "ImGui.h" // https://github.com/ocornut/imgui
#include "imgui_markdown.h" // https://github.com/juliettef/imgui_markdown
#include "IconsFontAwesome5.h" // https://github.com/juliettef/IconFontCppHeaders
// Following includes for Windows LinkCallback
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include "Shellapi.h"
#include <string>
// You can make your own Markdown function with your prefered string container and markdown config.
static ImGui::MarkdownConfig mdConfig{ LinkCallback, ICON_FA_LINK, { NULL, true, NULL, true, NULL, false } };
void LinkCallback( const char* link_, uint32_t linkLength_ )
{
std::string url( link_, linkLength_ );
ShellExecuteA( NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL );
}
void LoadFonts( float fontSize_ = 12.0f )
{
ImGuiIO& io = ImGui::GetIO();
io.Fonts->Clear();
// Base font
io.Fonts->AddFontFromFileTTF( "myfont.ttf", fontSize_ );
// Bold headings H2 and H3
mdConfig.headingFormats[ 1 ].font = io.Fonts->AddFontFromFileTTF( "myfont-bold.ttf", fontSize_ );
mdConfig.headingFormats[ 2 ].font = mdConfig.headingFormats[ 1 ].font;
// bold heading H1
float fontSizeH1 = fontSize_ * 1.1f;
mdConfig.headingFormats[ 0 ].font = io.Fonts->AddFontFromFileTTF( "myfont-bold.ttf", fontSizeH1 );
}
void Markdown( const std::string& markdown_ )
{
// fonts for, respectively, headings H1, H2, H3 and beyond
ImGui::Markdown( markdown_.c_str(), markdown_.length(), mdConfig );
}
void MarkdownExample()
{
const std::string markdownText = u8R"(
# H1 Header: Text and Links
You can add [links like this one to enkisoftware](https://www.enkisoftware.com/) and lines will wrap well.
## H2 Header: indented text.
This text has an indent (two leading spaces).
This one has two.
### H3 Header: Lists
* Unordered lists
* Lists can be indented with two extra spaces.
* Lists can have [links like this one to Avoyd](https://www.avoyd.com/)
)";
Markdown( markdownText );
}
===============================================================================
*/
#include <stdint.h>
namespace ImGui
{
// Configuration struct for Markdown
// * linkCallback is called when a link is clicked on
// * linkIcon is a string which encode a "Link" icon, if available in the current font (e.g. linkIcon = ICON_FA_LINK with FontAwesome + IconFontCppHeaders https://github.com/juliettef/IconFontCppHeaders)
// * HeadingFormat controls the format of heading H1 to H3, those above H3 use H3 format
// * font is the index into the ImGui font array
// * separator controls whether an underlined separator is drawn after the header
struct MarkdownConfig
{
typedef void MarkdownLinkCallback( const char* link_, uint32_t linkLength_ );
struct HeadingFormat{ ImFont* font; bool separator; };
static const int NUMHEADINGS = 3;
MarkdownLinkCallback* linkCallback = 0;
const char* linkIcon = "";
HeadingFormat headingFormats[ NUMHEADINGS ] = { { NULL, true }, { NULL, true }, { NULL, true } };
};
// External interface
void Markdown( const char* markdown_, int32_t markdownLength_, const MarkdownConfig& mdConfig_ );
}

View file

@ -0,0 +1,461 @@
#pragma once
// License: zlib
// Copyright (c) 2019 Juliette Foucaut & Doug Binks
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.
// 2. Altered source versions must be plainly marked as such, and must not be
// misrepresented as being the original software.
// 3. This notice may not be removed or altered from any source distribution.
/*
imgui_markdown https://github.com/juliettef/imgui_markdown
Markdown for Dear ImGui
A permissively licensed markdown single-header library for https://github.com/ocornut/imgui
imgui_markdown currently supports the following markdown functionality:
- Wrapped text
- Headers H1, H2, H3
- Indented text, multi levels
- Unordered lists and sub-lists
- Links
Syntax
Wrapping:
Text wraps automatically. To add a new line, use 'Return'.
Headers:
# H1
## H2
### H3
Indents:
On a new line, at the start of the line, add two spaces per indent.
··Indent level 1
····Indent level 2
Unordered lists:
On a new line, at the start of the line, add two spaces, an asterisks and a space.
For nested lists, add two additional spaces in front of the asterisk per list level increment.
··*·Unordered List level 1
····*·Unordered List level 2
Links:
[link description](https://...)
===============================================================================
// Example use on Windows with links opening in a browser
#include "ImGui.h" // https://github.com/ocornut/imgui
#include "imgui_markdown.h" // https://github.com/juliettef/imgui_markdown
#include "IconsFontAwesome5.h" // https://github.com/juliettef/IconFontCppHeaders
// Following includes for Windows LinkCallback
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include "Shellapi.h"
#include <string>
// You can make your own Markdown function with your prefered string container and markdown config.
static ImGui::MarkdownConfig mdConfig{ LinkCallback, ICON_FA_LINK, { NULL, true, NULL, true, NULL, false } };
void LinkCallback( const char* link_, uint32_t linkLength_ )
{
std::string url( link_, linkLength_ );
ShellExecuteA( NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL );
}
void LoadFonts( float fontSize_ = 12.0f )
{
ImGuiIO& io = ImGui::GetIO();
io.Fonts->Clear();
// Base font
io.Fonts->AddFontFromFileTTF( "myfont.ttf", fontSize_ );
// Bold headings H2 and H3
mdConfig.headingFormats[ 1 ].font = io.Fonts->AddFontFromFileTTF( "myfont-bold.ttf", fontSize_ );
mdConfig.headingFormats[ 2 ].font = mdConfig.headingFormats[ 1 ].font;
// bold heading H1
float fontSizeH1 = fontSize_ * 1.1f;
mdConfig.headingFormats[ 0 ].font = io.Fonts->AddFontFromFileTTF( "myfont-bold.ttf", fontSizeH1 );
}
void Markdown( const std::string& markdown_ )
{
// fonts for, respectively, headings H1, H2, H3 and beyond
ImGui::Markdown( markdown_.c_str(), markdown_.length(), mdConfig );
}
void MarkdownExample()
{
const std::string markdownText = u8R"(
# H1 Header: Text and Links
You can add [links like this one to enkisoftware](https://www.enkisoftware.com/) and lines will wrap well.
## H2 Header: indented text.
This text has an indent (two leading spaces).
This one has two.
### H3 Header: Lists
* Unordered lists
* Lists can be indented with two extra spaces.
* Lists can have [links like this one to Avoyd](https://www.avoyd.com/)
)";
Markdown( markdownText );
}
===============================================================================
*/
#include <stdint.h>
namespace ImGui
{
// Internals
struct TextRegion;
struct Line;
inline void UnderLine( ImColor col_ );
inline void RenderLine( const char* markdown_, Line& line_, TextRegion& textRegion_, const MarkdownConfig& mdConfig_ );
struct TextRegion
{
TextRegion() : indentX( 0.0f )
{
pFont = ImGui::GetFont();
}
~TextRegion()
{
ResetIndent();
}
// ImGui::TextWrapped will wrap at the starting position
// so to work around this we render using our own wrapping for the first line
void RenderTextWrapped( const char* text, const char* text_end, bool bIndentToHere = false )
{
const float scale = 1.0f;
float widthLeft = GetContentRegionAvail().x;
const char* endPrevLine = pFont->CalcWordWrapPositionA( scale, text, text_end, widthLeft );
ImGui::TextUnformatted( text, endPrevLine );
if( bIndentToHere )
{
float indentNeeded = GetContentRegionAvail().x - widthLeft;
if( indentNeeded )
{
ImGui::Indent( indentNeeded );
indentX += indentNeeded;
}
}
widthLeft = GetContentRegionAvail().x;
while( endPrevLine < text_end )
{
text = endPrevLine;
if( *text == ' ' ) { ++text; } // skip a space at start of line
endPrevLine = pFont->CalcWordWrapPositionA( scale, text, text_end, widthLeft );
if (text == endPrevLine)
{
endPrevLine++;
}
ImGui::TextUnformatted( text, endPrevLine );
}
}
void RenderListTextWrapped( const char* text, const char* text_end )
{
ImGui::Bullet();
ImGui::SameLine();
RenderTextWrapped( text, text_end, true );
}
void ResetIndent()
{
if( indentX > 0.0f )
{
ImGui::Unindent( indentX );
}
indentX = 0.0f;
}
private:
float indentX;
ImFont* pFont;
};
// Text that starts after a new line (or at beginning) and ends with a newline (or at end)
struct Line {
bool isHeading = false;
bool isUnorderedListStart = false;
bool isLeadingSpace = true; // spaces at start of line
int leadSpaceCount = 0;
int headingCount = 0;
int lineStart = 0;
int lineEnd = 0;
int lastRenderPosition = 0; // lines may get rendered in multiple pieces
};
struct TextBlock { // subset of line
int start = 0;
int stop = 0;
int size() const
{
return stop - start;
}
};
struct Link {
enum LinkState {
NO_LINK,
HAS_SQUARE_BRACKET_OPEN,
HAS_SQUARE_BRACKETS,
HAS_SQUARE_BRACKETS_ROUND_BRACKET_OPEN,
};
LinkState state = NO_LINK;
TextBlock text;
TextBlock url;
};
inline void UnderLine( ImColor col_ )
{
ImVec2 min = ImGui::GetItemRectMin();
ImVec2 max = ImGui::GetItemRectMax();
min.y = max.y;
ImGui::GetWindowDrawList()->AddLine( min, max, col_, 1.0f );
}
inline void RenderLine( const char* markdown_, Line& line_, TextRegion& textRegion_, const MarkdownConfig& mdConfig_ )
{
// indent
int indentStart = 0;
if( line_.isUnorderedListStart ) // ImGui unordered list render always adds one indent
{
indentStart = 1;
}
for( int j = indentStart; j < line_.leadSpaceCount / 2; ++j ) // add indents
{
ImGui::Indent();
}
// render
int textStart = line_.lastRenderPosition + 1;
int textSize = line_.lineEnd - textStart;
if( line_.isUnorderedListStart ) // render unordered list
{
const char* text = markdown_ + textStart + 1;
textRegion_.RenderListTextWrapped( text, text + textSize - 1 );
}
else if( line_.isHeading ) // render heading
{
MarkdownConfig::HeadingFormat fmt;
if( line_.headingCount > mdConfig_.NUMHEADINGS )
{
fmt = mdConfig_.headingFormats[ mdConfig_.NUMHEADINGS - 1 ];
}
else
{
fmt = mdConfig_.headingFormats[ line_.headingCount - 1 ];
}
bool popFontRequired = false;
if( fmt.font && fmt.font != ImGui::GetFont() )
{
ImGui::PushFont( fmt.font );
popFontRequired = true;
}
const char* text = markdown_ + textStart + 1;
ImGui::NewLine();
textRegion_.RenderTextWrapped( text, text + textSize - 1 );
if( fmt.separator )
{
ImGui::Separator();
}
ImGui::NewLine();
if( popFontRequired )
{
ImGui::PopFont();
}
}
else // render a normal paragraph chunk
{
const char* text = markdown_ + textStart;
textRegion_.RenderTextWrapped( text, text + textSize );
}
// unindent
for( int j = indentStart; j < line_.leadSpaceCount / 2; ++j )
{
ImGui::Unindent();
}
}
// render markdown
void Markdown( const char* markdown_, int32_t markdownLength_, const MarkdownConfig& mdConfig_ )
{
ImGuiStyle& style = ImGui::GetStyle();
Line line;
Link link;
TextRegion textRegion;
char c = 0;
for( int i=0; i < markdownLength_; ++i )
{
c = markdown_[i]; // get the character at index
if( c == 0 ) { break; } // shouldn't happen but don't go beyond 0.
// If we're at the beginning of the line, count any spaces
if( line.isLeadingSpace )
{
if( c == ' ' )
{
++line.leadSpaceCount;
continue;
}
else
{
line.isLeadingSpace = false;
line.lastRenderPosition = i - 1;
if(( c == '*' ) && ( line.leadSpaceCount >= 2 ))
{
if(( markdownLength_ > i + 1 ) && ( markdown_[ i + 1 ] == ' ' )) // space after '*'
{
line.isUnorderedListStart = true;
++i;
++line.lastRenderPosition;
}
continue;
}
else if( c == '#' )
{
line.headingCount++;
bool bContinueChecking = true;
int32_t j = i;
while( ++j < markdownLength_ && bContinueChecking )
{
c = markdown_[j];
switch( c )
{
case '#':
line.headingCount++;
break;
case ' ':
line.lastRenderPosition = j - 1;
i = j;
line.isHeading = true;
bContinueChecking = false;
break;
default:
line.isHeading = false;
bContinueChecking = false;
break;
}
}
if( line.isHeading ) { continue; }
}
}
}
// Test to see if we have a link
switch( link.state )
{
case Link::NO_LINK:
if( c == '[' )
{
link.state = Link::HAS_SQUARE_BRACKET_OPEN;
link.text.start = i + 1;
}
break;
case Link::HAS_SQUARE_BRACKET_OPEN:
if( c == ']' )
{
link.state = Link::HAS_SQUARE_BRACKETS;
link.text.stop = i;
}
break;
case Link::HAS_SQUARE_BRACKETS:
if( c == '(' )
{
link.state = Link::HAS_SQUARE_BRACKETS_ROUND_BRACKET_OPEN;
link.url.start = i + 1;
}
break;
case Link::HAS_SQUARE_BRACKETS_ROUND_BRACKET_OPEN:
if( c == ')' ) // it's a link, render it.
{
// render previous line content
line.lineEnd = link.text.start - 1;
RenderLine( markdown_, line, textRegion, mdConfig_ );
line.leadSpaceCount = 0;
line.isUnorderedListStart = false; // the following text shouldn't have bullets
// render link
link.url.stop = i;
ImGui::SameLine( 0.0f, 0.0f );
ImGui::PushStyleColor( ImGuiCol_Text, style.Colors[ ImGuiCol_ButtonHovered ]);
ImGui::PushTextWrapPos(-1.0f);
const char* text = markdown_ + link.text.start ;
ImGui::TextUnformatted( text, text + link.text.size() );
ImGui::PopTextWrapPos();
ImGui::PopStyleColor();
if (ImGui::IsItemHovered())
{
if( ImGui::IsMouseClicked(0) )
{
if( mdConfig_.linkCallback )
{
mdConfig_.linkCallback( markdown_ + link.url.start, link.url.size() );
}
}
ImGui::UnderLine( style.Colors[ ImGuiCol_ButtonHovered ] );
ImGui::SetTooltip( "%s Open in browser\n%.*s", mdConfig_.linkIcon, link.url.size(), markdown_ + link.url.start );
}
else
{
ImGui::UnderLine( style.Colors[ ImGuiCol_Button ] );
}
ImGui::SameLine( 0.0f, 0.0f );
// reset the link by reinitializing it
link = Link();
line.lastRenderPosition = i;
}
break;
}
// handle end of line (render)
if( c == '\n' )
{
// render the line
line.lineEnd = i;
RenderLine( markdown_, line, textRegion, mdConfig_ );
// reset the line
line = Line();
line.lineStart = i + 1;
line.lastRenderPosition = i;
textRegion.ResetIndent();
// reset the link
link = Link();
}
}
// render any remaining text if last char wasn't 0
if( markdownLength_ && line.lineStart < (int)markdownLength_ && markdown_[ line.lineStart ] != 0 )
{
line.lineEnd = (int)markdownLength_ - 1;
RenderLine( markdown_, line, textRegion, mdConfig_ );
}
}
}

View file

@ -0,0 +1,27 @@
namespace ImGui
{
struct MemoryEditor
{
bool AllowEdits;
bool HexII;
int Rows;
int DataEditingAddr;
bool DataEditingTakeFocus;
char DataInput[32];
char AddrInput[32];
MemoryEditor()
{
AllowEdits = true;
HexII = true;
Rows = 16;
DataEditingAddr = -1;
DataEditingTakeFocus = false;
strcpy(DataInput, "");
strcpy(AddrInput, "");
}
void Draw(void* mem_data, int mem_size, int base_display_addr = 0);
void Draw(const void* mem_data, int mem_size, int base_display_addr = 0);
};
} // namespace ImGui

View file

@ -0,0 +1,250 @@
#ifdef _MSC_VER
# define snprintf _snprintf
#endif
namespace ImGui
{
// const char* title;
// if (Begin(title, &Open))
// {
// End();
// }
void MemoryEditor::Draw(void* mem_data_void, int mem_size, int base_display_addr)
{
PushFont(Font::Mono);
unsigned char* mem_data = (unsigned char*)mem_data_void;
BeginChild("##scrolling", ImVec2(0, -GetFrameHeight()));
if (ImGui::BeginPopupContextWindow() )
{
ImGui::Checkbox("HexII", &HexII);
ImGui::EndPopup();
}
PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0.0f, 0.0f) );
PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.0f, 0.0f) );
int addr_digits_count = 0;
for (int n = base_display_addr + mem_size - 1; n > 0; n >>= 4)
{
addr_digits_count++;
}
float glyph_width = CalcTextSize("F").x;
float cell_width = glyph_width * 3; // "FF " we include trailing space in the width to easily catch clicks everywhere
float line_height = GetTextLineHeight();
int line_total_count = (int)((mem_size + Rows-1) / Rows);
ImGuiListClipper clipper;
clipper.Begin(line_total_count, line_height);
int visible_start_addr = clipper.DisplayStart * Rows;
int visible_end_addr = clipper.DisplayEnd * Rows;
bool data_next = false;
if (!AllowEdits || DataEditingAddr >= mem_size)
{
DataEditingAddr = -1;
}
int data_editing_addr_backup = DataEditingAddr;
if (DataEditingAddr != -1)
{
if (IsKeyPressed(GetKeyIndex(ImGuiKey_UpArrow)) && DataEditingAddr >= Rows) { DataEditingAddr -= Rows; DataEditingTakeFocus = true; }
else if (IsKeyPressed(GetKeyIndex(ImGuiKey_DownArrow)) && DataEditingAddr < mem_size - Rows) { DataEditingAddr += Rows; DataEditingTakeFocus = true; }
else if (IsKeyPressed(GetKeyIndex(ImGuiKey_LeftArrow)) && DataEditingAddr > 0) { DataEditingAddr -= 1; DataEditingTakeFocus = true; }
else if (IsKeyPressed(GetKeyIndex(ImGuiKey_RightArrow)) && DataEditingAddr < mem_size - 1) { DataEditingAddr += 1; DataEditingTakeFocus = true; }
}
if ((DataEditingAddr / Rows) != (data_editing_addr_backup / Rows))
{
// Track cursor movements
float scroll_offset = ((DataEditingAddr / Rows) - (data_editing_addr_backup / Rows)) * line_height;
bool scroll_desired = (scroll_offset < 0.0f && DataEditingAddr < visible_start_addr + Rows*2) || (scroll_offset > 0.0f && DataEditingAddr > visible_end_addr - Rows*2);
if (scroll_desired)
{
SetScrollY(GetScrollY() + scroll_offset);
}
}
bool draw_separator = true;
for (int line_i = clipper.DisplayStart; line_i < clipper.DisplayEnd; line_i++) // display only visible items
{
int addr = line_i * Rows;
Text("%0*x: ", addr_digits_count, base_display_addr+addr);
SameLine();
// Draw Hexadecimal
float line_start_x = GetCursorPosX();
for (int n = 0; n < Rows && addr < mem_size; n++, addr++)
{
SameLine(line_start_x + cell_width * n);
if (DataEditingAddr == addr)
{
// Display text input on current byte
PushID(addr);
struct FuncHolder
{
// FIXME: We should have a way to retrieve the text edit cursor position more easily in the API, this is rather tedious.
static int Callback(ImGuiInputTextCallbackData* data)
{
int* p_cursor_pos = (int*)data->UserData;
if (!data->HasSelection())
{
*p_cursor_pos = data->CursorPos;
}
return 0;
}
};
int cursor_pos = -1;
bool data_write = false;
if (DataEditingTakeFocus)
{
SetKeyboardFocusHere();
snprintf(AddrInput, sizeof(AddrInput), "%0*x", addr_digits_count, base_display_addr+addr);
snprintf(DataInput, sizeof(DataInput), "%02x", mem_data[addr]);
}
PushItemWidth(CalcTextSize("FF").x);
ImGuiInputTextFlags flags = ImGuiInputTextFlags_CharsHexadecimal|ImGuiInputTextFlags_EnterReturnsTrue|ImGuiInputTextFlags_AutoSelectAll|ImGuiInputTextFlags_NoHorizontalScroll|ImGuiInputTextFlags_AlwaysOverwrite|ImGuiInputTextFlags_CallbackAlways;
if (InputText("##data", DataInput, 32, flags, FuncHolder::Callback, &cursor_pos))
{
data_write = data_next = true;
}
else if (!DataEditingTakeFocus && !IsItemActive())
{
DataEditingAddr = -1;
}
DataEditingTakeFocus = false;
PopItemWidth();
if (cursor_pos >= 2)
{
data_write = data_next = true;
}
if (data_write)
{
int data;
if (sscanf(DataInput, "%X", &data) == 1)
{
mem_data[addr] = (unsigned char)data;
}
}
PopID();
}
else
{
if (HexII)
{
unsigned char byte = mem_data[addr];
if (isprint(byte) )
{
Text(".%c ", byte);
}
else if (0x00 == byte)
{
Text(" ");
}
else if (0xff == byte)
{
Text("## ");
}
else
{
Text("%02x ", byte);
}
}
else
{
Text("%02x ", mem_data[addr]);
}
if (AllowEdits && IsItemHovered() && IsMouseClicked(0))
{
DataEditingTakeFocus = true;
DataEditingAddr = addr;
}
}
}
SameLine(line_start_x + cell_width * Rows + glyph_width * 2);
if (draw_separator)
{
ImVec2 screen_pos = GetCursorScreenPos();
GetWindowDrawList()->AddLine(ImVec2(screen_pos.x - glyph_width, screen_pos.y - 9999), ImVec2(screen_pos.x - glyph_width, screen_pos.y + 9999), ImColor(GetStyle().Colors[ImGuiCol_Border]));
draw_separator = false;
}
// Draw ASCII values
addr = line_i * Rows;
for (int n = 0; n < Rows && addr < mem_size; n++, addr++)
{
if (n > 0) { SameLine(); }
int c = mem_data[addr];
Text("%c", (c >= 32 && c < 128) ? c : '.');
}
}
clipper.End();
PopStyleVar(2);
EndChild();
if (data_next && DataEditingAddr < mem_size)
{
DataEditingAddr = DataEditingAddr + 1;
DataEditingTakeFocus = true;
}
Separator();
AlignTextToFramePadding();
PushItemWidth(50);
PushAllowKeyboardFocus(false);
int rows_backup = Rows;
if (DragInt("##rows", &Rows, 0.2f, 4, 32, "%.0f rows"))
{
ImVec2 new_window_size = GetWindowSize();
new_window_size.x += (Rows - rows_backup) * (cell_width + glyph_width);
SetWindowSize(new_window_size);
}
PopAllowKeyboardFocus();
PopItemWidth();
SameLine();
Text("Range %0*x..%0*x", addr_digits_count, (int)base_display_addr, addr_digits_count, (int)base_display_addr+mem_size-1);
SameLine();
PushItemWidth(70);
if (InputText("##addr", AddrInput, 32, ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_EnterReturnsTrue))
{
int goto_addr;
if (sscanf(AddrInput, "%X", &goto_addr) == 1)
{
goto_addr -= base_display_addr;
if (goto_addr >= 0 && goto_addr < mem_size)
{
BeginChild("##scrolling");
SetScrollFromPosY(GetCursorStartPos().y + (goto_addr / Rows) * GetTextLineHeight());
EndChild();
DataEditingAddr = goto_addr;
DataEditingTakeFocus = true;
}
}
}
PopItemWidth();
PopFont();
}
void MemoryEditor::Draw(const void* mem_data, int mem_size, int base_display_addr)
{
Draw(const_cast<void*>(mem_data), mem_size, base_display_addr);
}
} // namespace ImGui

View file

@ -0,0 +1,5 @@
namespace ImGui
{
IMGUI_API bool RangeSliderFloat(const char* label, float* v1, float* v2, float v_min, float v_max, const char* display_format = "(%.3f, %.3f)", float power = 1.0f);
} // namespace ImGui

View file

@ -0,0 +1,222 @@
// https://github.com/ocornut/imgui/issues/76
// Taken from: https://github.com/wasikuss/imgui/commit/a50515ace6d9a62ebcd69817f1da927d31c39bb1
namespace ImGui
{
extern float RoundScalarWithFormatFloat(const char* format, ImGuiDataType data_type, float v);
extern float SliderCalcRatioFromValueFloat(ImGuiDataType data_type, float v, float v_min, float v_max, float power, float linear_zero_pos);
// ~80% common code with ImGui::SliderBehavior
bool RangeSliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v1, float* v2, float v_min, float v_max, float power, int decimal_precision, ImGuiSliderFlags flags)
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = GetCurrentWindow();
const ImGuiStyle& style = g.Style;
// Draw frame
RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding);
const bool is_non_linear = (power < 1.0f-0.00001f) || (power > 1.0f+0.00001f);
const bool is_horizontal = (flags & ImGuiSliderFlags_Vertical) == 0;
const float grab_padding = 2.0f;
const float slider_sz = is_horizontal ? (frame_bb.GetWidth() - grab_padding * 2.0f) : (frame_bb.GetHeight() - grab_padding * 2.0f);
float grab_sz;
if (decimal_precision > 0)
grab_sz = ImMin(style.GrabMinSize, slider_sz);
else
grab_sz = ImMin(ImMax(1.0f * (slider_sz / ((v_min < v_max ? v_max - v_min : v_min - v_max) + 1.0f)), style.GrabMinSize), slider_sz); // Integer sliders, if possible have the grab size represent 1 unit
const float slider_usable_sz = slider_sz - grab_sz;
const float slider_usable_pos_min = (is_horizontal ? frame_bb.Min.x : frame_bb.Min.y) + grab_padding + grab_sz*0.5f;
const float slider_usable_pos_max = (is_horizontal ? frame_bb.Max.x : frame_bb.Max.y) - grab_padding - grab_sz*0.5f;
// For logarithmic sliders that cross over sign boundary we want the exponential increase to be symmetric around 0.0f
float linear_zero_pos = 0.0f; // 0.0->1.0f
if (v_min * v_max < 0.0f)
{
// Different sign
const float linear_dist_min_to_0 = powf(fabsf(0.0f - v_min), 1.0f/power);
const float linear_dist_max_to_0 = powf(fabsf(v_max - 0.0f), 1.0f/power);
linear_zero_pos = linear_dist_min_to_0 / (linear_dist_min_to_0+linear_dist_max_to_0);
}
else
{
// Same sign
linear_zero_pos = v_min < 0.0f ? 1.0f : 0.0f;
}
// Process clicking on the slider
bool value_changed = false;
if (g.ActiveId == id)
{
if (g.IO.MouseDown[0])
{
const float mouse_abs_pos = is_horizontal ? g.IO.MousePos.x : g.IO.MousePos.y;
float clicked_t = (slider_usable_sz > 0.0f) ? ImClamp((mouse_abs_pos - slider_usable_pos_min) / slider_usable_sz, 0.0f, 1.0f) : 0.0f;
if (!is_horizontal)
clicked_t = 1.0f - clicked_t;
float new_value;
if (is_non_linear)
{
// Account for logarithmic scale on both sides of the zero
if (clicked_t < linear_zero_pos)
{
// Negative: rescale to the negative range before powering
float a = 1.0f - (clicked_t / linear_zero_pos);
a = powf(a, power);
new_value = ImLerp(ImMin(v_max,0.0f), v_min, a);
}
else
{
// Positive: rescale to the positive range before powering
float a;
if (fabsf(linear_zero_pos - 1.0f) > 1.e-6f)
a = (clicked_t - linear_zero_pos) / (1.0f - linear_zero_pos);
else
a = clicked_t;
a = powf(a, power);
new_value = ImLerp(ImMax(v_min,0.0f), v_max, a);
}
}
else
{
// Linear slider
new_value = ImLerp(v_min, v_max, clicked_t);
}
char fmt[64];
snprintf(fmt, 64, "%%.%df", decimal_precision);
// Round past decimal precision
new_value = RoundScalarWithFormatFloat(fmt, ImGuiDataType_Float, new_value);
if (*v1 != new_value || *v2 != new_value)
{
if (fabsf(*v1 - new_value) < fabsf(*v2 - new_value))
{
*v1 = new_value;
}
else
{
*v2 = new_value;
}
value_changed = true;
}
}
else
{
ClearActiveID();
}
}
// Calculate slider grab positioning
float grab_t = SliderCalcRatioFromValueFloat(ImGuiDataType_Float, *v1, v_min, v_max, power, linear_zero_pos);
// Draw
if (!is_horizontal)
grab_t = 1.0f - grab_t;
float grab_pos = ImLerp(slider_usable_pos_min, slider_usable_pos_max, grab_t);
ImRect grab_bb1;
if (is_horizontal)
grab_bb1 = ImRect(ImVec2(grab_pos - grab_sz*0.5f, frame_bb.Min.y + grab_padding), ImVec2(grab_pos + grab_sz*0.5f, frame_bb.Max.y - grab_padding));
else
grab_bb1 = ImRect(ImVec2(frame_bb.Min.x + grab_padding, grab_pos - grab_sz*0.5f), ImVec2(frame_bb.Max.x - grab_padding, grab_pos + grab_sz*0.5f));
window->DrawList->AddRectFilled(grab_bb1.Min, grab_bb1.Max, GetColorU32(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab), style.GrabRounding);
// Calculate slider grab positioning
grab_t = SliderCalcRatioFromValueFloat(ImGuiDataType_Float, *v2, v_min, v_max, power, linear_zero_pos);
// Draw
if (!is_horizontal)
grab_t = 1.0f - grab_t;
grab_pos = ImLerp(slider_usable_pos_min, slider_usable_pos_max, grab_t);
ImRect grab_bb2;
if (is_horizontal)
grab_bb2 = ImRect(ImVec2(grab_pos - grab_sz*0.5f, frame_bb.Min.y + grab_padding), ImVec2(grab_pos + grab_sz*0.5f, frame_bb.Max.y - grab_padding));
else
grab_bb2 = ImRect(ImVec2(frame_bb.Min.x + grab_padding, grab_pos - grab_sz*0.5f), ImVec2(frame_bb.Max.x - grab_padding, grab_pos + grab_sz*0.5f));
window->DrawList->AddRectFilled(grab_bb2.Min, grab_bb2.Max, GetColorU32(g.ActiveId == id ? ImGuiCol_SliderGrabActive : ImGuiCol_SliderGrab), style.GrabRounding);
ImRect connector(grab_bb1.Min, grab_bb2.Max);
connector.Min.x += grab_sz;
connector.Min.y += grab_sz*0.3f;
connector.Max.x -= grab_sz;
connector.Max.y -= grab_sz*0.3f;
window->DrawList->AddRectFilled(connector.Min, connector.Max, GetColorU32(ImGuiCol_SliderGrab), style.GrabRounding);
return value_changed;
}
// ~95% common code with ImGui::SliderFloat
bool RangeSliderFloat(const char* label, float* v1, float* v2, float v_min, float v_max, const char* display_format, float power)
{
ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems)
return false;
ImGuiContext& g = *GImGui;
const ImGuiStyle& style = g.Style;
const ImGuiID id = window->GetID(label);
const float w = CalcItemWidth();
const ImVec2 label_size = CalcTextSize(label, NULL, true);
const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y*2.0f));
const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
// NB- we don't call ItemSize() yet because we may turn into a text edit box below
if (!ItemAdd(total_bb, id))
{
ItemSize(total_bb, style.FramePadding.y);
return false;
}
const bool hovered = ItemHoverable(frame_bb, id);
if (hovered)
SetHoveredID(id);
if (!display_format)
display_format = "(%.3f, %.3f)";
int decimal_precision = ImParseFormatPrecision(display_format, 3);
// Tabbing or CTRL-clicking on Slider turns it into an input box
bool start_text_input = false;
const bool tab_focus_requested = (GetItemStatusFlags() & ImGuiItemStatusFlags_FocusedByTabbing) != 0;
if (tab_focus_requested || (hovered && g.IO.MouseClicked[0]))
{
SetActiveID(id, window);
FocusWindow(window);
if (tab_focus_requested || g.IO.KeyCtrl)
{
start_text_input = true;
g.TempInputId = 0;
}
}
if (start_text_input || (g.ActiveId == id && g.TempInputId == id))
{
char fmt[64];
snprintf(fmt, 64, "%%.%df", decimal_precision);
return TempInputScalar(frame_bb, id, label, ImGuiDataType_Float, v1, fmt);
}
ItemSize(total_bb, style.FramePadding.y);
// Actual slider behavior + render grab
const bool value_changed = RangeSliderBehavior(frame_bb, id, v1, v2, v_min, v_max, power, decimal_precision, 0);
// Display value using user-provided display format so user can add prefix/suffix/decorations to the value.
char value_buf[64];
const char* value_buf_end = value_buf + ImFormatString(value_buf, IM_ARRAYSIZE(value_buf), display_format, *v1, *v2);
RenderTextClipped(frame_bb.Min, frame_bb.Max, value_buf, value_buf_end, NULL, ImVec2(0.5f,0.5f));
if (label_size.x > 0.0f)
RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label);
return value_changed;
}
} // namespace ImGui

View file

@ -0,0 +1,77 @@
MICROSOFT SOFTWARE LICENSE TERMS
MICROSOFT DIRECTX SOFTWARE DEVELOPMENT KIT (SDK)
These license terms are an agreement between Microsoft Corporation (or based on where you live, one of its affiliates) and you. Please read them. They apply to the software named above, which includes the media on which you received it, if any. The terms also apply to any Microsoft
• updates,
• supplements,
• Internet-based services, and
• support services
for this software, unless other terms accompany those items. If so, those terms apply.
BY USING THE SOFTWARE, YOU ACCEPT THESE TERMS. IF YOU DO NOT ACCEPT THEM, DO NOT USE THE SOFTWARE.
If you comply with these license terms, you have the rights below.
1. INSTALLATION AND USE RIGHTS.
a. Installation and Use. You may install and use any number of copies of the software on your devices.
b. Included Microsoft Programs. The software contains other Microsoft programs. The license terms with those programs apply to your use of them.
2. ADDITIONAL LICENSING REQUIREMENTS AND/OR USE RIGHTS.
a. Media Elements and Templates. You may copy and use images, clip art, animations, sounds, music, shapes, video clips and templates provided with the software and identified for such use in documents and projects that you create. You may distribute those documents and projects non-commercially. If you wish to use these media elements or templates for any other purpose, go to www.microsoft.com/permission to learn whether that use is allowed.
b. Distributable Code. The software contains code that you are permitted to distribute in programs you develop if you comply with the terms below.
i. Right to Use and Distribute. The code and text files listed below are “Distributable Code.”
• DIRECTX REDIST.TXT Files. You may copy and distribute the object code form of code listed in DIRECTX REDIST.TXT files.
• Sample Code. You may modify, copy, and distribute the source and object code form of code marked as “sample”, as well as those marked as follows:
\Utilities\bin\x86\dxerr
\Utilities\bin\x64\dxerr
\Utilities\bin\x86\dxtex
\Utilities\bin\x64\dxtex
\Utilities\bin\x86\DxViewer
\Utilities\bin\x64\DxViewer
\Utilities\bin\x86\GDFTrace
\Utilities\bin\x64\GDFTrace
\Utilities\bin\x86\MeshConvert
\Utilities\bin\x64\MeshConvert
\Utilities\Source\Sas
\Utilities\Source\Effects11
• Third Party Distribution. You may permit distributors of your programs to copy and distribute the Distributable Code as part of those programs.
ii. Distribution Requirements. For any Distributable Code you distribute, you must
• add significant primary functionality to it in your programs;
• require distributors and external end users to agree to terms that protect it at least as much as this agreement;
• display your valid copyright notice on your programs; and
• indemnify, defend, and hold harmless Microsoft from any claims, including attorneys fees, related to the distribution or use of your programs.
iii. Distribution Restrictions. You may not
• alter any copyright, trademark or patent notice in the Distributable Code;
• use Microsofts trademarks in your programs names or in a way that suggests your programs come from or are endorsed by Microsoft;
• distribute Distributable Code to run on a platform other than the Windows, Xbox and Windows Mobile platforms;
• include Distributable Code in malicious, deceptive or unlawful programs; or
• modify or distribute the source code of any Distributable Code so that any part of it becomes subject to an Excluded License. An Excluded License is one that requires, as a condition of use, modification or distribution, that
• the code be disclosed or distributed in source code form; or
• others have the right to modify it.
3. SCOPE OF LICENSE. The software is licensed, not sold. This agreement only gives you some rights to use the software. Microsoft reserves all other rights. Unless applicable law gives you more rights despite this limitation, you may use the software only as expressly permitted in this agreement. In doing so, you must comply with any technical limitations in the software that only allow you to use it in certain ways. You may not
• disclose the results of any benchmark tests of the software to any third party without Microsofts prior written approval;
• work around any technical limitations in the software;
• reverse engineer, decompile or disassemble the software, except and only to the extent that applicable law expressly permits, despite this limitation;
• make more copies of the software than specified in this agreement or allowed by applicable law, despite this limitation;
• publish the software for others to copy;
• rent, lease or lend the software; or
• use the software for commercial software hosting services.
4. BACKUP COPY. You may make one backup copy of the software. You may use it only to reinstall the software.
5. DOCUMENTATION. Any person that has valid access to your computer or internal network may copy and use the documentation for your internal, reference purposes.
6. EXPORT RESTRICTIONS. The software is subject to United States export laws and regulations. You must comply with all domestic and international export laws and regulations that apply to the software. These laws include restrictions on destinations, end users and end use. For additional information, see www.microsoft.com/exporting.
7. SUPPORT SERVICES. Because this software is “as is,” we may not provide support services for it.
8. ENTIRE AGREEMENT. This agreement, and the terms for supplements, updates, Internet-based services and support services that you use, are the entire agreement for the software and support services.
9. APPLICABLE LAW.
a. United States. If you acquired the software in the United States, Washington state law governs the interpretation of this agreement and applies to claims for breach of it, regardless of conflict of laws principles. The laws of the state where you live govern all other claims, including claims under state consumer protection laws, unfair competition laws, and in tort.
b. Outside the United States. If you acquired the software in any other country, the laws of that country apply.
10. LEGAL EFFECT. This agreement describes certain legal rights. You may have other rights under the laws of your country. You may also have rights with respect to the party from whom you acquired the software. This agreement does not change your rights under the laws of your country if the laws of your country do not permit it to do so.
11. DISCLAIMER OF WARRANTY. THE SOFTWARE IS LICENSED “AS-IS.” YOU BEAR THE RISK OF USING IT. MICROSOFT GIVES NO EXPRESS WARRANTIES, GUARANTEES OR CONDITIONS. YOU MAY HAVE ADDITIONAL CONSUMER RIGHTS UNDER YOUR LOCAL LAWS WHICH THIS AGREEMENT CANNOT CHANGE. TO THE EXTENT PERMITTED UNDER YOUR LOCAL LAWS, MICROSOFT EXCLUDES THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
12. LIMITATION ON AND EXCLUSION OF REMEDIES AND DAMAGES. YOU CAN RECOVER FROM MICROSOFT AND ITS SUPPLIERS ONLY DIRECT DAMAGES UP TO U.S. $5.00. YOU CANNOT RECOVER ANY OTHER DAMAGES, INCLUDING CONSEQUENTIAL, LOST PROFITS, SPECIAL, INDIRECT OR INCIDENTAL DAMAGES.
This limitation applies to
• anything related to the software, services, content (including code) on third party Internet sites, or third party programs; and
• claims for breach of contract, breach of warranty, guarantee or condition, strict liability, negligence, or other tort to the extent permitted by applicable law.
It also applies even if Microsoft knew or should have known about the possibility of the damages. The above limitation or exclusion may not apply to you because your country may not allow the exclusion or limitation of incidental, consequential or other damages.
Please note: As this software is distributed in Quebec, Canada, some of the clauses in this agreement are provided below in French.
Remarque : Ce logiciel étant distribué au Québec, Canada, certaines des clauses dans ce contrat sont fournies ci-dessous en français.
EXONÉRATION DE GARANTIE. Le logiciel visé par une licence est offert « tel quel ». Toute utilisation de ce logiciel est à votre seule risque et péril. Microsoft naccorde aucune autre garantie expresse. Vous pouvez bénéficier de droits additionnels en vertu du droit local sur la protection des consommateurs, que ce contrat ne peut modifier. La ou elles sont permises par le droit locale, les garanties implicites de qualité marchande, dadéquation à un usage particulier et dabsence de contrefaçon sont exclues.
LIMITATION DES DOMMAGES-INTÉRÊTS ET EXCLUSION DE RESPONSABILITÉ POUR LES DOMMAGES. Vous pouvez obtenir de Microsoft et de ses fournisseurs une indemnisation en cas de dommages directs uniquement à hauteur de 5,00 $ US. Vous ne pouvez prétendre à aucune indemnisation pour les autres dommages, y compris les dommages spéciaux, indirects ou accessoires et pertes de bénéfices.
Cette limitation concerne :
• tout ce qui est relié au logiciel, aux services ou au contenu (y compris le code) figurant sur des sites Internet tiers ou dans des programmes tiers ; et
• les réclamations au titre de violation de contrat ou de garantie, ou au titre de responsabilité stricte, de négligence ou dune autre faute dans la limite autorisée par la loi en vigueur.
Elle sapplique également, même si Microsoft connaissait ou devrait connaître léventualité dun tel dommage. Si votre pays nautorise pas lexclusion ou la limitation de responsabilité pour les dommages indirects, accessoires ou de quelque nature que ce soit, il se peut que la limitation ou lexclusion ci-dessus ne sappliquera pas à votre égard.
EFFET JURIDIQUE. Le présent contrat décrit certains droits juridiques. Vous pourriez avoir dautres droits prévus par les lois de votre pays. Le présent contrat ne modifie pas les droits que vous confèrent les lois de votre pays si celles-ci ne le permettent pas.

View file

@ -0,0 +1,483 @@
/*==========================================================================;
*
* Copyright (C) Microsoft Corporation. All Rights Reserved.
*
* File: PIXEventsCommon.h
* Content: PIX include file
* Don't include this file directly - use pix3.h
*
****************************************************************************/
#pragma once
#ifndef _PIXEventsCommon_H_
#define _PIXEventsCommon_H_
#if defined(_AMD64_) || defined(_X86_)
#include <emmintrin.h>
#endif // _AMD64_ || _X86_
enum PIXEventType
{
PIXEvent_EndEvent = 0x000,
PIXEvent_BeginEvent_VarArgs = 0x001,
PIXEvent_BeginEvent_NoArgs = 0x002,
PIXEvent_SetMarker_VarArgs = 0x007,
PIXEvent_SetMarker_NoArgs = 0x008,
PIXEvent_EndEvent_OnContext = 0x010,
PIXEvent_BeginEvent_OnContext_VarArgs = 0x011,
PIXEvent_BeginEvent_OnContext_NoArgs = 0x012,
PIXEvent_SetMarker_OnContext_VarArgs = 0x017,
PIXEvent_SetMarker_OnContext_NoArgs = 0x018,
};
static const UINT64 PIXEventsReservedRecordSpaceQwords = 64;
//this is used to make sure SSE string copy always will end 16-byte write in the current block
//this way only a check if destination < limit can be performed, instead of destination < limit - 1
//since both these are UINT64* and SSE writes in 16 byte chunks, 8 bytes are kept in reserve
//so even if SSE overwrites 8 extra bytes, those will still belong to the correct block
//on next iteration check destination will be greater than limit
//this is used as well for fixed size UMD events and PIXEndEvent since these require less space
//than other variable length user events and do not need big reserved space
static const UINT64 PIXEventsReservedTailSpaceQwords = 2;
static const UINT64 PIXEventsSafeFastCopySpaceQwords = PIXEventsReservedRecordSpaceQwords - PIXEventsReservedTailSpaceQwords;
static const UINT64 PIXEventsGraphicsRecordSpaceQwords = 64;
//Bits 7-19 (13 bits)
static const UINT64 PIXEventsBlockEndMarker = 0x00000000000FFF80;
//Bits 10-19 (10 bits)
static const UINT64 PIXEventsTypeReadMask = 0x00000000000FFC00;
static const UINT64 PIXEventsTypeWriteMask = 0x00000000000003FF;
static const UINT64 PIXEventsTypeBitShift = 10;
//Bits 20-63 (44 bits)
static const UINT64 PIXEventsTimestampReadMask = 0xFFFFFFFFFFF00000;
static const UINT64 PIXEventsTimestampWriteMask = 0x00000FFFFFFFFFFF;
static const UINT64 PIXEventsTimestampBitShift = 20;
inline UINT64 PIXEncodeEventInfo(UINT64 timestamp, PIXEventType eventType)
{
return ((timestamp & PIXEventsTimestampWriteMask) << PIXEventsTimestampBitShift) |
(((UINT64)eventType & PIXEventsTypeWriteMask) << PIXEventsTypeBitShift);
}
//Bits 60-63 (4)
static const UINT64 PIXEventsStringAlignmentWriteMask = 0x000000000000000F;
static const UINT64 PIXEventsStringAlignmentReadMask = 0xF000000000000000;
static const UINT64 PIXEventsStringAlignmentBitShift = 60;
//Bits 55-59 (5)
static const UINT64 PIXEventsStringCopyChunkSizeWriteMask = 0x000000000000001F;
static const UINT64 PIXEventsStringCopyChunkSizeReadMask = 0x0F80000000000000;
static const UINT64 PIXEventsStringCopyChunkSizeBitShift = 55;
//Bit 54
static const UINT64 PIXEventsStringIsANSIWriteMask = 0x0000000000000001;
static const UINT64 PIXEventsStringIsANSIReadMask = 0x0040000000000000;
static const UINT64 PIXEventsStringIsANSIBitShift = 54;
//Bit 53
static const UINT64 PIXEventsStringIsShortcutWriteMask = 0x0000000000000001;
static const UINT64 PIXEventsStringIsShortcutReadMask = 0x0020000000000000;
static const UINT64 PIXEventsStringIsShortcutBitShift = 53;
inline UINT64 PIXEncodeStringInfo(UINT64 alignment, UINT64 copyChunkSize, BOOL isANSI, BOOL isShortcut)
{
return ((alignment & PIXEventsStringAlignmentWriteMask) << PIXEventsStringAlignmentBitShift) |
((copyChunkSize & PIXEventsStringCopyChunkSizeWriteMask) << PIXEventsStringCopyChunkSizeBitShift) |
(((UINT64)isANSI & PIXEventsStringIsANSIWriteMask) << PIXEventsStringIsANSIBitShift) |
(((UINT64)isShortcut & PIXEventsStringIsShortcutWriteMask) << PIXEventsStringIsShortcutBitShift);
}
template<UINT alignment, class T>
inline bool PIXIsPointerAligned(T* pointer)
{
return !(((UINT64)pointer) & (alignment - 1));
}
template<class T>
inline void PIXCopyEventArgument(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, T argument)
{
if (destination < limit)
{
*((T*)destination) = argument;
++destination;
}
}
//floats must be cast to double during writing the data to be properly printed later when reading the data
//this is needed because when float is passed to varargs function it's cast to double
template<>
inline void PIXCopyEventArgument<float>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, float argument)
{
if (destination < limit)
{
*((double*)destination) = (double)(argument);
++destination;
}
}
//char has to be cast to a longer signed integer type
//this is due to printf not ignoring correctly the upper bits of unsigned long long for a char format specifier
template<>
inline void PIXCopyEventArgument<char>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, char argument)
{
if (destination < limit)
{
*((INT64*)destination) = (INT64)(argument);
++destination;
}
}
//unsigned char has to be cast to a longer unsigned integer type
//this is due to printf not ignoring correctly the upper bits of unsigned long long for a char format specifier
template<>
inline void PIXCopyEventArgument<unsigned char>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, unsigned char argument)
{
if (destination < limit)
{
*destination = (UINT64)(argument);
++destination;
}
}
//bool has to be cast to an integer since it's not explicitly supported by string format routines
//there's no format specifier for bool type, but it should work with integer format specifiers
template<>
inline void PIXCopyEventArgument<bool>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, bool argument)
{
if (destination < limit)
{
*destination = (UINT64)(argument);
++destination;
}
}
inline void PIXCopyEventArgumentSlowest(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCSTR argument)
{
*destination++ = PIXEncodeStringInfo(0, 8, TRUE, FALSE);
while (destination < limit)
{
UINT64 c = argument[0];
if (!c)
{
*destination++ = 0;
return;
}
UINT64 x = c;
c = argument[1];
if (!c)
{
*destination++ = x;
return;
}
x |= c << 8;
c = argument[2];
if (!c)
{
*destination++ = x;
return;
}
x |= c << 16;
c = argument[3];
if (!c)
{
*destination++ = x;
return;
}
x |= c << 24;
c = argument[4];
if (!c)
{
*destination++ = x;
return;
}
x |= c << 32;
c = argument[5];
if (!c)
{
*destination++ = x;
return;
}
x |= c << 40;
c = argument[6];
if (!c)
{
*destination++ = x;
return;
}
x |= c << 48;
c = argument[7];
if (!c)
{
*destination++ = x;
return;
}
x |= c << 56;
*destination++ = x;
argument += 8;
}
}
inline void PIXCopyEventArgumentSlow(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCSTR argument)
{
if (PIXIsPointerAligned<8>(argument))
{
*destination++ = PIXEncodeStringInfo(0, 8, TRUE, FALSE);
UINT64* source = (UINT64*)argument;
while (destination < limit)
{
UINT64 qword = *source++;
*destination++ = qword;
//check if any of the characters is a terminating zero
if (!((qword & 0xFF00000000000000) &&
(qword & 0xFF000000000000) &&
(qword & 0xFF0000000000) &&
(qword & 0xFF00000000) &&
(qword & 0xFF000000) &&
(qword & 0xFF0000) &&
(qword & 0xFF00) &&
(qword & 0xFF)))
{
break;
}
}
}
else
{
PIXCopyEventArgumentSlowest(destination, limit, argument);
}
}
template<>
inline void PIXCopyEventArgument<PCSTR>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCSTR argument)
{
if (destination < limit)
{
if (argument != nullptr)
{
#if defined(_AMD64_) || defined(_X86_)
if (PIXIsPointerAligned<16>(argument))
{
*destination++ = PIXEncodeStringInfo(0, 16, TRUE, FALSE);
__m128i zero = _mm_setzero_si128();
if (PIXIsPointerAligned<16>(destination))
{
while (destination < limit)
{
__m128i mem = _mm_load_si128((__m128i*)argument);
_mm_store_si128((__m128i*)destination, mem);
//check if any of the characters is a terminating zero
__m128i res = _mm_cmpeq_epi8(mem, zero);
destination += 2;
if (_mm_movemask_epi8(res))
break;
argument += 16;
}
}
else
{
while (destination < limit)
{
__m128i mem = _mm_load_si128((__m128i*)argument);
_mm_storeu_si128((__m128i*)destination, mem);
//check if any of the characters is a terminating zero
__m128i res = _mm_cmpeq_epi8(mem, zero);
destination += 2;
if (_mm_movemask_epi8(res))
break;
argument += 16;
}
}
}
else
#endif // _AMD64_ || _X86_
{
PIXCopyEventArgumentSlow(destination, limit, argument);
}
}
else
{
*destination++ = 0ull;
}
}
}
template<>
inline void PIXCopyEventArgument<PSTR>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PSTR argument)
{
PIXCopyEventArgument(destination, limit, (PCSTR)argument);
}
inline void PIXCopyEventArgumentSlowest(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCWSTR argument)
{
*destination++ = PIXEncodeStringInfo(0, 8, FALSE, FALSE);
while (destination < limit)
{
UINT64 c = argument[0];
if (!c)
{
*destination++ = 0;
return;
}
UINT64 x = c;
c = argument[1];
if (!c)
{
*destination++ = x;
return;
}
x |= c << 16;
c = argument[2];
if (!c)
{
*destination++ = x;
return;
}
x |= c << 32;
c = argument[3];
if (!c)
{
*destination++ = x;
return;
}
x |= c << 48;
*destination++ = x;
argument += 4;
}
}
inline void PIXCopyEventArgumentSlow(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCWSTR argument)
{
if (PIXIsPointerAligned<8>(argument))
{
*destination++ = PIXEncodeStringInfo(0, 8, FALSE, FALSE);
UINT64* source = (UINT64*)argument;
while (destination < limit)
{
UINT64 qword = *source++;
*destination++ = qword;
//check if any of the characters is a terminating zero
//TODO: check if reversed condition is faster
if (!((qword & 0xFFFF000000000000) &&
(qword & 0xFFFF00000000) &&
(qword & 0xFFFF0000) &&
(qword & 0xFFFF)))
{
break;
}
}
}
else
{
PIXCopyEventArgumentSlowest(destination, limit, argument);
}
}
template<>
inline void PIXCopyEventArgument<PCWSTR>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PCWSTR argument)
{
if (destination < limit)
{
if (argument != nullptr)
{
#if defined(_AMD64_) || defined(_X86_)
if (PIXIsPointerAligned<16>(argument))
{
*destination++ = PIXEncodeStringInfo(0, 16, FALSE, FALSE);
__m128i zero = _mm_setzero_si128();
if (PIXIsPointerAligned<16>(destination))
{
while (destination < limit)
{
__m128i mem = _mm_load_si128((__m128i*)argument);
_mm_store_si128((__m128i*)destination, mem);
//check if any of the characters is a terminating zero
__m128i res = _mm_cmpeq_epi16(mem, zero);
destination += 2;
if (_mm_movemask_epi8(res))
break;
argument += 8;
}
}
else
{
while (destination < limit)
{
__m128i mem = _mm_load_si128((__m128i*)argument);
_mm_storeu_si128((__m128i*)destination, mem);
//check if any of the characters is a terminating zero
__m128i res = _mm_cmpeq_epi16(mem, zero);
destination += 2;
if (_mm_movemask_epi8(res))
break;
argument += 8;
}
}
}
else
#endif // _AMD64_ || _X86_
{
PIXCopyEventArgumentSlow(destination, limit, argument);
}
}
else
{
*destination++ = 0ull;
}
}
}
template<>
inline void PIXCopyEventArgument<PWSTR>(_Out_writes_to_ptr_(limit) UINT64*& destination, _In_ const UINT64* limit, _In_ PWSTR argument)
{
PIXCopyEventArgument(destination, limit, (PCWSTR)argument);
};
#if defined(__d3d12_x_h__) || defined(__d3d12_h__)
inline void PIXSetMarkerOnContext(_In_ ID3D12GraphicsCommandList* commandList, _In_reads_bytes_(size) void* data, UINT size)
{
commandList->SetMarker(D3D12_EVENT_METADATA, data, size);
}
inline void PIXSetMarkerOnContext(_In_ ID3D12CommandQueue* commandQueue, _In_reads_bytes_(size) void* data, UINT size)
{
commandQueue->SetMarker(D3D12_EVENT_METADATA, data, size);
}
inline void PIXBeginEventOnContext(_In_ ID3D12GraphicsCommandList* commandList, _In_reads_bytes_(size) void* data, UINT size)
{
commandList->BeginEvent(D3D12_EVENT_METADATA, data, size);
}
inline void PIXBeginEventOnContext(_In_ ID3D12CommandQueue* commandQueue, _In_reads_bytes_(size) void* data, UINT size)
{
commandQueue->BeginEvent(D3D12_EVENT_METADATA, data, size);
}
inline void PIXEndEventOnContext(_In_ ID3D12GraphicsCommandList* commandList)
{
commandList->EndEvent();
}
inline void PIXEndEventOnContext(_In_ ID3D12CommandQueue* commandQueue)
{
commandQueue->EndEvent();
}
#endif //__d3d12_x_h__
template<class T> struct PIXInferScopedEventType { typedef T Type; };
template<class T> struct PIXInferScopedEventType<const T> { typedef T Type; };
template<class T> struct PIXInferScopedEventType<T*> { typedef T Type; };
template<class T> struct PIXInferScopedEventType<T* const> { typedef T Type; };
template<> struct PIXInferScopedEventType<UINT64> { typedef void Type; };
template<> struct PIXInferScopedEventType<const UINT64> { typedef void Type; };
template<> struct PIXInferScopedEventType<INT64> { typedef void Type; };
template<> struct PIXInferScopedEventType<const INT64> { typedef void Type; };
template<> struct PIXInferScopedEventType<UINT> { typedef void Type; };
template<> struct PIXInferScopedEventType<const UINT> { typedef void Type; };
template<> struct PIXInferScopedEventType<INT> { typedef void Type; };
template<> struct PIXInferScopedEventType<const INT> { typedef void Type; };
#endif //_PIXEventsCommon_H_

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,601 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// File: D3D11Shader.h
// Content: D3D11 Shader Types and APIs
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __D3D11SHADER_H__
#define __D3D11SHADER_H__
#include "d3dcommon.h"
typedef enum D3D11_SHADER_VERSION_TYPE
{
D3D11_SHVER_PIXEL_SHADER = 0,
D3D11_SHVER_VERTEX_SHADER = 1,
D3D11_SHVER_GEOMETRY_SHADER = 2,
// D3D11 Shaders
D3D11_SHVER_HULL_SHADER = 3,
D3D11_SHVER_DOMAIN_SHADER = 4,
D3D11_SHVER_COMPUTE_SHADER = 5,
D3D11_SHVER_RESERVED0 = 0xFFF0,
} D3D11_SHADER_VERSION_TYPE;
#define D3D11_SHVER_GET_TYPE(_Version) \
(((_Version) >> 16) & 0xffff)
#define D3D11_SHVER_GET_MAJOR(_Version) \
(((_Version) >> 4) & 0xf)
#define D3D11_SHVER_GET_MINOR(_Version) \
(((_Version) >> 0) & 0xf)
// Slot ID for library function return
#define D3D_RETURN_PARAMETER_INDEX (-1)
typedef D3D_RESOURCE_RETURN_TYPE D3D11_RESOURCE_RETURN_TYPE;
typedef D3D_CBUFFER_TYPE D3D11_CBUFFER_TYPE;
typedef struct _D3D11_SIGNATURE_PARAMETER_DESC
{
LPCSTR SemanticName; // Name of the semantic
UINT SemanticIndex; // Index of the semantic
UINT Register; // Number of member variables
D3D_NAME SystemValueType;// A predefined system value, or D3D_NAME_UNDEFINED if not applicable
D3D_REGISTER_COMPONENT_TYPE ComponentType; // Scalar type (e.g. uint, float, etc.)
BYTE Mask; // Mask to indicate which components of the register
// are used (combination of D3D10_COMPONENT_MASK values)
BYTE ReadWriteMask; // Mask to indicate whether a given component is
// never written (if this is an output signature) or
// always read (if this is an input signature).
// (combination of D3D_MASK_* values)
UINT Stream; // Stream index
D3D_MIN_PRECISION MinPrecision; // Minimum desired interpolation precision
} D3D11_SIGNATURE_PARAMETER_DESC;
typedef struct _D3D11_SHADER_BUFFER_DESC
{
LPCSTR Name; // Name of the constant buffer
D3D_CBUFFER_TYPE Type; // Indicates type of buffer content
UINT Variables; // Number of member variables
UINT Size; // Size of CB (in bytes)
UINT uFlags; // Buffer description flags
} D3D11_SHADER_BUFFER_DESC;
typedef struct _D3D11_SHADER_VARIABLE_DESC
{
LPCSTR Name; // Name of the variable
UINT StartOffset; // Offset in constant buffer's backing store
UINT Size; // Size of variable (in bytes)
UINT uFlags; // Variable flags
LPVOID DefaultValue; // Raw pointer to default value
UINT StartTexture; // First texture index (or -1 if no textures used)
UINT TextureSize; // Number of texture slots possibly used.
UINT StartSampler; // First sampler index (or -1 if no textures used)
UINT SamplerSize; // Number of sampler slots possibly used.
} D3D11_SHADER_VARIABLE_DESC;
typedef struct _D3D11_SHADER_TYPE_DESC
{
D3D_SHADER_VARIABLE_CLASS Class; // Variable class (e.g. object, matrix, etc.)
D3D_SHADER_VARIABLE_TYPE Type; // Variable type (e.g. float, sampler, etc.)
UINT Rows; // Number of rows (for matrices, 1 for other numeric, 0 if not applicable)
UINT Columns; // Number of columns (for vectors & matrices, 1 for other numeric, 0 if not applicable)
UINT Elements; // Number of elements (0 if not an array)
UINT Members; // Number of members (0 if not a structure)
UINT Offset; // Offset from the start of structure (0 if not a structure member)
LPCSTR Name; // Name of type, can be NULL
} D3D11_SHADER_TYPE_DESC;
typedef D3D_TESSELLATOR_DOMAIN D3D11_TESSELLATOR_DOMAIN;
typedef D3D_TESSELLATOR_PARTITIONING D3D11_TESSELLATOR_PARTITIONING;
typedef D3D_TESSELLATOR_OUTPUT_PRIMITIVE D3D11_TESSELLATOR_OUTPUT_PRIMITIVE;
typedef struct _D3D11_SHADER_DESC
{
UINT Version; // Shader version
LPCSTR Creator; // Creator string
UINT Flags; // Shader compilation/parse flags
UINT ConstantBuffers; // Number of constant buffers
UINT BoundResources; // Number of bound resources
UINT InputParameters; // Number of parameters in the input signature
UINT OutputParameters; // Number of parameters in the output signature
UINT InstructionCount; // Number of emitted instructions
UINT TempRegisterCount; // Number of temporary registers used
UINT TempArrayCount; // Number of temporary arrays used
UINT DefCount; // Number of constant defines
UINT DclCount; // Number of declarations (input + output)
UINT TextureNormalInstructions; // Number of non-categorized texture instructions
UINT TextureLoadInstructions; // Number of texture load instructions
UINT TextureCompInstructions; // Number of texture comparison instructions
UINT TextureBiasInstructions; // Number of texture bias instructions
UINT TextureGradientInstructions; // Number of texture gradient instructions
UINT FloatInstructionCount; // Number of floating point arithmetic instructions used
UINT IntInstructionCount; // Number of signed integer arithmetic instructions used
UINT UintInstructionCount; // Number of unsigned integer arithmetic instructions used
UINT StaticFlowControlCount; // Number of static flow control instructions used
UINT DynamicFlowControlCount; // Number of dynamic flow control instructions used
UINT MacroInstructionCount; // Number of macro instructions used
UINT ArrayInstructionCount; // Number of array instructions used
UINT CutInstructionCount; // Number of cut instructions used
UINT EmitInstructionCount; // Number of emit instructions used
D3D_PRIMITIVE_TOPOLOGY GSOutputTopology; // Geometry shader output topology
UINT GSMaxOutputVertexCount; // Geometry shader maximum output vertex count
D3D_PRIMITIVE InputPrimitive; // GS/HS input primitive
UINT PatchConstantParameters; // Number of parameters in the patch constant signature
UINT cGSInstanceCount; // Number of Geometry shader instances
UINT cControlPoints; // Number of control points in the HS->DS stage
D3D_TESSELLATOR_OUTPUT_PRIMITIVE HSOutputPrimitive; // Primitive output by the tessellator
D3D_TESSELLATOR_PARTITIONING HSPartitioning; // Partitioning mode of the tessellator
D3D_TESSELLATOR_DOMAIN TessellatorDomain; // Domain of the tessellator (quad, tri, isoline)
// instruction counts
UINT cBarrierInstructions; // Number of barrier instructions in a compute shader
UINT cInterlockedInstructions; // Number of interlocked instructions
UINT cTextureStoreInstructions; // Number of texture writes
} D3D11_SHADER_DESC;
typedef struct _D3D11_SHADER_INPUT_BIND_DESC
{
LPCSTR Name; // Name of the resource
D3D_SHADER_INPUT_TYPE Type; // Type of resource (e.g. texture, cbuffer, etc.)
UINT BindPoint; // Starting bind point
UINT BindCount; // Number of contiguous bind points (for arrays)
UINT uFlags; // Input binding flags
D3D_RESOURCE_RETURN_TYPE ReturnType; // Return type (if texture)
D3D_SRV_DIMENSION Dimension; // Dimension (if texture)
UINT NumSamples; // Number of samples (0 if not MS texture)
} D3D11_SHADER_INPUT_BIND_DESC;
#define D3D_SHADER_REQUIRES_DOUBLES 0x00000001
#define D3D_SHADER_REQUIRES_EARLY_DEPTH_STENCIL 0x00000002
#define D3D_SHADER_REQUIRES_UAVS_AT_EVERY_STAGE 0x00000004
#define D3D_SHADER_REQUIRES_64_UAVS 0x00000008
#define D3D_SHADER_REQUIRES_MINIMUM_PRECISION 0x00000010
#define D3D_SHADER_REQUIRES_11_1_DOUBLE_EXTENSIONS 0x00000020
#define D3D_SHADER_REQUIRES_11_1_SHADER_EXTENSIONS 0x00000040
#define D3D_SHADER_REQUIRES_LEVEL_9_COMPARISON_FILTERING 0x00000080
#define D3D_SHADER_REQUIRES_TILED_RESOURCES 0x00000100
typedef struct _D3D11_LIBRARY_DESC
{
LPCSTR Creator; // The name of the originator of the library.
UINT Flags; // Compilation flags.
UINT FunctionCount; // Number of functions exported from the library.
} D3D11_LIBRARY_DESC;
typedef struct _D3D11_FUNCTION_DESC
{
UINT Version; // Shader version
LPCSTR Creator; // Creator string
UINT Flags; // Shader compilation/parse flags
UINT ConstantBuffers; // Number of constant buffers
UINT BoundResources; // Number of bound resources
UINT InstructionCount; // Number of emitted instructions
UINT TempRegisterCount; // Number of temporary registers used
UINT TempArrayCount; // Number of temporary arrays used
UINT DefCount; // Number of constant defines
UINT DclCount; // Number of declarations (input + output)
UINT TextureNormalInstructions; // Number of non-categorized texture instructions
UINT TextureLoadInstructions; // Number of texture load instructions
UINT TextureCompInstructions; // Number of texture comparison instructions
UINT TextureBiasInstructions; // Number of texture bias instructions
UINT TextureGradientInstructions; // Number of texture gradient instructions
UINT FloatInstructionCount; // Number of floating point arithmetic instructions used
UINT IntInstructionCount; // Number of signed integer arithmetic instructions used
UINT UintInstructionCount; // Number of unsigned integer arithmetic instructions used
UINT StaticFlowControlCount; // Number of static flow control instructions used
UINT DynamicFlowControlCount; // Number of dynamic flow control instructions used
UINT MacroInstructionCount; // Number of macro instructions used
UINT ArrayInstructionCount; // Number of array instructions used
UINT MovInstructionCount; // Number of mov instructions used
UINT MovcInstructionCount; // Number of movc instructions used
UINT ConversionInstructionCount; // Number of type conversion instructions used
UINT BitwiseInstructionCount; // Number of bitwise arithmetic instructions used
D3D_FEATURE_LEVEL MinFeatureLevel; // Min target of the function byte code
UINT64 RequiredFeatureFlags; // Required feature flags
LPCSTR Name; // Function name
INT FunctionParameterCount; // Number of logical parameters in the function signature (not including return)
BOOL HasReturn; // TRUE, if function returns a value, false - it is a subroutine
BOOL Has10Level9VertexShader; // TRUE, if there is a 10L9 VS blob
BOOL Has10Level9PixelShader; // TRUE, if there is a 10L9 PS blob
} D3D11_FUNCTION_DESC;
typedef struct _D3D11_PARAMETER_DESC
{
LPCSTR Name; // Parameter name.
LPCSTR SemanticName; // Parameter semantic name (+index).
D3D_SHADER_VARIABLE_TYPE Type; // Element type.
D3D_SHADER_VARIABLE_CLASS Class; // Scalar/Vector/Matrix.
UINT Rows; // Rows are for matrix parameters.
UINT Columns; // Components or Columns in matrix.
D3D_INTERPOLATION_MODE InterpolationMode; // Interpolation mode.
D3D_PARAMETER_FLAGS Flags; // Parameter modifiers.
UINT FirstInRegister; // The first input register for this parameter.
UINT FirstInComponent; // The first input register component for this parameter.
UINT FirstOutRegister; // The first output register for this parameter.
UINT FirstOutComponent; // The first output register component for this parameter.
} D3D11_PARAMETER_DESC;
//////////////////////////////////////////////////////////////////////////////
// Interfaces ////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
typedef interface ID3D11ShaderReflectionType ID3D11ShaderReflectionType;
typedef interface ID3D11ShaderReflectionType *LPD3D11SHADERREFLECTIONTYPE;
typedef interface ID3D11ShaderReflectionVariable ID3D11ShaderReflectionVariable;
typedef interface ID3D11ShaderReflectionVariable *LPD3D11SHADERREFLECTIONVARIABLE;
typedef interface ID3D11ShaderReflectionConstantBuffer ID3D11ShaderReflectionConstantBuffer;
typedef interface ID3D11ShaderReflectionConstantBuffer *LPD3D11SHADERREFLECTIONCONSTANTBUFFER;
typedef interface ID3D11ShaderReflection ID3D11ShaderReflection;
typedef interface ID3D11ShaderReflection *LPD3D11SHADERREFLECTION;
typedef interface ID3D11LibraryReflection ID3D11LibraryReflection;
typedef interface ID3D11LibraryReflection *LPD3D11LIBRARYREFLECTION;
typedef interface ID3D11FunctionReflection ID3D11FunctionReflection;
typedef interface ID3D11FunctionReflection *LPD3D11FUNCTIONREFLECTION;
typedef interface ID3D11FunctionParameterReflection ID3D11FunctionParameterReflection;
typedef interface ID3D11FunctionParameterReflection *LPD3D11FUNCTIONPARAMETERREFLECTION;
// {6E6FFA6A-9BAE-4613-A51E-91652D508C21}
interface DECLSPEC_UUID("6E6FFA6A-9BAE-4613-A51E-91652D508C21") ID3D11ShaderReflectionType;
DEFINE_GUID(IID_ID3D11ShaderReflectionType,
0x6e6ffa6a, 0x9bae, 0x4613, 0xa5, 0x1e, 0x91, 0x65, 0x2d, 0x50, 0x8c, 0x21);
#undef INTERFACE
#define INTERFACE ID3D11ShaderReflectionType
DECLARE_INTERFACE(ID3D11ShaderReflectionType)
{
STDMETHOD(GetDesc)(THIS_ _Out_ D3D11_SHADER_TYPE_DESC *pDesc) PURE;
STDMETHOD_(ID3D11ShaderReflectionType*, GetMemberTypeByIndex)(THIS_ _In_ UINT Index) PURE;
STDMETHOD_(ID3D11ShaderReflectionType*, GetMemberTypeByName)(THIS_ _In_ LPCSTR Name) PURE;
STDMETHOD_(LPCSTR, GetMemberTypeName)(THIS_ _In_ UINT Index) PURE;
STDMETHOD(IsEqual)(THIS_ _In_ ID3D11ShaderReflectionType* pType) PURE;
STDMETHOD_(ID3D11ShaderReflectionType*, GetSubType)(THIS) PURE;
STDMETHOD_(ID3D11ShaderReflectionType*, GetBaseClass)(THIS) PURE;
STDMETHOD_(UINT, GetNumInterfaces)(THIS) PURE;
STDMETHOD_(ID3D11ShaderReflectionType*, GetInterfaceByIndex)(THIS_ _In_ UINT uIndex) PURE;
STDMETHOD(IsOfType)(THIS_ _In_ ID3D11ShaderReflectionType* pType) PURE;
STDMETHOD(ImplementsInterface)(THIS_ _In_ ID3D11ShaderReflectionType* pBase) PURE;
};
// {51F23923-F3E5-4BD1-91CB-606177D8DB4C}
interface DECLSPEC_UUID("51F23923-F3E5-4BD1-91CB-606177D8DB4C") ID3D11ShaderReflectionVariable;
DEFINE_GUID(IID_ID3D11ShaderReflectionVariable,
0x51f23923, 0xf3e5, 0x4bd1, 0x91, 0xcb, 0x60, 0x61, 0x77, 0xd8, 0xdb, 0x4c);
#undef INTERFACE
#define INTERFACE ID3D11ShaderReflectionVariable
DECLARE_INTERFACE(ID3D11ShaderReflectionVariable)
{
STDMETHOD(GetDesc)(THIS_ _Out_ D3D11_SHADER_VARIABLE_DESC *pDesc) PURE;
STDMETHOD_(ID3D11ShaderReflectionType*, GetType)(THIS) PURE;
STDMETHOD_(ID3D11ShaderReflectionConstantBuffer*, GetBuffer)(THIS) PURE;
STDMETHOD_(UINT, GetInterfaceSlot)(THIS_ _In_ UINT uArrayIndex) PURE;
};
// {EB62D63D-93DD-4318-8AE8-C6F83AD371B8}
interface DECLSPEC_UUID("EB62D63D-93DD-4318-8AE8-C6F83AD371B8") ID3D11ShaderReflectionConstantBuffer;
DEFINE_GUID(IID_ID3D11ShaderReflectionConstantBuffer,
0xeb62d63d, 0x93dd, 0x4318, 0x8a, 0xe8, 0xc6, 0xf8, 0x3a, 0xd3, 0x71, 0xb8);
#undef INTERFACE
#define INTERFACE ID3D11ShaderReflectionConstantBuffer
DECLARE_INTERFACE(ID3D11ShaderReflectionConstantBuffer)
{
STDMETHOD(GetDesc)(THIS_ D3D11_SHADER_BUFFER_DESC *pDesc) PURE;
STDMETHOD_(ID3D11ShaderReflectionVariable*, GetVariableByIndex)(THIS_ _In_ UINT Index) PURE;
STDMETHOD_(ID3D11ShaderReflectionVariable*, GetVariableByName)(THIS_ _In_ LPCSTR Name) PURE;
};
// The ID3D11ShaderReflection IID may change from SDK version to SDK version
// if the reflection API changes. This prevents new code with the new API
// from working with an old binary. Recompiling with the new header
// will pick up the new IID.
// 8d536ca1-0cca-4956-a837-786963755584
interface DECLSPEC_UUID("8d536ca1-0cca-4956-a837-786963755584") ID3D11ShaderReflection;
DEFINE_GUID(IID_ID3D11ShaderReflection,
0x8d536ca1, 0x0cca, 0x4956, 0xa8, 0x37, 0x78, 0x69, 0x63, 0x75, 0x55, 0x84);
#undef INTERFACE
#define INTERFACE ID3D11ShaderReflection
DECLARE_INTERFACE_(ID3D11ShaderReflection, IUnknown)
{
STDMETHOD(QueryInterface)(THIS_ _In_ REFIID iid,
_Out_ LPVOID *ppv) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
STDMETHOD(GetDesc)(THIS_ _Out_ D3D11_SHADER_DESC *pDesc) PURE;
STDMETHOD_(ID3D11ShaderReflectionConstantBuffer*, GetConstantBufferByIndex)(THIS_ _In_ UINT Index) PURE;
STDMETHOD_(ID3D11ShaderReflectionConstantBuffer*, GetConstantBufferByName)(THIS_ _In_ LPCSTR Name) PURE;
STDMETHOD(GetResourceBindingDesc)(THIS_ _In_ UINT ResourceIndex,
_Out_ D3D11_SHADER_INPUT_BIND_DESC *pDesc) PURE;
STDMETHOD(GetInputParameterDesc)(THIS_ _In_ UINT ParameterIndex,
_Out_ D3D11_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
STDMETHOD(GetOutputParameterDesc)(THIS_ _In_ UINT ParameterIndex,
_Out_ D3D11_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
STDMETHOD(GetPatchConstantParameterDesc)(THIS_ _In_ UINT ParameterIndex,
_Out_ D3D11_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
STDMETHOD_(ID3D11ShaderReflectionVariable*, GetVariableByName)(THIS_ _In_ LPCSTR Name) PURE;
STDMETHOD(GetResourceBindingDescByName)(THIS_ _In_ LPCSTR Name,
_Out_ D3D11_SHADER_INPUT_BIND_DESC *pDesc) PURE;
STDMETHOD_(UINT, GetMovInstructionCount)(THIS) PURE;
STDMETHOD_(UINT, GetMovcInstructionCount)(THIS) PURE;
STDMETHOD_(UINT, GetConversionInstructionCount)(THIS) PURE;
STDMETHOD_(UINT, GetBitwiseInstructionCount)(THIS) PURE;
STDMETHOD_(D3D_PRIMITIVE, GetGSInputPrimitive)(THIS) PURE;
STDMETHOD_(BOOL, IsSampleFrequencyShader)(THIS) PURE;
STDMETHOD_(UINT, GetNumInterfaceSlots)(THIS) PURE;
STDMETHOD(GetMinFeatureLevel)(THIS_ _Out_ enum D3D_FEATURE_LEVEL* pLevel) PURE;
STDMETHOD_(UINT, GetThreadGroupSize)(THIS_
_Out_opt_ UINT* pSizeX,
_Out_opt_ UINT* pSizeY,
_Out_opt_ UINT* pSizeZ) PURE;
STDMETHOD_(UINT64, GetRequiresFlags)(THIS) PURE;
};
// {54384F1B-5B3E-4BB7-AE01-60BA3097CBB6}
interface DECLSPEC_UUID("54384F1B-5B3E-4BB7-AE01-60BA3097CBB6") ID3D11LibraryReflection;
DEFINE_GUID(IID_ID3D11LibraryReflection,
0x54384f1b, 0x5b3e, 0x4bb7, 0xae, 0x1, 0x60, 0xba, 0x30, 0x97, 0xcb, 0xb6);
#undef INTERFACE
#define INTERFACE ID3D11LibraryReflection
DECLARE_INTERFACE_(ID3D11LibraryReflection, IUnknown)
{
STDMETHOD(QueryInterface)(THIS_ _In_ REFIID iid, _Out_ LPVOID * ppv) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
STDMETHOD(GetDesc)(THIS_ _Out_ D3D11_LIBRARY_DESC * pDesc) PURE;
STDMETHOD_(ID3D11FunctionReflection *, GetFunctionByIndex)(THIS_ _In_ INT FunctionIndex) PURE;
};
// {207BCECB-D683-4A06-A8A3-9B149B9F73A4}
interface DECLSPEC_UUID("207BCECB-D683-4A06-A8A3-9B149B9F73A4") ID3D11FunctionReflection;
DEFINE_GUID(IID_ID3D11FunctionReflection,
0x207bcecb, 0xd683, 0x4a06, 0xa8, 0xa3, 0x9b, 0x14, 0x9b, 0x9f, 0x73, 0xa4);
#undef INTERFACE
#define INTERFACE ID3D11FunctionReflection
DECLARE_INTERFACE(ID3D11FunctionReflection)
{
STDMETHOD(GetDesc)(THIS_ _Out_ D3D11_FUNCTION_DESC * pDesc) PURE;
STDMETHOD_(ID3D11ShaderReflectionConstantBuffer *, GetConstantBufferByIndex)(THIS_ _In_ UINT BufferIndex) PURE;
STDMETHOD_(ID3D11ShaderReflectionConstantBuffer *, GetConstantBufferByName)(THIS_ _In_ LPCSTR Name) PURE;
STDMETHOD(GetResourceBindingDesc)(THIS_ _In_ UINT ResourceIndex,
_Out_ D3D11_SHADER_INPUT_BIND_DESC * pDesc) PURE;
STDMETHOD_(ID3D11ShaderReflectionVariable *, GetVariableByName)(THIS_ _In_ LPCSTR Name) PURE;
STDMETHOD(GetResourceBindingDescByName)(THIS_ _In_ LPCSTR Name,
_Out_ D3D11_SHADER_INPUT_BIND_DESC * pDesc) PURE;
// Use D3D_RETURN_PARAMETER_INDEX to get description of the return value.
STDMETHOD_(ID3D11FunctionParameterReflection *, GetFunctionParameter)(THIS_ _In_ INT ParameterIndex) PURE;
};
// {42757488-334F-47FE-982E-1A65D08CC462}
interface DECLSPEC_UUID("42757488-334F-47FE-982E-1A65D08CC462") ID3D11FunctionParameterReflection;
DEFINE_GUID(IID_ID3D11FunctionParameterReflection,
0x42757488, 0x334f, 0x47fe, 0x98, 0x2e, 0x1a, 0x65, 0xd0, 0x8c, 0xc4, 0x62);
#undef INTERFACE
#define INTERFACE ID3D11FunctionParameterReflection
DECLARE_INTERFACE(ID3D11FunctionParameterReflection)
{
STDMETHOD(GetDesc)(THIS_ _Out_ D3D11_PARAMETER_DESC * pDesc) PURE;
};
// {CAC701EE-80FC-4122-8242-10B39C8CEC34}
interface DECLSPEC_UUID("CAC701EE-80FC-4122-8242-10B39C8CEC34") ID3D11Module;
DEFINE_GUID(IID_ID3D11Module,
0xcac701ee, 0x80fc, 0x4122, 0x82, 0x42, 0x10, 0xb3, 0x9c, 0x8c, 0xec, 0x34);
#undef INTERFACE
#define INTERFACE ID3D11Module
DECLARE_INTERFACE_(ID3D11Module, IUnknown)
{
STDMETHOD(QueryInterface)(THIS_ _In_ REFIID iid, _Out_ LPVOID * ppv) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
// Create an instance of a module for resource re-binding.
STDMETHOD(CreateInstance)(THIS_ _In_opt_ LPCSTR pNamespace,
_COM_Outptr_ interface ID3D11ModuleInstance ** ppModuleInstance) PURE;
};
// {469E07F7-045A-48D5-AA12-68A478CDF75D}
interface DECLSPEC_UUID("469E07F7-045A-48D5-AA12-68A478CDF75D") ID3D11ModuleInstance;
DEFINE_GUID(IID_ID3D11ModuleInstance,
0x469e07f7, 0x45a, 0x48d5, 0xaa, 0x12, 0x68, 0xa4, 0x78, 0xcd, 0xf7, 0x5d);
#undef INTERFACE
#define INTERFACE ID3D11ModuleInstance
DECLARE_INTERFACE_(ID3D11ModuleInstance, IUnknown)
{
STDMETHOD(QueryInterface)(THIS_ _In_ REFIID iid, _Out_ LPVOID * ppv) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
//
// Resource binding API.
//
STDMETHOD(BindConstantBuffer)(THIS_ _In_ UINT uSrcSlot, _In_ UINT uDstSlot, _In_ UINT cbDstOffset) PURE;
STDMETHOD(BindConstantBufferByName)(THIS_ _In_ LPCSTR pName, _In_ UINT uDstSlot, _In_ UINT cbDstOffset) PURE;
STDMETHOD(BindResource)(THIS_ _In_ UINT uSrcSlot, _In_ UINT uDstSlot, _In_ UINT uCount) PURE;
STDMETHOD(BindResourceByName)(THIS_ _In_ LPCSTR pName, _In_ UINT uDstSlot, _In_ UINT uCount) PURE;
STDMETHOD(BindSampler)(THIS_ _In_ UINT uSrcSlot, _In_ UINT uDstSlot, _In_ UINT uCount) PURE;
STDMETHOD(BindSamplerByName)(THIS_ _In_ LPCSTR pName, _In_ UINT uDstSlot, _In_ UINT uCount) PURE;
STDMETHOD(BindUnorderedAccessView)(THIS_ _In_ UINT uSrcSlot, _In_ UINT uDstSlot, _In_ UINT uCount) PURE;
STDMETHOD(BindUnorderedAccessViewByName)(THIS_ _In_ LPCSTR pName, _In_ UINT uDstSlot, _In_ UINT uCount) PURE;
STDMETHOD(BindResourceAsUnorderedAccessView)(THIS_ _In_ UINT uSrcSrvSlot, _In_ UINT uDstUavSlot, _In_ UINT uCount) PURE;
STDMETHOD(BindResourceAsUnorderedAccessViewByName)(THIS_ _In_ LPCSTR pSrvName, _In_ UINT uDstUavSlot, _In_ UINT uCount) PURE;
};
// {59A6CD0E-E10D-4C1F-88C0-63ABA1DAF30E}
interface DECLSPEC_UUID("59A6CD0E-E10D-4C1F-88C0-63ABA1DAF30E") ID3D11Linker;
DEFINE_GUID(IID_ID3D11Linker,
0x59a6cd0e, 0xe10d, 0x4c1f, 0x88, 0xc0, 0x63, 0xab, 0xa1, 0xda, 0xf3, 0xe);
#undef INTERFACE
#define INTERFACE ID3D11Linker
DECLARE_INTERFACE_(ID3D11Linker, IUnknown)
{
STDMETHOD(QueryInterface)(THIS_ _In_ REFIID iid, _Out_ LPVOID * ppv) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
// Link the shader and produce a shader blob suitable to D3D runtime.
STDMETHOD(Link)(THIS_ _In_ interface ID3D11ModuleInstance * pEntry,
_In_ LPCSTR pEntryName,
_In_ LPCSTR pTargetName,
_In_ UINT uFlags,
_COM_Outptr_ ID3DBlob ** ppShaderBlob,
_Always_(_Outptr_opt_result_maybenull_) ID3DBlob ** ppErrorBuffer) PURE;
// Add an instance of a library module to be used for linking.
STDMETHOD(UseLibrary)(THIS_ _In_ interface ID3D11ModuleInstance * pLibraryMI) PURE;
// Add a clip plane with the plane coefficients taken from a cbuffer entry for 10L9 shaders.
STDMETHOD(AddClipPlaneFromCBuffer)(THIS_ _In_ UINT uCBufferSlot, _In_ UINT uCBufferEntry) PURE;
};
// {D80DD70C-8D2F-4751-94A1-03C79B3556DB}
interface DECLSPEC_UUID("D80DD70C-8D2F-4751-94A1-03C79B3556DB") ID3D11LinkingNode;
DEFINE_GUID(IID_ID3D11LinkingNode,
0xd80dd70c, 0x8d2f, 0x4751, 0x94, 0xa1, 0x3, 0xc7, 0x9b, 0x35, 0x56, 0xdb);
#undef INTERFACE
#define INTERFACE ID3D11LinkingNode
DECLARE_INTERFACE_(ID3D11LinkingNode, IUnknown)
{
STDMETHOD(QueryInterface)(THIS_ _In_ REFIID iid, _Out_ LPVOID * ppv) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
};
// {54133220-1CE8-43D3-8236-9855C5CEECFF}
interface DECLSPEC_UUID("54133220-1CE8-43D3-8236-9855C5CEECFF") ID3D11FunctionLinkingGraph;
DEFINE_GUID(IID_ID3D11FunctionLinkingGraph,
0x54133220, 0x1ce8, 0x43d3, 0x82, 0x36, 0x98, 0x55, 0xc5, 0xce, 0xec, 0xff);
#undef INTERFACE
#define INTERFACE ID3D11FunctionLinkingGraph
DECLARE_INTERFACE_(ID3D11FunctionLinkingGraph, IUnknown)
{
STDMETHOD(QueryInterface)(THIS_ _In_ REFIID iid, _Out_ LPVOID * ppv) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
// Create a shader module out of FLG description.
STDMETHOD(CreateModuleInstance)(THIS_ _COM_Outptr_ interface ID3D11ModuleInstance ** ppModuleInstance,
_Always_(_Outptr_opt_result_maybenull_) ID3DBlob ** ppErrorBuffer) PURE;
STDMETHOD(SetInputSignature)(THIS_ __in_ecount(cInputParameters) const D3D11_PARAMETER_DESC * pInputParameters,
_In_ UINT cInputParameters,
_COM_Outptr_ interface ID3D11LinkingNode ** ppInputNode) PURE;
STDMETHOD(SetOutputSignature)(THIS_ __in_ecount(cOutputParameters) const D3D11_PARAMETER_DESC * pOutputParameters,
_In_ UINT cOutputParameters,
_COM_Outptr_ interface ID3D11LinkingNode ** ppOutputNode) PURE;
STDMETHOD(CallFunction)(THIS_ _In_opt_ LPCSTR pModuleInstanceNamespace,
_In_ interface ID3D11Module * pModuleWithFunctionPrototype,
_In_ LPCSTR pFunctionName,
_COM_Outptr_ interface ID3D11LinkingNode ** ppCallNode) PURE;
STDMETHOD(PassValue)(THIS_ _In_ interface ID3D11LinkingNode * pSrcNode,
_In_ INT SrcParameterIndex,
_In_ interface ID3D11LinkingNode * pDstNode,
_In_ INT DstParameterIndex) PURE;
STDMETHOD(PassValueWithSwizzle)(THIS_ _In_ interface ID3D11LinkingNode * pSrcNode,
_In_ INT SrcParameterIndex,
_In_ LPCSTR pSrcSwizzle,
_In_ interface ID3D11LinkingNode * pDstNode,
_In_ INT DstParameterIndex,
_In_ LPCSTR pDstSwizzle) PURE;
STDMETHOD(GetLastError)(THIS_ _Always_(_Outptr_opt_result_maybenull_) ID3DBlob ** ppErrorBuffer) PURE;
STDMETHOD(GenerateHlsl)(THIS_ _In_ UINT uFlags, // uFlags is reserved for future use.
_COM_Outptr_ ID3DBlob ** ppBuffer) PURE;
};
//////////////////////////////////////////////////////////////////////////////
// APIs //////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
extern "C" {
#endif //__cplusplus
#ifdef __cplusplus
}
#endif //__cplusplus
#endif //__D3D11SHADER_H__

View file

@ -0,0 +1,570 @@
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 8.01.0622 */
/* @@MIDL_FILE_HEADING( ) */
/* verify that the <rpcndr.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 475
#endif
/* verify that the <rpcsal.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCSAL_H_VERSION__
#define __REQUIRED_RPCSAL_H_VERSION__ 100
#endif
#include "rpc.h"
#include "rpcndr.h"
#ifndef __RPCNDR_H_VERSION__
#error this stub requires an updated version of <rpcndr.h>
#endif /* __RPCNDR_H_VERSION__ */
#ifndef COM_NO_WINDOWS_H
#include "windows.h"
#include "ole2.h"
#endif /*COM_NO_WINDOWS_H*/
#ifndef __d3d11ShaderTracing_h__
#define __d3d11ShaderTracing_h__
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
/* Forward Declarations */
#ifndef __ID3D11ShaderTrace_FWD_DEFINED__
#define __ID3D11ShaderTrace_FWD_DEFINED__
typedef interface ID3D11ShaderTrace ID3D11ShaderTrace;
#endif /* __ID3D11ShaderTrace_FWD_DEFINED__ */
#ifndef __ID3D11ShaderTraceFactory_FWD_DEFINED__
#define __ID3D11ShaderTraceFactory_FWD_DEFINED__
typedef interface ID3D11ShaderTraceFactory ID3D11ShaderTraceFactory;
#endif /* __ID3D11ShaderTraceFactory_FWD_DEFINED__ */
/* header files for imported files */
#include "oaidl.h"
#include "ocidl.h"
#ifdef __cplusplus
extern "C"{
#endif
/* interface __MIDL_itf_d3d11ShaderTracing_0000_0000 */
/* [local] */
typedef
enum D3D11_SHADER_TYPE
{
D3D11_VERTEX_SHADER = 1,
D3D11_HULL_SHADER = 2,
D3D11_DOMAIN_SHADER = 3,
D3D11_GEOMETRY_SHADER = 4,
D3D11_PIXEL_SHADER = 5,
D3D11_COMPUTE_SHADER = 6
} D3D11_SHADER_TYPE;
#define D3D11_TRACE_COMPONENT_X 0x1
#define D3D11_TRACE_COMPONENT_Y 0x2
#define D3D11_TRACE_COMPONENT_Z 0x4
#define D3D11_TRACE_COMPONENT_W 0x8
typedef UINT8 D3D11_TRACE_COMPONENT_MASK;
typedef struct D3D11_VERTEX_SHADER_TRACE_DESC
{
UINT64 Invocation;
} D3D11_VERTEX_SHADER_TRACE_DESC;
typedef struct D3D11_HULL_SHADER_TRACE_DESC
{
UINT64 Invocation;
} D3D11_HULL_SHADER_TRACE_DESC;
typedef struct D3D11_DOMAIN_SHADER_TRACE_DESC
{
UINT64 Invocation;
} D3D11_DOMAIN_SHADER_TRACE_DESC;
typedef struct D3D11_GEOMETRY_SHADER_TRACE_DESC
{
UINT64 Invocation;
} D3D11_GEOMETRY_SHADER_TRACE_DESC;
typedef struct D3D11_PIXEL_SHADER_TRACE_DESC
{
UINT64 Invocation;
INT X;
INT Y;
UINT64 SampleMask;
} D3D11_PIXEL_SHADER_TRACE_DESC;
typedef struct D3D11_COMPUTE_SHADER_TRACE_DESC
{
UINT64 Invocation;
UINT ThreadIDInGroup[ 3 ];
UINT ThreadGroupID[ 3 ];
} D3D11_COMPUTE_SHADER_TRACE_DESC;
#define D3D11_SHADER_TRACE_FLAG_RECORD_REGISTER_WRITES 0x1
#define D3D11_SHADER_TRACE_FLAG_RECORD_REGISTER_READS 0x2
typedef struct D3D11_SHADER_TRACE_DESC
{
D3D11_SHADER_TYPE Type;
UINT Flags;
union
{
D3D11_VERTEX_SHADER_TRACE_DESC VertexShaderTraceDesc;
D3D11_HULL_SHADER_TRACE_DESC HullShaderTraceDesc;
D3D11_DOMAIN_SHADER_TRACE_DESC DomainShaderTraceDesc;
D3D11_GEOMETRY_SHADER_TRACE_DESC GeometryShaderTraceDesc;
D3D11_PIXEL_SHADER_TRACE_DESC PixelShaderTraceDesc;
D3D11_COMPUTE_SHADER_TRACE_DESC ComputeShaderTraceDesc;
} ;
} D3D11_SHADER_TRACE_DESC;
typedef
enum D3D11_TRACE_GS_INPUT_PRIMITIVE
{
D3D11_TRACE_GS_INPUT_PRIMITIVE_UNDEFINED = 0,
D3D11_TRACE_GS_INPUT_PRIMITIVE_POINT = 1,
D3D11_TRACE_GS_INPUT_PRIMITIVE_LINE = 2,
D3D11_TRACE_GS_INPUT_PRIMITIVE_TRIANGLE = 3,
D3D11_TRACE_GS_INPUT_PRIMITIVE_LINE_ADJ = 6,
D3D11_TRACE_GS_INPUT_PRIMITIVE_TRIANGLE_ADJ = 7
} D3D11_TRACE_GS_INPUT_PRIMITIVE;
typedef struct D3D11_TRACE_STATS
{
D3D11_SHADER_TRACE_DESC TraceDesc;
UINT8 NumInvocationsInStamp;
UINT8 TargetStampIndex;
UINT NumTraceSteps;
D3D11_TRACE_COMPONENT_MASK InputMask[ 32 ];
D3D11_TRACE_COMPONENT_MASK OutputMask[ 32 ];
UINT16 NumTemps;
UINT16 MaxIndexableTempIndex;
UINT16 IndexableTempSize[ 4096 ];
UINT16 ImmediateConstantBufferSize;
UINT PixelPosition[ 4 ][ 2 ];
UINT64 PixelCoverageMask[ 4 ];
UINT64 PixelDiscardedMask[ 4 ];
UINT64 PixelCoverageMaskAfterShader[ 4 ];
UINT64 PixelCoverageMaskAfterA2CSampleMask[ 4 ];
UINT64 PixelCoverageMaskAfterA2CSampleMaskDepth[ 4 ];
UINT64 PixelCoverageMaskAfterA2CSampleMaskDepthStencil[ 4 ];
BOOL PSOutputsDepth;
BOOL PSOutputsMask;
D3D11_TRACE_GS_INPUT_PRIMITIVE GSInputPrimitive;
BOOL GSInputsPrimitiveID;
D3D11_TRACE_COMPONENT_MASK HSOutputPatchConstantMask[ 32 ];
D3D11_TRACE_COMPONENT_MASK DSInputPatchConstantMask[ 32 ];
} D3D11_TRACE_STATS;
typedef struct D3D11_TRACE_VALUE
{
UINT Bits[ 4 ];
D3D11_TRACE_COMPONENT_MASK ValidMask;
} D3D11_TRACE_VALUE;
typedef
enum D3D11_TRACE_REGISTER_TYPE
{
D3D11_TRACE_OUTPUT_NULL_REGISTER = 0,
D3D11_TRACE_INPUT_REGISTER = ( D3D11_TRACE_OUTPUT_NULL_REGISTER + 1 ) ,
D3D11_TRACE_INPUT_PRIMITIVE_ID_REGISTER = ( D3D11_TRACE_INPUT_REGISTER + 1 ) ,
D3D11_TRACE_IMMEDIATE_CONSTANT_BUFFER = ( D3D11_TRACE_INPUT_PRIMITIVE_ID_REGISTER + 1 ) ,
D3D11_TRACE_TEMP_REGISTER = ( D3D11_TRACE_IMMEDIATE_CONSTANT_BUFFER + 1 ) ,
D3D11_TRACE_INDEXABLE_TEMP_REGISTER = ( D3D11_TRACE_TEMP_REGISTER + 1 ) ,
D3D11_TRACE_OUTPUT_REGISTER = ( D3D11_TRACE_INDEXABLE_TEMP_REGISTER + 1 ) ,
D3D11_TRACE_OUTPUT_DEPTH_REGISTER = ( D3D11_TRACE_OUTPUT_REGISTER + 1 ) ,
D3D11_TRACE_CONSTANT_BUFFER = ( D3D11_TRACE_OUTPUT_DEPTH_REGISTER + 1 ) ,
D3D11_TRACE_IMMEDIATE32 = ( D3D11_TRACE_CONSTANT_BUFFER + 1 ) ,
D3D11_TRACE_SAMPLER = ( D3D11_TRACE_IMMEDIATE32 + 1 ) ,
D3D11_TRACE_RESOURCE = ( D3D11_TRACE_SAMPLER + 1 ) ,
D3D11_TRACE_RASTERIZER = ( D3D11_TRACE_RESOURCE + 1 ) ,
D3D11_TRACE_OUTPUT_COVERAGE_MASK = ( D3D11_TRACE_RASTERIZER + 1 ) ,
D3D11_TRACE_STREAM = ( D3D11_TRACE_OUTPUT_COVERAGE_MASK + 1 ) ,
D3D11_TRACE_THIS_POINTER = ( D3D11_TRACE_STREAM + 1 ) ,
D3D11_TRACE_OUTPUT_CONTROL_POINT_ID_REGISTER = ( D3D11_TRACE_THIS_POINTER + 1 ) ,
D3D11_TRACE_INPUT_FORK_INSTANCE_ID_REGISTER = ( D3D11_TRACE_OUTPUT_CONTROL_POINT_ID_REGISTER + 1 ) ,
D3D11_TRACE_INPUT_JOIN_INSTANCE_ID_REGISTER = ( D3D11_TRACE_INPUT_FORK_INSTANCE_ID_REGISTER + 1 ) ,
D3D11_TRACE_INPUT_CONTROL_POINT_REGISTER = ( D3D11_TRACE_INPUT_JOIN_INSTANCE_ID_REGISTER + 1 ) ,
D3D11_TRACE_OUTPUT_CONTROL_POINT_REGISTER = ( D3D11_TRACE_INPUT_CONTROL_POINT_REGISTER + 1 ) ,
D3D11_TRACE_INPUT_PATCH_CONSTANT_REGISTER = ( D3D11_TRACE_OUTPUT_CONTROL_POINT_REGISTER + 1 ) ,
D3D11_TRACE_INPUT_DOMAIN_POINT_REGISTER = ( D3D11_TRACE_INPUT_PATCH_CONSTANT_REGISTER + 1 ) ,
D3D11_TRACE_UNORDERED_ACCESS_VIEW = ( D3D11_TRACE_INPUT_DOMAIN_POINT_REGISTER + 1 ) ,
D3D11_TRACE_THREAD_GROUP_SHARED_MEMORY = ( D3D11_TRACE_UNORDERED_ACCESS_VIEW + 1 ) ,
D3D11_TRACE_INPUT_THREAD_ID_REGISTER = ( D3D11_TRACE_THREAD_GROUP_SHARED_MEMORY + 1 ) ,
D3D11_TRACE_INPUT_THREAD_GROUP_ID_REGISTER = ( D3D11_TRACE_INPUT_THREAD_ID_REGISTER + 1 ) ,
D3D11_TRACE_INPUT_THREAD_ID_IN_GROUP_REGISTER = ( D3D11_TRACE_INPUT_THREAD_GROUP_ID_REGISTER + 1 ) ,
D3D11_TRACE_INPUT_COVERAGE_MASK_REGISTER = ( D3D11_TRACE_INPUT_THREAD_ID_IN_GROUP_REGISTER + 1 ) ,
D3D11_TRACE_INPUT_THREAD_ID_IN_GROUP_FLATTENED_REGISTER = ( D3D11_TRACE_INPUT_COVERAGE_MASK_REGISTER + 1 ) ,
D3D11_TRACE_INPUT_GS_INSTANCE_ID_REGISTER = ( D3D11_TRACE_INPUT_THREAD_ID_IN_GROUP_FLATTENED_REGISTER + 1 ) ,
D3D11_TRACE_OUTPUT_DEPTH_GREATER_EQUAL_REGISTER = ( D3D11_TRACE_INPUT_GS_INSTANCE_ID_REGISTER + 1 ) ,
D3D11_TRACE_OUTPUT_DEPTH_LESS_EQUAL_REGISTER = ( D3D11_TRACE_OUTPUT_DEPTH_GREATER_EQUAL_REGISTER + 1 ) ,
D3D11_TRACE_IMMEDIATE64 = ( D3D11_TRACE_OUTPUT_DEPTH_LESS_EQUAL_REGISTER + 1 ) ,
D3D11_TRACE_INPUT_CYCLE_COUNTER_REGISTER = ( D3D11_TRACE_IMMEDIATE64 + 1 ) ,
D3D11_TRACE_INTERFACE_POINTER = ( D3D11_TRACE_INPUT_CYCLE_COUNTER_REGISTER + 1 )
} D3D11_TRACE_REGISTER_TYPE;
#define D3D11_TRACE_REGISTER_FLAGS_RELATIVE_INDEXING 0x1
typedef struct D3D11_TRACE_REGISTER
{
D3D11_TRACE_REGISTER_TYPE RegType;
union
{
UINT16 Index1D;
UINT16 Index2D[ 2 ];
} ;
UINT8 OperandIndex;
UINT8 Flags;
} D3D11_TRACE_REGISTER;
#define D3D11_TRACE_MISC_GS_EMIT 0x1
#define D3D11_TRACE_MISC_GS_CUT 0x2
#define D3D11_TRACE_MISC_PS_DISCARD 0x4
#define D3D11_TRACE_MISC_GS_EMIT_STREAM 0x8
#define D3D11_TRACE_MISC_GS_CUT_STREAM 0x10
#define D3D11_TRACE_MISC_HALT 0x20
#define D3D11_TRACE_MISC_MESSAGE 0x40
typedef UINT16 D3D11_TRACE_MISC_OPERATIONS_MASK;
typedef struct D3D11_TRACE_STEP
{
UINT ID;
BOOL InstructionActive;
UINT8 NumRegistersWritten;
UINT8 NumRegistersRead;
D3D11_TRACE_MISC_OPERATIONS_MASK MiscOperations;
UINT OpcodeType;
UINT64 CurrentGlobalCycle;
} D3D11_TRACE_STEP;
extern RPC_IF_HANDLE __MIDL_itf_d3d11ShaderTracing_0000_0000_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_d3d11ShaderTracing_0000_0000_v0_0_s_ifspec;
#ifndef __ID3D11ShaderTrace_INTERFACE_DEFINED__
#define __ID3D11ShaderTrace_INTERFACE_DEFINED__
/* interface ID3D11ShaderTrace */
/* [unique][local][object][uuid] */
EXTERN_C const IID IID_ID3D11ShaderTrace;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("36b013e6-2811-4845-baa7-d623fe0df104")
ID3D11ShaderTrace : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE TraceReady(
/* [annotation] */
_Out_opt_ UINT64 *pTestCount) = 0;
virtual void STDMETHODCALLTYPE ResetTrace( void) = 0;
virtual HRESULT STDMETHODCALLTYPE GetTraceStats(
/* [annotation] */
_Out_ D3D11_TRACE_STATS *pTraceStats) = 0;
virtual HRESULT STDMETHODCALLTYPE PSSelectStamp(
/* [annotation] */
_In_ UINT stampIndex) = 0;
virtual HRESULT STDMETHODCALLTYPE GetInitialRegisterContents(
/* [annotation] */
_In_ D3D11_TRACE_REGISTER *pRegister,
/* [annotation] */
_Out_ D3D11_TRACE_VALUE *pValue) = 0;
virtual HRESULT STDMETHODCALLTYPE GetStep(
/* [annotation] */
_In_ UINT stepIndex,
/* [annotation] */
_Out_ D3D11_TRACE_STEP *pTraceStep) = 0;
virtual HRESULT STDMETHODCALLTYPE GetWrittenRegister(
/* [annotation] */
_In_ UINT stepIndex,
/* [annotation] */
_In_ UINT writtenRegisterIndex,
/* [annotation] */
_Out_ D3D11_TRACE_REGISTER *pRegister,
/* [annotation] */
_Out_ D3D11_TRACE_VALUE *pValue) = 0;
virtual HRESULT STDMETHODCALLTYPE GetReadRegister(
/* [annotation] */
_In_ UINT stepIndex,
/* [annotation] */
_In_ UINT readRegisterIndex,
/* [annotation] */
_Out_ D3D11_TRACE_REGISTER *pRegister,
/* [annotation] */
_Out_ D3D11_TRACE_VALUE *pValue) = 0;
};
#else /* C style interface */
typedef struct ID3D11ShaderTraceVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
ID3D11ShaderTrace * This,
/* [in] */ REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
ID3D11ShaderTrace * This);
ULONG ( STDMETHODCALLTYPE *Release )(
ID3D11ShaderTrace * This);
HRESULT ( STDMETHODCALLTYPE *TraceReady )(
ID3D11ShaderTrace * This,
/* [annotation] */
_Out_opt_ UINT64 *pTestCount);
void ( STDMETHODCALLTYPE *ResetTrace )(
ID3D11ShaderTrace * This);
HRESULT ( STDMETHODCALLTYPE *GetTraceStats )(
ID3D11ShaderTrace * This,
/* [annotation] */
_Out_ D3D11_TRACE_STATS *pTraceStats);
HRESULT ( STDMETHODCALLTYPE *PSSelectStamp )(
ID3D11ShaderTrace * This,
/* [annotation] */
_In_ UINT stampIndex);
HRESULT ( STDMETHODCALLTYPE *GetInitialRegisterContents )(
ID3D11ShaderTrace * This,
/* [annotation] */
_In_ D3D11_TRACE_REGISTER *pRegister,
/* [annotation] */
_Out_ D3D11_TRACE_VALUE *pValue);
HRESULT ( STDMETHODCALLTYPE *GetStep )(
ID3D11ShaderTrace * This,
/* [annotation] */
_In_ UINT stepIndex,
/* [annotation] */
_Out_ D3D11_TRACE_STEP *pTraceStep);
HRESULT ( STDMETHODCALLTYPE *GetWrittenRegister )(
ID3D11ShaderTrace * This,
/* [annotation] */
_In_ UINT stepIndex,
/* [annotation] */
_In_ UINT writtenRegisterIndex,
/* [annotation] */
_Out_ D3D11_TRACE_REGISTER *pRegister,
/* [annotation] */
_Out_ D3D11_TRACE_VALUE *pValue);
HRESULT ( STDMETHODCALLTYPE *GetReadRegister )(
ID3D11ShaderTrace * This,
/* [annotation] */
_In_ UINT stepIndex,
/* [annotation] */
_In_ UINT readRegisterIndex,
/* [annotation] */
_Out_ D3D11_TRACE_REGISTER *pRegister,
/* [annotation] */
_Out_ D3D11_TRACE_VALUE *pValue);
END_INTERFACE
} ID3D11ShaderTraceVtbl;
interface ID3D11ShaderTrace
{
CONST_VTBL struct ID3D11ShaderTraceVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define ID3D11ShaderTrace_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define ID3D11ShaderTrace_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define ID3D11ShaderTrace_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define ID3D11ShaderTrace_TraceReady(This,pTestCount) \
( (This)->lpVtbl -> TraceReady(This,pTestCount) )
#define ID3D11ShaderTrace_ResetTrace(This) \
( (This)->lpVtbl -> ResetTrace(This) )
#define ID3D11ShaderTrace_GetTraceStats(This,pTraceStats) \
( (This)->lpVtbl -> GetTraceStats(This,pTraceStats) )
#define ID3D11ShaderTrace_PSSelectStamp(This,stampIndex) \
( (This)->lpVtbl -> PSSelectStamp(This,stampIndex) )
#define ID3D11ShaderTrace_GetInitialRegisterContents(This,pRegister,pValue) \
( (This)->lpVtbl -> GetInitialRegisterContents(This,pRegister,pValue) )
#define ID3D11ShaderTrace_GetStep(This,stepIndex,pTraceStep) \
( (This)->lpVtbl -> GetStep(This,stepIndex,pTraceStep) )
#define ID3D11ShaderTrace_GetWrittenRegister(This,stepIndex,writtenRegisterIndex,pRegister,pValue) \
( (This)->lpVtbl -> GetWrittenRegister(This,stepIndex,writtenRegisterIndex,pRegister,pValue) )
#define ID3D11ShaderTrace_GetReadRegister(This,stepIndex,readRegisterIndex,pRegister,pValue) \
( (This)->lpVtbl -> GetReadRegister(This,stepIndex,readRegisterIndex,pRegister,pValue) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* __ID3D11ShaderTrace_INTERFACE_DEFINED__ */
#ifndef __ID3D11ShaderTraceFactory_INTERFACE_DEFINED__
#define __ID3D11ShaderTraceFactory_INTERFACE_DEFINED__
/* interface ID3D11ShaderTraceFactory */
/* [unique][local][object][uuid] */
EXTERN_C const IID IID_ID3D11ShaderTraceFactory;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("1fbad429-66ab-41cc-9617-667ac10e4459")
ID3D11ShaderTraceFactory : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE CreateShaderTrace(
/* [annotation] */
_In_ IUnknown *pShader,
/* [annotation] */
_In_ D3D11_SHADER_TRACE_DESC *pTraceDesc,
/* [annotation] */
_COM_Outptr_ ID3D11ShaderTrace **ppShaderTrace) = 0;
};
#else /* C style interface */
typedef struct ID3D11ShaderTraceFactoryVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
ID3D11ShaderTraceFactory * This,
/* [in] */ REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
ID3D11ShaderTraceFactory * This);
ULONG ( STDMETHODCALLTYPE *Release )(
ID3D11ShaderTraceFactory * This);
HRESULT ( STDMETHODCALLTYPE *CreateShaderTrace )(
ID3D11ShaderTraceFactory * This,
/* [annotation] */
_In_ IUnknown *pShader,
/* [annotation] */
_In_ D3D11_SHADER_TRACE_DESC *pTraceDesc,
/* [annotation] */
_COM_Outptr_ ID3D11ShaderTrace **ppShaderTrace);
END_INTERFACE
} ID3D11ShaderTraceFactoryVtbl;
interface ID3D11ShaderTraceFactory
{
CONST_VTBL struct ID3D11ShaderTraceFactoryVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define ID3D11ShaderTraceFactory_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define ID3D11ShaderTraceFactory_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define ID3D11ShaderTraceFactory_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define ID3D11ShaderTraceFactory_CreateShaderTrace(This,pShader,pTraceDesc,ppShaderTrace) \
( (This)->lpVtbl -> CreateShaderTrace(This,pShader,pTraceDesc,ppShaderTrace) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* __ID3D11ShaderTraceFactory_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_d3d11ShaderTracing_0000_0002 */
/* [local] */
HRESULT WINAPI
D3DDisassemble11Trace(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
_In_ SIZE_T SrcDataSize,
_In_ ID3D11ShaderTrace* pTrace,
_In_ UINT StartStep,
_In_ UINT NumSteps,
_In_ UINT Flags,
_COM_Outptr_ interface ID3D10Blob** ppDisassembly);
extern RPC_IF_HANDLE __MIDL_itf_d3d11ShaderTracing_0000_0002_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_d3d11ShaderTracing_0000_0002_v0_0_s_ifspec;
/* Additional Prototypes for ALL interfaces */
/* end of Additional Prototypes */
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,459 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// File: D3D12Shader.h
// Content: D3D12 Shader Types and APIs
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __D3D12SHADER_H__
#define __D3D12SHADER_H__
#include "d3dcommon.h"
typedef enum D3D12_SHADER_VERSION_TYPE
{
D3D12_SHVER_PIXEL_SHADER = 0,
D3D12_SHVER_VERTEX_SHADER = 1,
D3D12_SHVER_GEOMETRY_SHADER = 2,
// D3D11 Shaders
D3D12_SHVER_HULL_SHADER = 3,
D3D12_SHVER_DOMAIN_SHADER = 4,
D3D12_SHVER_COMPUTE_SHADER = 5,
D3D12_SHVER_RESERVED0 = 0xFFF0,
} D3D12_SHADER_VERSION_TYPE;
#define D3D12_SHVER_GET_TYPE(_Version) \
(((_Version) >> 16) & 0xffff)
#define D3D12_SHVER_GET_MAJOR(_Version) \
(((_Version) >> 4) & 0xf)
#define D3D12_SHVER_GET_MINOR(_Version) \
(((_Version) >> 0) & 0xf)
// Slot ID for library function return
#define D3D_RETURN_PARAMETER_INDEX (-1)
typedef D3D_RESOURCE_RETURN_TYPE D3D12_RESOURCE_RETURN_TYPE;
typedef D3D_CBUFFER_TYPE D3D12_CBUFFER_TYPE;
typedef struct _D3D12_SIGNATURE_PARAMETER_DESC
{
LPCSTR SemanticName; // Name of the semantic
UINT SemanticIndex; // Index of the semantic
UINT Register; // Number of member variables
D3D_NAME SystemValueType;// A predefined system value, or D3D_NAME_UNDEFINED if not applicable
D3D_REGISTER_COMPONENT_TYPE ComponentType; // Scalar type (e.g. uint, float, etc.)
BYTE Mask; // Mask to indicate which components of the register
// are used (combination of D3D10_COMPONENT_MASK values)
BYTE ReadWriteMask; // Mask to indicate whether a given component is
// never written (if this is an output signature) or
// always read (if this is an input signature).
// (combination of D3D_MASK_* values)
UINT Stream; // Stream index
D3D_MIN_PRECISION MinPrecision; // Minimum desired interpolation precision
} D3D12_SIGNATURE_PARAMETER_DESC;
typedef struct _D3D12_SHADER_BUFFER_DESC
{
LPCSTR Name; // Name of the constant buffer
D3D_CBUFFER_TYPE Type; // Indicates type of buffer content
UINT Variables; // Number of member variables
UINT Size; // Size of CB (in bytes)
UINT uFlags; // Buffer description flags
} D3D12_SHADER_BUFFER_DESC;
typedef struct _D3D12_SHADER_VARIABLE_DESC
{
LPCSTR Name; // Name of the variable
UINT StartOffset; // Offset in constant buffer's backing store
UINT Size; // Size of variable (in bytes)
UINT uFlags; // Variable flags
LPVOID DefaultValue; // Raw pointer to default value
UINT StartTexture; // First texture index (or -1 if no textures used)
UINT TextureSize; // Number of texture slots possibly used.
UINT StartSampler; // First sampler index (or -1 if no textures used)
UINT SamplerSize; // Number of sampler slots possibly used.
} D3D12_SHADER_VARIABLE_DESC;
typedef struct _D3D12_SHADER_TYPE_DESC
{
D3D_SHADER_VARIABLE_CLASS Class; // Variable class (e.g. object, matrix, etc.)
D3D_SHADER_VARIABLE_TYPE Type; // Variable type (e.g. float, sampler, etc.)
UINT Rows; // Number of rows (for matrices, 1 for other numeric, 0 if not applicable)
UINT Columns; // Number of columns (for vectors & matrices, 1 for other numeric, 0 if not applicable)
UINT Elements; // Number of elements (0 if not an array)
UINT Members; // Number of members (0 if not a structure)
UINT Offset; // Offset from the start of structure (0 if not a structure member)
LPCSTR Name; // Name of type, can be NULL
} D3D12_SHADER_TYPE_DESC;
typedef D3D_TESSELLATOR_DOMAIN D3D12_TESSELLATOR_DOMAIN;
typedef D3D_TESSELLATOR_PARTITIONING D3D12_TESSELLATOR_PARTITIONING;
typedef D3D_TESSELLATOR_OUTPUT_PRIMITIVE D3D12_TESSELLATOR_OUTPUT_PRIMITIVE;
typedef struct _D3D12_SHADER_DESC
{
UINT Version; // Shader version
LPCSTR Creator; // Creator string
UINT Flags; // Shader compilation/parse flags
UINT ConstantBuffers; // Number of constant buffers
UINT BoundResources; // Number of bound resources
UINT InputParameters; // Number of parameters in the input signature
UINT OutputParameters; // Number of parameters in the output signature
UINT InstructionCount; // Number of emitted instructions
UINT TempRegisterCount; // Number of temporary registers used
UINT TempArrayCount; // Number of temporary arrays used
UINT DefCount; // Number of constant defines
UINT DclCount; // Number of declarations (input + output)
UINT TextureNormalInstructions; // Number of non-categorized texture instructions
UINT TextureLoadInstructions; // Number of texture load instructions
UINT TextureCompInstructions; // Number of texture comparison instructions
UINT TextureBiasInstructions; // Number of texture bias instructions
UINT TextureGradientInstructions; // Number of texture gradient instructions
UINT FloatInstructionCount; // Number of floating point arithmetic instructions used
UINT IntInstructionCount; // Number of signed integer arithmetic instructions used
UINT UintInstructionCount; // Number of unsigned integer arithmetic instructions used
UINT StaticFlowControlCount; // Number of static flow control instructions used
UINT DynamicFlowControlCount; // Number of dynamic flow control instructions used
UINT MacroInstructionCount; // Number of macro instructions used
UINT ArrayInstructionCount; // Number of array instructions used
UINT CutInstructionCount; // Number of cut instructions used
UINT EmitInstructionCount; // Number of emit instructions used
D3D_PRIMITIVE_TOPOLOGY GSOutputTopology; // Geometry shader output topology
UINT GSMaxOutputVertexCount; // Geometry shader maximum output vertex count
D3D_PRIMITIVE InputPrimitive; // GS/HS input primitive
UINT PatchConstantParameters; // Number of parameters in the patch constant signature
UINT cGSInstanceCount; // Number of Geometry shader instances
UINT cControlPoints; // Number of control points in the HS->DS stage
D3D_TESSELLATOR_OUTPUT_PRIMITIVE HSOutputPrimitive; // Primitive output by the tessellator
D3D_TESSELLATOR_PARTITIONING HSPartitioning; // Partitioning mode of the tessellator
D3D_TESSELLATOR_DOMAIN TessellatorDomain; // Domain of the tessellator (quad, tri, isoline)
// instruction counts
UINT cBarrierInstructions; // Number of barrier instructions in a compute shader
UINT cInterlockedInstructions; // Number of interlocked instructions
UINT cTextureStoreInstructions; // Number of texture writes
} D3D12_SHADER_DESC;
typedef struct _D3D12_SHADER_INPUT_BIND_DESC
{
LPCSTR Name; // Name of the resource
D3D_SHADER_INPUT_TYPE Type; // Type of resource (e.g. texture, cbuffer, etc.)
UINT BindPoint; // Starting bind point
UINT BindCount; // Number of contiguous bind points (for arrays)
UINT uFlags; // Input binding flags
D3D_RESOURCE_RETURN_TYPE ReturnType; // Return type (if texture)
D3D_SRV_DIMENSION Dimension; // Dimension (if texture)
UINT NumSamples; // Number of samples (0 if not MS texture)
UINT Space; // Register space
UINT uID; // Range ID in the bytecode
} D3D12_SHADER_INPUT_BIND_DESC;
#define D3D_SHADER_REQUIRES_DOUBLES 0x00000001
#define D3D_SHADER_REQUIRES_EARLY_DEPTH_STENCIL 0x00000002
#define D3D_SHADER_REQUIRES_UAVS_AT_EVERY_STAGE 0x00000004
#define D3D_SHADER_REQUIRES_64_UAVS 0x00000008
#define D3D_SHADER_REQUIRES_MINIMUM_PRECISION 0x00000010
#define D3D_SHADER_REQUIRES_11_1_DOUBLE_EXTENSIONS 0x00000020
#define D3D_SHADER_REQUIRES_11_1_SHADER_EXTENSIONS 0x00000040
#define D3D_SHADER_REQUIRES_LEVEL_9_COMPARISON_FILTERING 0x00000080
#define D3D_SHADER_REQUIRES_TILED_RESOURCES 0x00000100
#define D3D_SHADER_REQUIRES_STENCIL_REF 0x00000200
#define D3D_SHADER_REQUIRES_INNER_COVERAGE 0x00000400
#define D3D_SHADER_REQUIRES_TYPED_UAV_LOAD_ADDITIONAL_FORMATS 0x00000800
#define D3D_SHADER_REQUIRES_ROVS 0x00001000
#define D3D_SHADER_REQUIRES_VIEWPORT_AND_RT_ARRAY_INDEX_FROM_ANY_SHADER_FEEDING_RASTERIZER 0x00002000
typedef struct _D3D12_LIBRARY_DESC
{
LPCSTR Creator; // The name of the originator of the library.
UINT Flags; // Compilation flags.
UINT FunctionCount; // Number of functions exported from the library.
} D3D12_LIBRARY_DESC;
typedef struct _D3D12_FUNCTION_DESC
{
UINT Version; // Shader version
LPCSTR Creator; // Creator string
UINT Flags; // Shader compilation/parse flags
UINT ConstantBuffers; // Number of constant buffers
UINT BoundResources; // Number of bound resources
UINT InstructionCount; // Number of emitted instructions
UINT TempRegisterCount; // Number of temporary registers used
UINT TempArrayCount; // Number of temporary arrays used
UINT DefCount; // Number of constant defines
UINT DclCount; // Number of declarations (input + output)
UINT TextureNormalInstructions; // Number of non-categorized texture instructions
UINT TextureLoadInstructions; // Number of texture load instructions
UINT TextureCompInstructions; // Number of texture comparison instructions
UINT TextureBiasInstructions; // Number of texture bias instructions
UINT TextureGradientInstructions; // Number of texture gradient instructions
UINT FloatInstructionCount; // Number of floating point arithmetic instructions used
UINT IntInstructionCount; // Number of signed integer arithmetic instructions used
UINT UintInstructionCount; // Number of unsigned integer arithmetic instructions used
UINT StaticFlowControlCount; // Number of static flow control instructions used
UINT DynamicFlowControlCount; // Number of dynamic flow control instructions used
UINT MacroInstructionCount; // Number of macro instructions used
UINT ArrayInstructionCount; // Number of array instructions used
UINT MovInstructionCount; // Number of mov instructions used
UINT MovcInstructionCount; // Number of movc instructions used
UINT ConversionInstructionCount; // Number of type conversion instructions used
UINT BitwiseInstructionCount; // Number of bitwise arithmetic instructions used
D3D_FEATURE_LEVEL MinFeatureLevel; // Min target of the function byte code
UINT64 RequiredFeatureFlags; // Required feature flags
LPCSTR Name; // Function name
INT FunctionParameterCount; // Number of logical parameters in the function signature (not including return)
BOOL HasReturn; // TRUE, if function returns a value, false - it is a subroutine
BOOL Has10Level9VertexShader; // TRUE, if there is a 10L9 VS blob
BOOL Has10Level9PixelShader; // TRUE, if there is a 10L9 PS blob
} D3D12_FUNCTION_DESC;
typedef struct _D3D12_PARAMETER_DESC
{
LPCSTR Name; // Parameter name.
LPCSTR SemanticName; // Parameter semantic name (+index).
D3D_SHADER_VARIABLE_TYPE Type; // Element type.
D3D_SHADER_VARIABLE_CLASS Class; // Scalar/Vector/Matrix.
UINT Rows; // Rows are for matrix parameters.
UINT Columns; // Components or Columns in matrix.
D3D_INTERPOLATION_MODE InterpolationMode; // Interpolation mode.
D3D_PARAMETER_FLAGS Flags; // Parameter modifiers.
UINT FirstInRegister; // The first input register for this parameter.
UINT FirstInComponent; // The first input register component for this parameter.
UINT FirstOutRegister; // The first output register for this parameter.
UINT FirstOutComponent; // The first output register component for this parameter.
} D3D12_PARAMETER_DESC;
//////////////////////////////////////////////////////////////////////////////
// Interfaces ////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
typedef interface ID3D12ShaderReflectionType ID3D12ShaderReflectionType;
typedef interface ID3D12ShaderReflectionType *LPD3D12SHADERREFLECTIONTYPE;
typedef interface ID3D12ShaderReflectionVariable ID3D12ShaderReflectionVariable;
typedef interface ID3D12ShaderReflectionVariable *LPD3D12SHADERREFLECTIONVARIABLE;
typedef interface ID3D12ShaderReflectionConstantBuffer ID3D12ShaderReflectionConstantBuffer;
typedef interface ID3D12ShaderReflectionConstantBuffer *LPD3D12SHADERREFLECTIONCONSTANTBUFFER;
typedef interface ID3D12ShaderReflection ID3D12ShaderReflection;
typedef interface ID3D12ShaderReflection *LPD3D12SHADERREFLECTION;
typedef interface ID3D12LibraryReflection ID3D12LibraryReflection;
typedef interface ID3D12LibraryReflection *LPD3D12LIBRARYREFLECTION;
typedef interface ID3D12FunctionReflection ID3D12FunctionReflection;
typedef interface ID3D12FunctionReflection *LPD3D12FUNCTIONREFLECTION;
typedef interface ID3D12FunctionParameterReflection ID3D12FunctionParameterReflection;
typedef interface ID3D12FunctionParameterReflection *LPD3D12FUNCTIONPARAMETERREFLECTION;
// {E913C351-783D-48CA-A1D1-4F306284AD56}
interface DECLSPEC_UUID("E913C351-783D-48CA-A1D1-4F306284AD56") ID3D12ShaderReflectionType;
DEFINE_GUID(IID_ID3D12ShaderReflectionType,
0xe913c351, 0x783d, 0x48ca, 0xa1, 0xd1, 0x4f, 0x30, 0x62, 0x84, 0xad, 0x56);
#undef INTERFACE
#define INTERFACE ID3D12ShaderReflectionType
DECLARE_INTERFACE(ID3D12ShaderReflectionType)
{
STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_SHADER_TYPE_DESC *pDesc) PURE;
STDMETHOD_(ID3D12ShaderReflectionType*, GetMemberTypeByIndex)(THIS_ _In_ UINT Index) PURE;
STDMETHOD_(ID3D12ShaderReflectionType*, GetMemberTypeByName)(THIS_ _In_ LPCSTR Name) PURE;
STDMETHOD_(LPCSTR, GetMemberTypeName)(THIS_ _In_ UINT Index) PURE;
STDMETHOD(IsEqual)(THIS_ _In_ ID3D12ShaderReflectionType* pType) PURE;
STDMETHOD_(ID3D12ShaderReflectionType*, GetSubType)(THIS) PURE;
STDMETHOD_(ID3D12ShaderReflectionType*, GetBaseClass)(THIS) PURE;
STDMETHOD_(UINT, GetNumInterfaces)(THIS) PURE;
STDMETHOD_(ID3D12ShaderReflectionType*, GetInterfaceByIndex)(THIS_ _In_ UINT uIndex) PURE;
STDMETHOD(IsOfType)(THIS_ _In_ ID3D12ShaderReflectionType* pType) PURE;
STDMETHOD(ImplementsInterface)(THIS_ _In_ ID3D12ShaderReflectionType* pBase) PURE;
};
// {8337A8A6-A216-444A-B2F4-314733A73AEA}
interface DECLSPEC_UUID("8337A8A6-A216-444A-B2F4-314733A73AEA") ID3D12ShaderReflectionVariable;
DEFINE_GUID(IID_ID3D12ShaderReflectionVariable,
0x8337a8a6, 0xa216, 0x444a, 0xb2, 0xf4, 0x31, 0x47, 0x33, 0xa7, 0x3a, 0xea);
#undef INTERFACE
#define INTERFACE ID3D12ShaderReflectionVariable
DECLARE_INTERFACE(ID3D12ShaderReflectionVariable)
{
STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_SHADER_VARIABLE_DESC *pDesc) PURE;
STDMETHOD_(ID3D12ShaderReflectionType*, GetType)(THIS) PURE;
STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetBuffer)(THIS) PURE;
STDMETHOD_(UINT, GetInterfaceSlot)(THIS_ _In_ UINT uArrayIndex) PURE;
};
// {C59598B4-48B3-4869-B9B1-B1618B14A8B7}
interface DECLSPEC_UUID("C59598B4-48B3-4869-B9B1-B1618B14A8B7") ID3D12ShaderReflectionConstantBuffer;
DEFINE_GUID(IID_ID3D12ShaderReflectionConstantBuffer,
0xc59598b4, 0x48b3, 0x4869, 0xb9, 0xb1, 0xb1, 0x61, 0x8b, 0x14, 0xa8, 0xb7);
#undef INTERFACE
#define INTERFACE ID3D12ShaderReflectionConstantBuffer
DECLARE_INTERFACE(ID3D12ShaderReflectionConstantBuffer)
{
STDMETHOD(GetDesc)(THIS_ D3D12_SHADER_BUFFER_DESC *pDesc) PURE;
STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByIndex)(THIS_ _In_ UINT Index) PURE;
STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByName)(THIS_ _In_ LPCSTR Name) PURE;
};
// The ID3D12ShaderReflection IID may change from SDK version to SDK version
// if the reflection API changes. This prevents new code with the new API
// from working with an old binary. Recompiling with the new header
// will pick up the new IID.
// {5A58797D-A72C-478D-8BA2-EFC6B0EFE88E}
interface DECLSPEC_UUID("5A58797D-A72C-478D-8BA2-EFC6B0EFE88E") ID3D12ShaderReflection;
DEFINE_GUID(IID_ID3D12ShaderReflection,
0x5a58797d, 0xa72c, 0x478d, 0x8b, 0xa2, 0xef, 0xc6, 0xb0, 0xef, 0xe8, 0x8e);
#undef INTERFACE
#define INTERFACE ID3D12ShaderReflection
DECLARE_INTERFACE_(ID3D12ShaderReflection, IUnknown)
{
STDMETHOD(QueryInterface)(THIS_ _In_ REFIID iid,
_Out_ LPVOID *ppv) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_SHADER_DESC *pDesc) PURE;
STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetConstantBufferByIndex)(THIS_ _In_ UINT Index) PURE;
STDMETHOD_(ID3D12ShaderReflectionConstantBuffer*, GetConstantBufferByName)(THIS_ _In_ LPCSTR Name) PURE;
STDMETHOD(GetResourceBindingDesc)(THIS_ _In_ UINT ResourceIndex,
_Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc) PURE;
STDMETHOD(GetInputParameterDesc)(THIS_ _In_ UINT ParameterIndex,
_Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
STDMETHOD(GetOutputParameterDesc)(THIS_ _In_ UINT ParameterIndex,
_Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
STDMETHOD(GetPatchConstantParameterDesc)(THIS_ _In_ UINT ParameterIndex,
_Out_ D3D12_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
STDMETHOD_(ID3D12ShaderReflectionVariable*, GetVariableByName)(THIS_ _In_ LPCSTR Name) PURE;
STDMETHOD(GetResourceBindingDescByName)(THIS_ _In_ LPCSTR Name,
_Out_ D3D12_SHADER_INPUT_BIND_DESC *pDesc) PURE;
STDMETHOD_(UINT, GetMovInstructionCount)(THIS) PURE;
STDMETHOD_(UINT, GetMovcInstructionCount)(THIS) PURE;
STDMETHOD_(UINT, GetConversionInstructionCount)(THIS) PURE;
STDMETHOD_(UINT, GetBitwiseInstructionCount)(THIS) PURE;
STDMETHOD_(D3D_PRIMITIVE, GetGSInputPrimitive)(THIS) PURE;
STDMETHOD_(BOOL, IsSampleFrequencyShader)(THIS) PURE;
STDMETHOD_(UINT, GetNumInterfaceSlots)(THIS) PURE;
STDMETHOD(GetMinFeatureLevel)(THIS_ _Out_ enum D3D_FEATURE_LEVEL* pLevel) PURE;
STDMETHOD_(UINT, GetThreadGroupSize)(THIS_
_Out_opt_ UINT* pSizeX,
_Out_opt_ UINT* pSizeY,
_Out_opt_ UINT* pSizeZ) PURE;
STDMETHOD_(UINT64, GetRequiresFlags)(THIS) PURE;
};
// {8E349D19-54DB-4A56-9DC9-119D87BDB804}
interface DECLSPEC_UUID("8E349D19-54DB-4A56-9DC9-119D87BDB804") ID3D12LibraryReflection;
DEFINE_GUID(IID_ID3D12LibraryReflection,
0x8e349d19, 0x54db, 0x4a56, 0x9d, 0xc9, 0x11, 0x9d, 0x87, 0xbd, 0xb8, 0x4);
#undef INTERFACE
#define INTERFACE ID3D12LibraryReflection
DECLARE_INTERFACE_(ID3D12LibraryReflection, IUnknown)
{
STDMETHOD(QueryInterface)(THIS_ _In_ REFIID iid, _Out_ LPVOID * ppv) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_LIBRARY_DESC * pDesc) PURE;
STDMETHOD_(ID3D12FunctionReflection *, GetFunctionByIndex)(THIS_ _In_ INT FunctionIndex) PURE;
};
// {1108795C-2772-4BA9-B2A8-D464DC7E2799}
interface DECLSPEC_UUID("1108795C-2772-4BA9-B2A8-D464DC7E2799") ID3D12FunctionReflection;
DEFINE_GUID(IID_ID3D12FunctionReflection,
0x1108795c, 0x2772, 0x4ba9, 0xb2, 0xa8, 0xd4, 0x64, 0xdc, 0x7e, 0x27, 0x99);
#undef INTERFACE
#define INTERFACE ID3D12FunctionReflection
DECLARE_INTERFACE(ID3D12FunctionReflection)
{
STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_FUNCTION_DESC * pDesc) PURE;
STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByIndex)(THIS_ _In_ UINT BufferIndex) PURE;
STDMETHOD_(ID3D12ShaderReflectionConstantBuffer *, GetConstantBufferByName)(THIS_ _In_ LPCSTR Name) PURE;
STDMETHOD(GetResourceBindingDesc)(THIS_ _In_ UINT ResourceIndex,
_Out_ D3D12_SHADER_INPUT_BIND_DESC * pDesc) PURE;
STDMETHOD_(ID3D12ShaderReflectionVariable *, GetVariableByName)(THIS_ _In_ LPCSTR Name) PURE;
STDMETHOD(GetResourceBindingDescByName)(THIS_ _In_ LPCSTR Name,
_Out_ D3D12_SHADER_INPUT_BIND_DESC * pDesc) PURE;
// Use D3D_RETURN_PARAMETER_INDEX to get description of the return value.
STDMETHOD_(ID3D12FunctionParameterReflection *, GetFunctionParameter)(THIS_ _In_ INT ParameterIndex) PURE;
};
// {EC25F42D-7006-4F2B-B33E-02CC3375733F}
interface DECLSPEC_UUID("EC25F42D-7006-4F2B-B33E-02CC3375733F") ID3D12FunctionParameterReflection;
DEFINE_GUID(IID_ID3D12FunctionParameterReflection,
0xec25f42d, 0x7006, 0x4f2b, 0xb3, 0x3e, 0x2, 0xcc, 0x33, 0x75, 0x73, 0x3f);
#undef INTERFACE
#define INTERFACE ID3D12FunctionParameterReflection
DECLARE_INTERFACE(ID3D12FunctionParameterReflection)
{
STDMETHOD(GetDesc)(THIS_ _Out_ D3D12_PARAMETER_DESC * pDesc) PURE;
};
//////////////////////////////////////////////////////////////////////////////
// APIs //////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
extern "C" {
#endif //__cplusplus
#ifdef __cplusplus
}
#endif //__cplusplus
#endif //__D3D12SHADER_H__

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,571 @@
/*==========================================================================;
*
* Copyright (C) Microsoft Corporation. All Rights Reserved.
*
* File: d3d9caps.h
* Content: Direct3D capabilities include file
*
***************************************************************************/
#ifndef _d3d9CAPS_H
#define _d3d9CAPS_H
#ifndef DIRECT3D_VERSION
#define DIRECT3D_VERSION 0x0900
#endif //DIRECT3D_VERSION
// include this file content only if compiling for DX9 interfaces
#if(DIRECT3D_VERSION >= 0x0900)
#if defined(_X86_) || defined(_IA64_)
#pragma pack(4)
#endif
typedef struct _D3DVSHADERCAPS2_0
{
DWORD Caps;
INT DynamicFlowControlDepth;
INT NumTemps;
INT StaticFlowControlDepth;
} D3DVSHADERCAPS2_0;
#define D3DVS20CAPS_PREDICATION (1<<0)
#define D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH 24
#define D3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH 0
#define D3DVS20_MAX_NUMTEMPS 32
#define D3DVS20_MIN_NUMTEMPS 12
#define D3DVS20_MAX_STATICFLOWCONTROLDEPTH 4
#define D3DVS20_MIN_STATICFLOWCONTROLDEPTH 1
typedef struct _D3DPSHADERCAPS2_0
{
DWORD Caps;
INT DynamicFlowControlDepth;
INT NumTemps;
INT StaticFlowControlDepth;
INT NumInstructionSlots;
} D3DPSHADERCAPS2_0;
#define D3DPS20CAPS_ARBITRARYSWIZZLE (1<<0)
#define D3DPS20CAPS_GRADIENTINSTRUCTIONS (1<<1)
#define D3DPS20CAPS_PREDICATION (1<<2)
#define D3DPS20CAPS_NODEPENDENTREADLIMIT (1<<3)
#define D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT (1<<4)
#define D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH 24
#define D3DPS20_MIN_DYNAMICFLOWCONTROLDEPTH 0
#define D3DPS20_MAX_NUMTEMPS 32
#define D3DPS20_MIN_NUMTEMPS 12
#define D3DPS20_MAX_STATICFLOWCONTROLDEPTH 4
#define D3DPS20_MIN_STATICFLOWCONTROLDEPTH 0
#define D3DPS20_MAX_NUMINSTRUCTIONSLOTS 512
#define D3DPS20_MIN_NUMINSTRUCTIONSLOTS 96
#define D3DMIN30SHADERINSTRUCTIONS 512
#define D3DMAX30SHADERINSTRUCTIONS 32768
/* D3D9Ex only -- */
#if !defined(D3D_DISABLE_9EX)
typedef struct _D3DOVERLAYCAPS
{
UINT Caps;
UINT MaxOverlayDisplayWidth;
UINT MaxOverlayDisplayHeight;
} D3DOVERLAYCAPS;
#define D3DOVERLAYCAPS_FULLRANGERGB 0x00000001
#define D3DOVERLAYCAPS_LIMITEDRANGERGB 0x00000002
#define D3DOVERLAYCAPS_YCbCr_BT601 0x00000004
#define D3DOVERLAYCAPS_YCbCr_BT709 0x00000008
#define D3DOVERLAYCAPS_YCbCr_BT601_xvYCC 0x00000010
#define D3DOVERLAYCAPS_YCbCr_BT709_xvYCC 0x00000020
#define D3DOVERLAYCAPS_STRETCHX 0x00000040
#define D3DOVERLAYCAPS_STRETCHY 0x00000080
typedef struct _D3DCONTENTPROTECTIONCAPS
{
DWORD Caps;
GUID KeyExchangeType;
UINT BufferAlignmentStart;
UINT BlockAlignmentSize;
ULONGLONG ProtectedMemorySize;
} D3DCONTENTPROTECTIONCAPS;
#define D3DCPCAPS_SOFTWARE 0x00000001
#define D3DCPCAPS_HARDWARE 0x00000002
#define D3DCPCAPS_PROTECTIONALWAYSON 0x00000004
#define D3DCPCAPS_PARTIALDECRYPTION 0x00000008
#define D3DCPCAPS_CONTENTKEY 0x00000010
#define D3DCPCAPS_FRESHENSESSIONKEY 0x00000020
#define D3DCPCAPS_ENCRYPTEDREADBACK 0x00000040
#define D3DCPCAPS_ENCRYPTEDREADBACKKEY 0x00000080
#define D3DCPCAPS_SEQUENTIAL_CTR_IV 0x00000100
#define D3DCPCAPS_ENCRYPTSLICEDATAONLY 0x00000200
DEFINE_GUID(D3DCRYPTOTYPE_AES128_CTR,
0x9b6bd711, 0x4f74, 0x41c9, 0x9e, 0x7b, 0xb, 0xe2, 0xd7, 0xd9, 0x3b, 0x4f);
DEFINE_GUID(D3DCRYPTOTYPE_PROPRIETARY,
0xab4e9afd, 0x1d1c, 0x46e6, 0xa7, 0x2f, 0x8, 0x69, 0x91, 0x7b, 0xd, 0xe8);
DEFINE_GUID(D3DKEYEXCHANGE_RSAES_OAEP,
0xc1949895, 0xd72a, 0x4a1d, 0x8e, 0x5d, 0xed, 0x85, 0x7d, 0x17, 0x15, 0x20);
DEFINE_GUID(D3DKEYEXCHANGE_DXVA,
0x43d3775c, 0x38e5, 0x4924, 0x8d, 0x86, 0xd3, 0xfc, 0xcf, 0x15, 0x3e, 0x9b);
#endif // !D3D_DISABLE_9EX
/* -- D3D9Ex only */
typedef struct _D3DCAPS9
{
/* Device Info */
D3DDEVTYPE DeviceType;
UINT AdapterOrdinal;
/* Caps from DX7 Draw */
DWORD Caps;
DWORD Caps2;
DWORD Caps3;
DWORD PresentationIntervals;
/* Cursor Caps */
DWORD CursorCaps;
/* 3D Device Caps */
DWORD DevCaps;
DWORD PrimitiveMiscCaps;
DWORD RasterCaps;
DWORD ZCmpCaps;
DWORD SrcBlendCaps;
DWORD DestBlendCaps;
DWORD AlphaCmpCaps;
DWORD ShadeCaps;
DWORD TextureCaps;
DWORD TextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DTexture9's
DWORD CubeTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DCubeTexture9's
DWORD VolumeTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DVolumeTexture9's
DWORD TextureAddressCaps; // D3DPTADDRESSCAPS for IDirect3DTexture9's
DWORD VolumeTextureAddressCaps; // D3DPTADDRESSCAPS for IDirect3DVolumeTexture9's
DWORD LineCaps; // D3DLINECAPS
DWORD MaxTextureWidth, MaxTextureHeight;
DWORD MaxVolumeExtent;
DWORD MaxTextureRepeat;
DWORD MaxTextureAspectRatio;
DWORD MaxAnisotropy;
float MaxVertexW;
float GuardBandLeft;
float GuardBandTop;
float GuardBandRight;
float GuardBandBottom;
float ExtentsAdjust;
DWORD StencilCaps;
DWORD FVFCaps;
DWORD TextureOpCaps;
DWORD MaxTextureBlendStages;
DWORD MaxSimultaneousTextures;
DWORD VertexProcessingCaps;
DWORD MaxActiveLights;
DWORD MaxUserClipPlanes;
DWORD MaxVertexBlendMatrices;
DWORD MaxVertexBlendMatrixIndex;
float MaxPointSize;
DWORD MaxPrimitiveCount; // max number of primitives per DrawPrimitive call
DWORD MaxVertexIndex;
DWORD MaxStreams;
DWORD MaxStreamStride; // max stride for SetStreamSource
DWORD VertexShaderVersion;
DWORD MaxVertexShaderConst; // number of vertex shader constant registers
DWORD PixelShaderVersion;
float PixelShader1xMaxValue; // max value storable in registers of ps.1.x shaders
// Here are the DX9 specific ones
DWORD DevCaps2;
float MaxNpatchTessellationLevel;
DWORD Reserved5;
UINT MasterAdapterOrdinal; // ordinal of master adaptor for adapter group
UINT AdapterOrdinalInGroup; // ordinal inside the adapter group
UINT NumberOfAdaptersInGroup; // number of adapters in this adapter group (only if master)
DWORD DeclTypes; // Data types, supported in vertex declarations
DWORD NumSimultaneousRTs; // Will be at least 1
DWORD StretchRectFilterCaps; // Filter caps supported by StretchRect
D3DVSHADERCAPS2_0 VS20Caps;
D3DPSHADERCAPS2_0 PS20Caps;
DWORD VertexTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DTexture9's for texture, used in vertex shaders
DWORD MaxVShaderInstructionsExecuted; // maximum number of vertex shader instructions that can be executed
DWORD MaxPShaderInstructionsExecuted; // maximum number of pixel shader instructions that can be executed
DWORD MaxVertexShader30InstructionSlots;
DWORD MaxPixelShader30InstructionSlots;
} D3DCAPS9;
//
// BIT DEFINES FOR D3DCAPS9 DWORD MEMBERS
//
//
// Caps
//
#define D3DCAPS_OVERLAY 0x00000800L
#define D3DCAPS_READ_SCANLINE 0x00020000L
//
// Caps2
//
#define D3DCAPS2_FULLSCREENGAMMA 0x00020000L
#define D3DCAPS2_CANCALIBRATEGAMMA 0x00100000L
#define D3DCAPS2_RESERVED 0x02000000L
#define D3DCAPS2_CANMANAGERESOURCE 0x10000000L
#define D3DCAPS2_DYNAMICTEXTURES 0x20000000L
#define D3DCAPS2_CANAUTOGENMIPMAP 0x40000000L
/* D3D9Ex only -- */
#if !defined(D3D_DISABLE_9EX)
#define D3DCAPS2_CANSHARERESOURCE 0x80000000L
#endif // !D3D_DISABLE_9EX
/* -- D3D9Ex only */
//
// Caps3
//
#define D3DCAPS3_RESERVED 0x8000001fL
// Indicates that the device can respect the ALPHABLENDENABLE render state
// when fullscreen while using the FLIP or DISCARD swap effect.
// COPY and COPYVSYNC swap effects work whether or not this flag is set.
#define D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD 0x00000020L
// Indicates that the device can perform a gamma correction from
// a windowed back buffer containing linear content to the sRGB desktop.
#define D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION 0x00000080L
#define D3DCAPS3_COPY_TO_VIDMEM 0x00000100L /* Device can acclerate copies from sysmem to local vidmem */
#define D3DCAPS3_COPY_TO_SYSTEMMEM 0x00000200L /* Device can acclerate copies from local vidmem to sysmem */
#define D3DCAPS3_DXVAHD 0x00000400L
#define D3DCAPS3_DXVAHD_LIMITED 0x00000800L
//
// PresentationIntervals
//
#define D3DPRESENT_INTERVAL_DEFAULT 0x00000000L
#define D3DPRESENT_INTERVAL_ONE 0x00000001L
#define D3DPRESENT_INTERVAL_TWO 0x00000002L
#define D3DPRESENT_INTERVAL_THREE 0x00000004L
#define D3DPRESENT_INTERVAL_FOUR 0x00000008L
#define D3DPRESENT_INTERVAL_IMMEDIATE 0x80000000L
//
// CursorCaps
//
// Driver supports HW color cursor in at least hi-res modes(height >=400)
#define D3DCURSORCAPS_COLOR 0x00000001L
// Driver supports HW cursor also in low-res modes(height < 400)
#define D3DCURSORCAPS_LOWRES 0x00000002L
//
// DevCaps
//
#define D3DDEVCAPS_EXECUTESYSTEMMEMORY 0x00000010L /* Device can use execute buffers from system memory */
#define D3DDEVCAPS_EXECUTEVIDEOMEMORY 0x00000020L /* Device can use execute buffers from video memory */
#define D3DDEVCAPS_TLVERTEXSYSTEMMEMORY 0x00000040L /* Device can use TL buffers from system memory */
#define D3DDEVCAPS_TLVERTEXVIDEOMEMORY 0x00000080L /* Device can use TL buffers from video memory */
#define D3DDEVCAPS_TEXTURESYSTEMMEMORY 0x00000100L /* Device can texture from system memory */
#define D3DDEVCAPS_TEXTUREVIDEOMEMORY 0x00000200L /* Device can texture from device memory */
#define D3DDEVCAPS_DRAWPRIMTLVERTEX 0x00000400L /* Device can draw TLVERTEX primitives */
#define D3DDEVCAPS_CANRENDERAFTERFLIP 0x00000800L /* Device can render without waiting for flip to complete */
#define D3DDEVCAPS_TEXTURENONLOCALVIDMEM 0x00001000L /* Device can texture from nonlocal video memory */
#define D3DDEVCAPS_DRAWPRIMITIVES2 0x00002000L /* Device can support DrawPrimitives2 */
#define D3DDEVCAPS_SEPARATETEXTUREMEMORIES 0x00004000L /* Device is texturing from separate memory pools */
#define D3DDEVCAPS_DRAWPRIMITIVES2EX 0x00008000L /* Device can support Extended DrawPrimitives2 i.e. DX7 compliant driver*/
#define D3DDEVCAPS_HWTRANSFORMANDLIGHT 0x00010000L /* Device can support transformation and lighting in hardware and DRAWPRIMITIVES2EX must be also */
#define D3DDEVCAPS_CANBLTSYSTONONLOCAL 0x00020000L /* Device supports a Tex Blt from system memory to non-local vidmem */
#define D3DDEVCAPS_HWRASTERIZATION 0x00080000L /* Device has HW acceleration for rasterization */
#define D3DDEVCAPS_PUREDEVICE 0x00100000L /* Device supports D3DCREATE_PUREDEVICE */
#define D3DDEVCAPS_QUINTICRTPATCHES 0x00200000L /* Device supports quintic Beziers and BSplines */
#define D3DDEVCAPS_RTPATCHES 0x00400000L /* Device supports Rect and Tri patches */
#define D3DDEVCAPS_RTPATCHHANDLEZERO 0x00800000L /* Indicates that RT Patches may be drawn efficiently using handle 0 */
#define D3DDEVCAPS_NPATCHES 0x01000000L /* Device supports N-Patches */
//
// PrimitiveMiscCaps
//
#define D3DPMISCCAPS_MASKZ 0x00000002L
#define D3DPMISCCAPS_CULLNONE 0x00000010L
#define D3DPMISCCAPS_CULLCW 0x00000020L
#define D3DPMISCCAPS_CULLCCW 0x00000040L
#define D3DPMISCCAPS_COLORWRITEENABLE 0x00000080L
#define D3DPMISCCAPS_CLIPPLANESCALEDPOINTS 0x00000100L /* Device correctly clips scaled points to clip planes */
#define D3DPMISCCAPS_CLIPTLVERTS 0x00000200L /* device will clip post-transformed vertex primitives */
#define D3DPMISCCAPS_TSSARGTEMP 0x00000400L /* device supports D3DTA_TEMP for temporary register */
#define D3DPMISCCAPS_BLENDOP 0x00000800L /* device supports D3DRS_BLENDOP */
#define D3DPMISCCAPS_NULLREFERENCE 0x00001000L /* Reference Device that doesnt render */
#define D3DPMISCCAPS_INDEPENDENTWRITEMASKS 0x00004000L /* Device supports independent write masks for MET or MRT */
#define D3DPMISCCAPS_PERSTAGECONSTANT 0x00008000L /* Device supports per-stage constants */
#define D3DPMISCCAPS_FOGANDSPECULARALPHA 0x00010000L /* Device supports separate fog and specular alpha (many devices
use the specular alpha channel to store fog factor) */
#define D3DPMISCCAPS_SEPARATEALPHABLEND 0x00020000L /* Device supports separate blend settings for the alpha channel */
#define D3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS 0x00040000L /* Device supports different bit depths for MRT */
#define D3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING 0x00080000L /* Device supports post-pixel shader operations for MRT */
#define D3DPMISCCAPS_FOGVERTEXCLAMPED 0x00100000L /* Device clamps fog blend factor per vertex */
/* D3D9Ex only -- */
#if !defined(D3D_DISABLE_9EX)
#define D3DPMISCCAPS_POSTBLENDSRGBCONVERT 0x00200000L /* Indicates device can perform conversion to sRGB after blending. */
#endif // !D3D_DISABLE_9EX
/* -- D3D9Ex only */
//
// LineCaps
//
#define D3DLINECAPS_TEXTURE 0x00000001L
#define D3DLINECAPS_ZTEST 0x00000002L
#define D3DLINECAPS_BLEND 0x00000004L
#define D3DLINECAPS_ALPHACMP 0x00000008L
#define D3DLINECAPS_FOG 0x00000010L
#define D3DLINECAPS_ANTIALIAS 0x00000020L
//
// RasterCaps
//
#define D3DPRASTERCAPS_DITHER 0x00000001L
#define D3DPRASTERCAPS_ZTEST 0x00000010L
#define D3DPRASTERCAPS_FOGVERTEX 0x00000080L
#define D3DPRASTERCAPS_FOGTABLE 0x00000100L
#define D3DPRASTERCAPS_MIPMAPLODBIAS 0x00002000L
#define D3DPRASTERCAPS_ZBUFFERLESSHSR 0x00008000L
#define D3DPRASTERCAPS_FOGRANGE 0x00010000L
#define D3DPRASTERCAPS_ANISOTROPY 0x00020000L
#define D3DPRASTERCAPS_WBUFFER 0x00040000L
#define D3DPRASTERCAPS_WFOG 0x00100000L
#define D3DPRASTERCAPS_ZFOG 0x00200000L
#define D3DPRASTERCAPS_COLORPERSPECTIVE 0x00400000L /* Device iterates colors perspective correct */
#define D3DPRASTERCAPS_SCISSORTEST 0x01000000L
#define D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS 0x02000000L
#define D3DPRASTERCAPS_DEPTHBIAS 0x04000000L
#define D3DPRASTERCAPS_MULTISAMPLE_TOGGLE 0x08000000L
//
// ZCmpCaps, AlphaCmpCaps
//
#define D3DPCMPCAPS_NEVER 0x00000001L
#define D3DPCMPCAPS_LESS 0x00000002L
#define D3DPCMPCAPS_EQUAL 0x00000004L
#define D3DPCMPCAPS_LESSEQUAL 0x00000008L
#define D3DPCMPCAPS_GREATER 0x00000010L
#define D3DPCMPCAPS_NOTEQUAL 0x00000020L
#define D3DPCMPCAPS_GREATEREQUAL 0x00000040L
#define D3DPCMPCAPS_ALWAYS 0x00000080L
//
// SourceBlendCaps, DestBlendCaps
//
#define D3DPBLENDCAPS_ZERO 0x00000001L
#define D3DPBLENDCAPS_ONE 0x00000002L
#define D3DPBLENDCAPS_SRCCOLOR 0x00000004L
#define D3DPBLENDCAPS_INVSRCCOLOR 0x00000008L
#define D3DPBLENDCAPS_SRCALPHA 0x00000010L
#define D3DPBLENDCAPS_INVSRCALPHA 0x00000020L
#define D3DPBLENDCAPS_DESTALPHA 0x00000040L
#define D3DPBLENDCAPS_INVDESTALPHA 0x00000080L
#define D3DPBLENDCAPS_DESTCOLOR 0x00000100L
#define D3DPBLENDCAPS_INVDESTCOLOR 0x00000200L
#define D3DPBLENDCAPS_SRCALPHASAT 0x00000400L
#define D3DPBLENDCAPS_BOTHSRCALPHA 0x00000800L
#define D3DPBLENDCAPS_BOTHINVSRCALPHA 0x00001000L
#define D3DPBLENDCAPS_BLENDFACTOR 0x00002000L /* Supports both D3DBLEND_BLENDFACTOR and D3DBLEND_INVBLENDFACTOR */
/* D3D9Ex only -- */
#if !defined(D3D_DISABLE_9EX)
#define D3DPBLENDCAPS_SRCCOLOR2 0x00004000L
#define D3DPBLENDCAPS_INVSRCCOLOR2 0x00008000L
#endif // !D3D_DISABLE_9EX
/* -- D3D9Ex only */
//
// ShadeCaps
//
#define D3DPSHADECAPS_COLORGOURAUDRGB 0x00000008L
#define D3DPSHADECAPS_SPECULARGOURAUDRGB 0x00000200L
#define D3DPSHADECAPS_ALPHAGOURAUDBLEND 0x00004000L
#define D3DPSHADECAPS_FOGGOURAUD 0x00080000L
//
// TextureCaps
//
#define D3DPTEXTURECAPS_PERSPECTIVE 0x00000001L /* Perspective-correct texturing is supported */
#define D3DPTEXTURECAPS_POW2 0x00000002L /* Power-of-2 texture dimensions are required - applies to non-Cube/Volume textures only. */
#define D3DPTEXTURECAPS_ALPHA 0x00000004L /* Alpha in texture pixels is supported */
#define D3DPTEXTURECAPS_SQUAREONLY 0x00000020L /* Only square textures are supported */
#define D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE 0x00000040L /* Texture indices are not scaled by the texture size prior to interpolation */
#define D3DPTEXTURECAPS_ALPHAPALETTE 0x00000080L /* Device can draw alpha from texture palettes */
// Device can use non-POW2 textures if:
// 1) D3DTEXTURE_ADDRESS is set to CLAMP for this texture's stage
// 2) D3DRS_WRAP(N) is zero for this texture's coordinates
// 3) mip mapping is not enabled (use magnification filter only)
#define D3DPTEXTURECAPS_NONPOW2CONDITIONAL 0x00000100L
#define D3DPTEXTURECAPS_PROJECTED 0x00000400L /* Device can do D3DTTFF_PROJECTED */
#define D3DPTEXTURECAPS_CUBEMAP 0x00000800L /* Device can do cubemap textures */
#define D3DPTEXTURECAPS_VOLUMEMAP 0x00002000L /* Device can do volume textures */
#define D3DPTEXTURECAPS_MIPMAP 0x00004000L /* Device can do mipmapped textures */
#define D3DPTEXTURECAPS_MIPVOLUMEMAP 0x00008000L /* Device can do mipmapped volume textures */
#define D3DPTEXTURECAPS_MIPCUBEMAP 0x00010000L /* Device can do mipmapped cube maps */
#define D3DPTEXTURECAPS_CUBEMAP_POW2 0x00020000L /* Device requires that cubemaps be power-of-2 dimension */
#define D3DPTEXTURECAPS_VOLUMEMAP_POW2 0x00040000L /* Device requires that volume maps be power-of-2 dimension */
#define D3DPTEXTURECAPS_NOPROJECTEDBUMPENV 0x00200000L /* Device does not support projected bump env lookup operation
in programmable and fixed function pixel shaders */
//
// TextureFilterCaps, StretchRectFilterCaps
//
#define D3DPTFILTERCAPS_MINFPOINT 0x00000100L /* Min Filter */
#define D3DPTFILTERCAPS_MINFLINEAR 0x00000200L
#define D3DPTFILTERCAPS_MINFANISOTROPIC 0x00000400L
#define D3DPTFILTERCAPS_MINFPYRAMIDALQUAD 0x00000800L
#define D3DPTFILTERCAPS_MINFGAUSSIANQUAD 0x00001000L
#define D3DPTFILTERCAPS_MIPFPOINT 0x00010000L /* Mip Filter */
#define D3DPTFILTERCAPS_MIPFLINEAR 0x00020000L
/* D3D9Ex only -- */
#if !defined(D3D_DISABLE_9EX)
#define D3DPTFILTERCAPS_CONVOLUTIONMONO 0x00040000L /* Min and Mag for the convolution mono filter */
#endif // !D3D_DISABLE_9EX
/* -- D3D9Ex only */
#define D3DPTFILTERCAPS_MAGFPOINT 0x01000000L /* Mag Filter */
#define D3DPTFILTERCAPS_MAGFLINEAR 0x02000000L
#define D3DPTFILTERCAPS_MAGFANISOTROPIC 0x04000000L
#define D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD 0x08000000L
#define D3DPTFILTERCAPS_MAGFGAUSSIANQUAD 0x10000000L
//
// TextureAddressCaps
//
#define D3DPTADDRESSCAPS_WRAP 0x00000001L
#define D3DPTADDRESSCAPS_MIRROR 0x00000002L
#define D3DPTADDRESSCAPS_CLAMP 0x00000004L
#define D3DPTADDRESSCAPS_BORDER 0x00000008L
#define D3DPTADDRESSCAPS_INDEPENDENTUV 0x00000010L
#define D3DPTADDRESSCAPS_MIRRORONCE 0x00000020L
//
// StencilCaps
//
#define D3DSTENCILCAPS_KEEP 0x00000001L
#define D3DSTENCILCAPS_ZERO 0x00000002L
#define D3DSTENCILCAPS_REPLACE 0x00000004L
#define D3DSTENCILCAPS_INCRSAT 0x00000008L
#define D3DSTENCILCAPS_DECRSAT 0x00000010L
#define D3DSTENCILCAPS_INVERT 0x00000020L
#define D3DSTENCILCAPS_INCR 0x00000040L
#define D3DSTENCILCAPS_DECR 0x00000080L
#define D3DSTENCILCAPS_TWOSIDED 0x00000100L
//
// TextureOpCaps
//
#define D3DTEXOPCAPS_DISABLE 0x00000001L
#define D3DTEXOPCAPS_SELECTARG1 0x00000002L
#define D3DTEXOPCAPS_SELECTARG2 0x00000004L
#define D3DTEXOPCAPS_MODULATE 0x00000008L
#define D3DTEXOPCAPS_MODULATE2X 0x00000010L
#define D3DTEXOPCAPS_MODULATE4X 0x00000020L
#define D3DTEXOPCAPS_ADD 0x00000040L
#define D3DTEXOPCAPS_ADDSIGNED 0x00000080L
#define D3DTEXOPCAPS_ADDSIGNED2X 0x00000100L
#define D3DTEXOPCAPS_SUBTRACT 0x00000200L
#define D3DTEXOPCAPS_ADDSMOOTH 0x00000400L
#define D3DTEXOPCAPS_BLENDDIFFUSEALPHA 0x00000800L
#define D3DTEXOPCAPS_BLENDTEXTUREALPHA 0x00001000L
#define D3DTEXOPCAPS_BLENDFACTORALPHA 0x00002000L
#define D3DTEXOPCAPS_BLENDTEXTUREALPHAPM 0x00004000L
#define D3DTEXOPCAPS_BLENDCURRENTALPHA 0x00008000L
#define D3DTEXOPCAPS_PREMODULATE 0x00010000L
#define D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR 0x00020000L
#define D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA 0x00040000L
#define D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR 0x00080000L
#define D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA 0x00100000L
#define D3DTEXOPCAPS_BUMPENVMAP 0x00200000L
#define D3DTEXOPCAPS_BUMPENVMAPLUMINANCE 0x00400000L
#define D3DTEXOPCAPS_DOTPRODUCT3 0x00800000L
#define D3DTEXOPCAPS_MULTIPLYADD 0x01000000L
#define D3DTEXOPCAPS_LERP 0x02000000L
//
// FVFCaps
//
#define D3DFVFCAPS_TEXCOORDCOUNTMASK 0x0000ffffL /* mask for texture coordinate count field */
#define D3DFVFCAPS_DONOTSTRIPELEMENTS 0x00080000L /* Device prefers that vertex elements not be stripped */
#define D3DFVFCAPS_PSIZE 0x00100000L /* Device can receive point size */
//
// VertexProcessingCaps
//
#define D3DVTXPCAPS_TEXGEN 0x00000001L /* device can do texgen */
#define D3DVTXPCAPS_MATERIALSOURCE7 0x00000002L /* device can do DX7-level colormaterialsource ops */
#define D3DVTXPCAPS_DIRECTIONALLIGHTS 0x00000008L /* device can do directional lights */
#define D3DVTXPCAPS_POSITIONALLIGHTS 0x00000010L /* device can do positional lights (includes point and spot) */
#define D3DVTXPCAPS_LOCALVIEWER 0x00000020L /* device can do local viewer */
#define D3DVTXPCAPS_TWEENING 0x00000040L /* device can do vertex tweening */
#define D3DVTXPCAPS_TEXGEN_SPHEREMAP 0x00000100L /* device supports D3DTSS_TCI_SPHEREMAP */
#define D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER 0x00000200L /* device does not support TexGen in non-local
viewer mode */
//
// DevCaps2
//
#define D3DDEVCAPS2_STREAMOFFSET 0x00000001L /* Device supports offsets in streams. Must be set by DX9 drivers */
#define D3DDEVCAPS2_DMAPNPATCH 0x00000002L /* Device supports displacement maps for N-Patches*/
#define D3DDEVCAPS2_ADAPTIVETESSRTPATCH 0x00000004L /* Device supports adaptive tesselation of RT-patches*/
#define D3DDEVCAPS2_ADAPTIVETESSNPATCH 0x00000008L /* Device supports adaptive tesselation of N-patches*/
#define D3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES 0x00000010L /* Device supports StretchRect calls with a texture as the source*/
#define D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH 0x00000020L /* Device supports presampled displacement maps for N-Patches */
#define D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET 0x00000040L /* Vertex elements in a vertex declaration can share the same stream offset */
//
// DeclTypes
//
#define D3DDTCAPS_UBYTE4 0x00000001L
#define D3DDTCAPS_UBYTE4N 0x00000002L
#define D3DDTCAPS_SHORT2N 0x00000004L
#define D3DDTCAPS_SHORT4N 0x00000008L
#define D3DDTCAPS_USHORT2N 0x00000010L
#define D3DDTCAPS_USHORT4N 0x00000020L
#define D3DDTCAPS_UDEC3 0x00000040L
#define D3DDTCAPS_DEC3N 0x00000080L
#define D3DDTCAPS_FLOAT16_2 0x00000100L
#define D3DDTCAPS_FLOAT16_4 0x00000200L
#pragma pack()
#endif /* (DIRECT3D_VERSION >= 0x0900) */
#endif /* _d3d9CAPS_H_ */

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,586 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// File: D3DCompiler.h
// Content: D3D Compilation Types and APIs
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __D3DCOMPILER_H__
#define __D3DCOMPILER_H__
#include <winapifamily.h>
// Current name of the DLL shipped in the same SDK as this header.
#define D3DCOMPILER_DLL_W L"d3dcompiler_47.dll"
#define D3DCOMPILER_DLL_A "d3dcompiler_47.dll"
// Current HLSL compiler version.
#define D3D_COMPILER_VERSION 47
#ifdef UNICODE
#define D3DCOMPILER_DLL D3DCOMPILER_DLL_W
#else
#define D3DCOMPILER_DLL D3DCOMPILER_DLL_A
#endif
#include "d3d11shader.h"
#include "d3d12shader.h"
//////////////////////////////////////////////////////////////////////////////
// APIs //////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
extern "C" {
#endif //__cplusplus
// BK - pragma region Application Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
//----------------------------------------------------------------------------
// D3DReadFileToBlob:
// -----------------
// Simple helper routine to read a file on disk into memory
// for passing to other routines in this API.
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DReadFileToBlob(_In_ LPCWSTR pFileName,
_Out_ ID3DBlob** ppContents);
//----------------------------------------------------------------------------
// D3DWriteBlobToFile:
// ------------------
// Simple helper routine to write a memory blob to a file on disk.
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DWriteBlobToFile(_In_ ID3DBlob* pBlob,
_In_ LPCWSTR pFileName,
_In_ BOOL bOverwrite);
//----------------------------------------------------------------------------
// D3DCOMPILE flags:
// -----------------
// D3DCOMPILE_DEBUG
// Insert debug file/line/type/symbol information.
//
// D3DCOMPILE_SKIP_VALIDATION
// Do not validate the generated code against known capabilities and
// constraints. This option is only recommended when compiling shaders
// you KNOW will work. (ie. have compiled before without this option.)
// Shaders are always validated by D3D before they are set to the device.
//
// D3DCOMPILE_SKIP_OPTIMIZATION
// Instructs the compiler to skip optimization steps during code generation.
// Unless you are trying to isolate a problem in your code using this option
// is not recommended.
//
// D3DCOMPILE_PACK_MATRIX_ROW_MAJOR
// Unless explicitly specified, matrices will be packed in row-major order
// on input and output from the shader.
//
// D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR
// Unless explicitly specified, matrices will be packed in column-major
// order on input and output from the shader. This is generally more
// efficient, since it allows vector-matrix multiplication to be performed
// using a series of dot-products.
//
// D3DCOMPILE_PARTIAL_PRECISION
// Force all computations in resulting shader to occur at partial precision.
// This may result in faster evaluation of shaders on some hardware.
//
// D3DCOMPILE_FORCE_VS_SOFTWARE_NO_OPT
// Force compiler to compile against the next highest available software
// target for vertex shaders. This flag also turns optimizations off,
// and debugging on.
//
// D3DCOMPILE_FORCE_PS_SOFTWARE_NO_OPT
// Force compiler to compile against the next highest available software
// target for pixel shaders. This flag also turns optimizations off,
// and debugging on.
//
// D3DCOMPILE_NO_PRESHADER
// Disables Preshaders. Using this flag will cause the compiler to not
// pull out static expression for evaluation on the host cpu
//
// D3DCOMPILE_AVOID_FLOW_CONTROL
// Hint compiler to avoid flow-control constructs where possible.
//
// D3DCOMPILE_PREFER_FLOW_CONTROL
// Hint compiler to prefer flow-control constructs where possible.
//
// D3DCOMPILE_ENABLE_STRICTNESS
// By default, the HLSL/Effect compilers are not strict on deprecated syntax.
// Specifying this flag enables the strict mode. Deprecated syntax may be
// removed in a future release, and enabling syntax is a good way to make
// sure your shaders comply to the latest spec.
//
// D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY
// This enables older shaders to compile to 4_0 targets.
//
// D3DCOMPILE_DEBUG_NAME_FOR_SOURCE
// This enables a debug name to be generated based on source information.
// It requires D3DCOMPILE_DEBUG to be set, and is exclusive with
// D3DCOMPILE_DEBUG_NAME_FOR_BINARY.
//
// D3DCOMPILE_DEBUG_NAME_FOR_BINARY
// This enables a debug name to be generated based on compiled information.
// It requires D3DCOMPILE_DEBUG to be set, and is exclusive with
// D3DCOMPILE_DEBUG_NAME_FOR_SOURCE.
//
//----------------------------------------------------------------------------
#define D3DCOMPILE_DEBUG (1 << 0)
#define D3DCOMPILE_SKIP_VALIDATION (1 << 1)
#define D3DCOMPILE_SKIP_OPTIMIZATION (1 << 2)
#define D3DCOMPILE_PACK_MATRIX_ROW_MAJOR (1 << 3)
#define D3DCOMPILE_PACK_MATRIX_COLUMN_MAJOR (1 << 4)
#define D3DCOMPILE_PARTIAL_PRECISION (1 << 5)
#define D3DCOMPILE_FORCE_VS_SOFTWARE_NO_OPT (1 << 6)
#define D3DCOMPILE_FORCE_PS_SOFTWARE_NO_OPT (1 << 7)
#define D3DCOMPILE_NO_PRESHADER (1 << 8)
#define D3DCOMPILE_AVOID_FLOW_CONTROL (1 << 9)
#define D3DCOMPILE_PREFER_FLOW_CONTROL (1 << 10)
#define D3DCOMPILE_ENABLE_STRICTNESS (1 << 11)
#define D3DCOMPILE_ENABLE_BACKWARDS_COMPATIBILITY (1 << 12)
#define D3DCOMPILE_IEEE_STRICTNESS (1 << 13)
#define D3DCOMPILE_OPTIMIZATION_LEVEL0 (1 << 14)
#define D3DCOMPILE_OPTIMIZATION_LEVEL1 0
#define D3DCOMPILE_OPTIMIZATION_LEVEL2 ((1 << 14) | (1 << 15))
#define D3DCOMPILE_OPTIMIZATION_LEVEL3 (1 << 15)
#define D3DCOMPILE_RESERVED16 (1 << 16)
#define D3DCOMPILE_RESERVED17 (1 << 17)
#define D3DCOMPILE_WARNINGS_ARE_ERRORS (1 << 18)
#define D3DCOMPILE_RESOURCES_MAY_ALIAS (1 << 19)
#define D3DCOMPILE_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES (1 << 20)
#define D3DCOMPILE_ALL_RESOURCES_BOUND (1 << 21)
#define D3DCOMPILE_DEBUG_NAME_FOR_SOURCE (1 << 22)
#define D3DCOMPILE_DEBUG_NAME_FOR_BINARY (1 << 23)
//----------------------------------------------------------------------------
// D3DCOMPILE_EFFECT flags:
// -------------------------------------
// These flags are passed in when creating an effect, and affect
// either compilation behavior or runtime effect behavior
//
// D3DCOMPILE_EFFECT_CHILD_EFFECT
// Compile this .fx file to a child effect. Child effects have no
// initializers for any shared values as these are initialied in the
// master effect (pool).
//
// D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS
// By default, performance mode is enabled. Performance mode
// disallows mutable state objects by preventing non-literal
// expressions from appearing in state object definitions.
// Specifying this flag will disable the mode and allow for mutable
// state objects.
//
//----------------------------------------------------------------------------
#define D3DCOMPILE_EFFECT_CHILD_EFFECT (1 << 0)
#define D3DCOMPILE_EFFECT_ALLOW_SLOW_OPS (1 << 1)
//----------------------------------------------------------------------------
// D3DCOMPILE Flags2:
// -----------------
// Root signature flags. (passed in Flags2)
#define D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_LATEST 0
#define D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_1_0 (1 << 4)
#define D3DCOMPILE_FLAGS2_FORCE_ROOT_SIGNATURE_1_1 (1 << 5)
//----------------------------------------------------------------------------
// D3DCompile:
// ----------
// Compile source text into bytecode appropriate for the given target.
//----------------------------------------------------------------------------
// D3D_COMPILE_STANDARD_FILE_INCLUDE can be passed for pInclude in any
// API and indicates that a simple default include handler should be
// used. The include handler will include files relative to the
// current directory and files relative to the directory of the initial source
// file. When used with APIs like D3DCompile pSourceName must be a
// file name and the initial relative directory will be derived from it.
#define D3D_COMPILE_STANDARD_FILE_INCLUDE ((ID3DInclude*)(UINT_PTR)1)
HRESULT WINAPI
D3DCompile(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
_In_ SIZE_T SrcDataSize,
_In_opt_ LPCSTR pSourceName,
_In_reads_opt_(_Inexpressible_(pDefines->Name != NULL)) CONST D3D_SHADER_MACRO* pDefines,
_In_opt_ ID3DInclude* pInclude,
_In_opt_ LPCSTR pEntrypoint,
_In_ LPCSTR pTarget,
_In_ UINT Flags1,
_In_ UINT Flags2,
_Out_ ID3DBlob** ppCode,
_Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorMsgs);
typedef HRESULT (WINAPI *pD3DCompile)
(LPCVOID pSrcData,
SIZE_T SrcDataSize,
LPCSTR pFileName,
CONST D3D_SHADER_MACRO* pDefines,
ID3DInclude* pInclude,
LPCSTR pEntrypoint,
LPCSTR pTarget,
UINT Flags1,
UINT Flags2,
ID3DBlob** ppCode,
ID3DBlob** ppErrorMsgs);
#define D3DCOMPILE_SECDATA_MERGE_UAV_SLOTS 0x00000001
#define D3DCOMPILE_SECDATA_PRESERVE_TEMPLATE_SLOTS 0x00000002
#define D3DCOMPILE_SECDATA_REQUIRE_TEMPLATE_MATCH 0x00000004
HRESULT WINAPI
D3DCompile2(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
_In_ SIZE_T SrcDataSize,
_In_opt_ LPCSTR pSourceName,
_In_reads_opt_(_Inexpressible_(pDefines->Name != NULL)) CONST D3D_SHADER_MACRO* pDefines,
_In_opt_ ID3DInclude* pInclude,
_In_ LPCSTR pEntrypoint,
_In_ LPCSTR pTarget,
_In_ UINT Flags1,
_In_ UINT Flags2,
_In_ UINT SecondaryDataFlags,
_In_reads_bytes_opt_(SecondaryDataSize) LPCVOID pSecondaryData,
_In_ SIZE_T SecondaryDataSize,
_Out_ ID3DBlob** ppCode,
_Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorMsgs);
HRESULT WINAPI
D3DCompileFromFile(_In_ LPCWSTR pFileName,
_In_reads_opt_(_Inexpressible_(pDefines->Name != NULL)) CONST D3D_SHADER_MACRO* pDefines,
_In_opt_ ID3DInclude* pInclude,
_In_ LPCSTR pEntrypoint,
_In_ LPCSTR pTarget,
_In_ UINT Flags1,
_In_ UINT Flags2,
_Out_ ID3DBlob** ppCode,
_Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorMsgs);
//----------------------------------------------------------------------------
// D3DPreprocess:
// -------------
// Process source text with the compiler's preprocessor and return
// the resulting text.
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DPreprocess(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
_In_ SIZE_T SrcDataSize,
_In_opt_ LPCSTR pSourceName,
_In_opt_ CONST D3D_SHADER_MACRO* pDefines,
_In_opt_ ID3DInclude* pInclude,
_Out_ ID3DBlob** ppCodeText,
_Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorMsgs);
typedef HRESULT (WINAPI *pD3DPreprocess)
(LPCVOID pSrcData,
SIZE_T SrcDataSize,
LPCSTR pFileName,
CONST D3D_SHADER_MACRO* pDefines,
ID3DInclude* pInclude,
ID3DBlob** ppCodeText,
ID3DBlob** ppErrorMsgs);
//----------------------------------------------------------------------------
// D3DGetDebugInfo:
// -----------------------
// Gets shader debug info. Debug info is generated by D3DCompile and is
// embedded in the body of the shader.
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DGetDebugInfo(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
_In_ SIZE_T SrcDataSize,
_Out_ ID3DBlob** ppDebugInfo);
//----------------------------------------------------------------------------
// D3DReflect:
// ----------
// Shader code contains metadata that can be inspected via the
// reflection APIs.
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DReflect(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
_In_ SIZE_T SrcDataSize,
_In_ REFIID pInterface,
_Out_ void** ppReflector);
//----------------------------------------------------------------------------
// D3DReflectLibrary:
// ----------
// Library code contains metadata that can be inspected via the library
// reflection APIs.
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DReflectLibrary(__in_bcount(SrcDataSize) LPCVOID pSrcData,
__in SIZE_T SrcDataSize,
__in REFIID riid,
__out LPVOID * ppReflector);
//----------------------------------------------------------------------------
// D3DDisassemble:
// ----------------------
// Takes a binary shader and returns a buffer containing text assembly.
//----------------------------------------------------------------------------
#define D3D_DISASM_ENABLE_COLOR_CODE 0x00000001
#define D3D_DISASM_ENABLE_DEFAULT_VALUE_PRINTS 0x00000002
#define D3D_DISASM_ENABLE_INSTRUCTION_NUMBERING 0x00000004
#define D3D_DISASM_ENABLE_INSTRUCTION_CYCLE 0x00000008
#define D3D_DISASM_DISABLE_DEBUG_INFO 0x00000010
#define D3D_DISASM_ENABLE_INSTRUCTION_OFFSET 0x00000020
#define D3D_DISASM_INSTRUCTION_ONLY 0x00000040
#define D3D_DISASM_PRINT_HEX_LITERALS 0x00000080
HRESULT WINAPI
D3DDisassemble(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
_In_ SIZE_T SrcDataSize,
_In_ UINT Flags,
_In_opt_ LPCSTR szComments,
_Out_ ID3DBlob** ppDisassembly);
typedef HRESULT (WINAPI *pD3DDisassemble)
(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
_In_ SIZE_T SrcDataSize,
_In_ UINT Flags,
_In_opt_ LPCSTR szComments,
_Out_ ID3DBlob** ppDisassembly);
HRESULT WINAPI
D3DDisassembleRegion(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
_In_ SIZE_T SrcDataSize,
_In_ UINT Flags,
_In_opt_ LPCSTR szComments,
_In_ SIZE_T StartByteOffset,
_In_ SIZE_T NumInsts,
_Out_opt_ SIZE_T* pFinishByteOffset,
_Out_ ID3DBlob** ppDisassembly);
//----------------------------------------------------------------------------
// Shader linking and Function Linking Graph (FLG) APIs
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DCreateLinker(__out interface ID3D11Linker ** ppLinker);
HRESULT WINAPI
D3DLoadModule(_In_ LPCVOID pSrcData,
_In_ SIZE_T cbSrcDataSize,
_Out_ interface ID3D11Module ** ppModule);
HRESULT WINAPI
D3DCreateFunctionLinkingGraph(_In_ UINT uFlags,
_Out_ interface ID3D11FunctionLinkingGraph ** ppFunctionLinkingGraph);
//----------------------------------------------------------------------------
// D3DGetTraceInstructionOffsets:
// -----------------------
// Determines byte offsets for instructions within a shader blob.
// This information is useful for going between trace instruction
// indices and byte offsets that are used in debug information.
//----------------------------------------------------------------------------
#define D3D_GET_INST_OFFSETS_INCLUDE_NON_EXECUTABLE 0x00000001
HRESULT WINAPI
D3DGetTraceInstructionOffsets(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
_In_ SIZE_T SrcDataSize,
_In_ UINT Flags,
_In_ SIZE_T StartInstIndex,
_In_ SIZE_T NumInsts,
_Out_writes_to_opt_(NumInsts, min(NumInsts, *pTotalInsts)) SIZE_T* pOffsets,
_Out_opt_ SIZE_T* pTotalInsts);
//----------------------------------------------------------------------------
// D3DGetInputSignatureBlob:
// -----------------------
// Retrieve the input signature from a compilation result.
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DGetInputSignatureBlob(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
_In_ SIZE_T SrcDataSize,
_Out_ ID3DBlob** ppSignatureBlob);
//----------------------------------------------------------------------------
// D3DGetOutputSignatureBlob:
// -----------------------
// Retrieve the output signature from a compilation result.
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DGetOutputSignatureBlob(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
_In_ SIZE_T SrcDataSize,
_Out_ ID3DBlob** ppSignatureBlob);
//----------------------------------------------------------------------------
// D3DGetInputAndOutputSignatureBlob:
// -----------------------
// Retrieve the input and output signatures from a compilation result.
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DGetInputAndOutputSignatureBlob(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
_In_ SIZE_T SrcDataSize,
_Out_ ID3DBlob** ppSignatureBlob);
//----------------------------------------------------------------------------
// D3DStripShader:
// -----------------------
// Removes unwanted blobs from a compilation result
//----------------------------------------------------------------------------
typedef enum D3DCOMPILER_STRIP_FLAGS
{
D3DCOMPILER_STRIP_REFLECTION_DATA = 0x00000001,
D3DCOMPILER_STRIP_DEBUG_INFO = 0x00000002,
D3DCOMPILER_STRIP_TEST_BLOBS = 0x00000004,
D3DCOMPILER_STRIP_PRIVATE_DATA = 0x00000008,
D3DCOMPILER_STRIP_ROOT_SIGNATURE = 0x00000010,
D3DCOMPILER_STRIP_FORCE_DWORD = 0x7fffffff,
} D3DCOMPILER_STRIP_FLAGS;
HRESULT WINAPI
D3DStripShader(_In_reads_bytes_(BytecodeLength) LPCVOID pShaderBytecode,
_In_ SIZE_T BytecodeLength,
_In_ UINT uStripFlags,
_Out_ ID3DBlob** ppStrippedBlob);
//----------------------------------------------------------------------------
// D3DGetBlobPart:
// -----------------------
// Extracts information from a compilation result.
//----------------------------------------------------------------------------
typedef enum D3D_BLOB_PART
{
D3D_BLOB_INPUT_SIGNATURE_BLOB,
D3D_BLOB_OUTPUT_SIGNATURE_BLOB,
D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB,
D3D_BLOB_PATCH_CONSTANT_SIGNATURE_BLOB,
D3D_BLOB_ALL_SIGNATURE_BLOB,
D3D_BLOB_DEBUG_INFO,
D3D_BLOB_LEGACY_SHADER,
D3D_BLOB_XNA_PREPASS_SHADER,
D3D_BLOB_XNA_SHADER,
D3D_BLOB_PDB,
D3D_BLOB_PRIVATE_DATA,
D3D_BLOB_ROOT_SIGNATURE,
D3D_BLOB_DEBUG_NAME,
// Test parts are only produced by special compiler versions and so
// are usually not present in shaders.
D3D_BLOB_TEST_ALTERNATE_SHADER = 0x8000,
D3D_BLOB_TEST_COMPILE_DETAILS,
D3D_BLOB_TEST_COMPILE_PERF,
D3D_BLOB_TEST_COMPILE_REPORT,
} D3D_BLOB_PART;
HRESULT WINAPI
D3DGetBlobPart(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
_In_ SIZE_T SrcDataSize,
_In_ D3D_BLOB_PART Part,
_In_ UINT Flags,
_Out_ ID3DBlob** ppPart);
//----------------------------------------------------------------------------
// D3DSetBlobPart:
// -----------------------
// Update information in a compilation result.
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DSetBlobPart(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
_In_ SIZE_T SrcDataSize,
_In_ D3D_BLOB_PART Part,
_In_ UINT Flags,
_In_reads_bytes_(PartSize) LPCVOID pPart,
_In_ SIZE_T PartSize,
_Out_ ID3DBlob** ppNewShader);
//----------------------------------------------------------------------------
// D3DCreateBlob:
// -----------------------
// Create an ID3DBlob instance.
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DCreateBlob(_In_ SIZE_T Size,
_Out_ ID3DBlob** ppBlob);
//----------------------------------------------------------------------------
// D3DCompressShaders:
// -----------------------
// Compresses a set of shaders into a more compact form.
//----------------------------------------------------------------------------
typedef struct _D3D_SHADER_DATA
{
LPCVOID pBytecode;
SIZE_T BytecodeLength;
} D3D_SHADER_DATA;
#define D3D_COMPRESS_SHADER_KEEP_ALL_PARTS 0x00000001
HRESULT WINAPI
D3DCompressShaders(_In_ UINT uNumShaders,
_In_reads_(uNumShaders) D3D_SHADER_DATA* pShaderData,
_In_ UINT uFlags,
_Out_ ID3DBlob** ppCompressedData);
//----------------------------------------------------------------------------
// D3DDecompressShaders:
// -----------------------
// Decompresses one or more shaders from a compressed set.
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DDecompressShaders(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
_In_ SIZE_T SrcDataSize,
_In_ UINT uNumShaders,
_In_ UINT uStartIndex,
_In_reads_opt_(uNumShaders) UINT* pIndices,
_In_ UINT uFlags,
_Out_writes_(uNumShaders) ID3DBlob** ppShaders,
_Out_opt_ UINT* pTotalShaders);
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */
// BK - pragma endregion
// BK - pragma region Desktop Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
//----------------------------------------------------------------------------
// D3DDisassemble10Effect:
// -----------------------
// Takes a D3D10 effect interface and returns a
// buffer containing text assembly.
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DDisassemble10Effect(_In_ interface ID3D10Effect *pEffect,
_In_ UINT Flags,
_Out_ ID3DBlob** ppDisassembly);
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// BK - pragma endregion
#ifdef __cplusplus
}
#endif //__cplusplus
#endif // #ifndef __D3DCOMPILER_H__

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,56 @@
//
// Copyright (C) Microsoft. All rights reserved.
//
#ifndef __dxgicommon_h__
#define __dxgicommon_h__
typedef struct DXGI_RATIONAL
{
UINT Numerator;
UINT Denominator;
} DXGI_RATIONAL;
// The following values are used with DXGI_SAMPLE_DESC::Quality:
#define DXGI_STANDARD_MULTISAMPLE_QUALITY_PATTERN 0xffffffff
#define DXGI_CENTER_MULTISAMPLE_QUALITY_PATTERN 0xfffffffe
typedef struct DXGI_SAMPLE_DESC
{
UINT Count;
UINT Quality;
} DXGI_SAMPLE_DESC;
typedef enum DXGI_COLOR_SPACE_TYPE
{
DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709 = 0,
DXGI_COLOR_SPACE_RGB_FULL_G10_NONE_P709 = 1,
DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P709 = 2,
DXGI_COLOR_SPACE_RGB_STUDIO_G22_NONE_P2020 = 3,
DXGI_COLOR_SPACE_RESERVED = 4,
DXGI_COLOR_SPACE_YCBCR_FULL_G22_NONE_P709_X601 = 5,
DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P601 = 6,
DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P601 = 7,
DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P709 = 8,
DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P709 = 9,
DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_LEFT_P2020 = 10,
DXGI_COLOR_SPACE_YCBCR_FULL_G22_LEFT_P2020 = 11,
DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020 = 12,
DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_LEFT_P2020 = 13,
DXGI_COLOR_SPACE_RGB_STUDIO_G2084_NONE_P2020 = 14,
DXGI_COLOR_SPACE_YCBCR_STUDIO_G22_TOPLEFT_P2020 = 15,
DXGI_COLOR_SPACE_YCBCR_STUDIO_G2084_TOPLEFT_P2020 = 16,
DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P2020 = 17,
DXGI_COLOR_SPACE_YCBCR_STUDIO_GHLG_TOPLEFT_P2020 = 18,
DXGI_COLOR_SPACE_YCBCR_FULL_GHLG_TOPLEFT_P2020 = 19,
DXGI_COLOR_SPACE_RGB_STUDIO_G24_NONE_P709 = 20,
DXGI_COLOR_SPACE_RGB_STUDIO_G24_NONE_P2020 = 21,
DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_LEFT_P709 = 22,
DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_LEFT_P2020 = 23,
DXGI_COLOR_SPACE_YCBCR_STUDIO_G24_TOPLEFT_P2020 = 24,
DXGI_COLOR_SPACE_CUSTOM = 0xFFFFFFFF
} DXGI_COLOR_SPACE_TYPE;
#endif // __dxgicommon_h__

View file

@ -0,0 +1,986 @@
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 8.01.0622 */
/* @@MIDL_FILE_HEADING( ) */
/* verify that the <rpcndr.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCNDR_H_VERSION__
#define __REQUIRED_RPCNDR_H_VERSION__ 475
#endif
/* verify that the <rpcsal.h> version is high enough to compile this file*/
#ifndef __REQUIRED_RPCSAL_H_VERSION__
#define __REQUIRED_RPCSAL_H_VERSION__ 100
#endif
#include "rpc.h"
#include "rpcndr.h"
#ifndef __RPCNDR_H_VERSION__
#error this stub requires an updated version of <rpcndr.h>
#endif /* __RPCNDR_H_VERSION__ */
#ifndef COM_NO_WINDOWS_H
#include "windows.h"
#include "ole2.h"
#endif /*COM_NO_WINDOWS_H*/
#ifndef __dxgidebug_h__
#define __dxgidebug_h__
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
/* Forward Declarations */
#ifndef __IDXGIInfoQueue_FWD_DEFINED__
#define __IDXGIInfoQueue_FWD_DEFINED__
typedef interface IDXGIInfoQueue IDXGIInfoQueue;
#endif /* __IDXGIInfoQueue_FWD_DEFINED__ */
#ifndef __IDXGIDebug_FWD_DEFINED__
#define __IDXGIDebug_FWD_DEFINED__
typedef interface IDXGIDebug IDXGIDebug;
#endif /* __IDXGIDebug_FWD_DEFINED__ */
#ifndef __IDXGIDebug1_FWD_DEFINED__
#define __IDXGIDebug1_FWD_DEFINED__
typedef interface IDXGIDebug1 IDXGIDebug1;
#endif /* __IDXGIDebug1_FWD_DEFINED__ */
/* header files for imported files */
#include "oaidl.h"
#include "ocidl.h"
#ifdef __cplusplus
extern "C"{
#endif
/* interface __MIDL_itf_dxgidebug_0000_0000 */
/* [local] */
#define DXGI_DEBUG_BINARY_VERSION ( 1 )
typedef
enum DXGI_DEBUG_RLO_FLAGS
{
DXGI_DEBUG_RLO_SUMMARY = 0x1,
DXGI_DEBUG_RLO_DETAIL = 0x2,
DXGI_DEBUG_RLO_IGNORE_INTERNAL = 0x4,
DXGI_DEBUG_RLO_ALL = 0x7
} DXGI_DEBUG_RLO_FLAGS;
typedef GUID DXGI_DEBUG_ID;
DEFINE_GUID(DXGI_DEBUG_ALL, 0xe48ae283, 0xda80, 0x490b, 0x87, 0xe6, 0x43, 0xe9, 0xa9, 0xcf, 0xda, 0x8);
DEFINE_GUID(DXGI_DEBUG_DX, 0x35cdd7fc, 0x13b2, 0x421d, 0xa5, 0xd7, 0x7e, 0x44, 0x51, 0x28, 0x7d, 0x64);
DEFINE_GUID(DXGI_DEBUG_DXGI, 0x25cddaa4, 0xb1c6, 0x47e1, 0xac, 0x3e, 0x98, 0x87, 0x5b, 0x5a, 0x2e, 0x2a);
DEFINE_GUID(DXGI_DEBUG_APP, 0x6cd6e01, 0x4219, 0x4ebd, 0x87, 0x9, 0x27, 0xed, 0x23, 0x36, 0xc, 0x62);
typedef
enum DXGI_INFO_QUEUE_MESSAGE_CATEGORY
{
DXGI_INFO_QUEUE_MESSAGE_CATEGORY_UNKNOWN = 0,
DXGI_INFO_QUEUE_MESSAGE_CATEGORY_MISCELLANEOUS = ( DXGI_INFO_QUEUE_MESSAGE_CATEGORY_UNKNOWN + 1 ) ,
DXGI_INFO_QUEUE_MESSAGE_CATEGORY_INITIALIZATION = ( DXGI_INFO_QUEUE_MESSAGE_CATEGORY_MISCELLANEOUS + 1 ) ,
DXGI_INFO_QUEUE_MESSAGE_CATEGORY_CLEANUP = ( DXGI_INFO_QUEUE_MESSAGE_CATEGORY_INITIALIZATION + 1 ) ,
DXGI_INFO_QUEUE_MESSAGE_CATEGORY_COMPILATION = ( DXGI_INFO_QUEUE_MESSAGE_CATEGORY_CLEANUP + 1 ) ,
DXGI_INFO_QUEUE_MESSAGE_CATEGORY_STATE_CREATION = ( DXGI_INFO_QUEUE_MESSAGE_CATEGORY_COMPILATION + 1 ) ,
DXGI_INFO_QUEUE_MESSAGE_CATEGORY_STATE_SETTING = ( DXGI_INFO_QUEUE_MESSAGE_CATEGORY_STATE_CREATION + 1 ) ,
DXGI_INFO_QUEUE_MESSAGE_CATEGORY_STATE_GETTING = ( DXGI_INFO_QUEUE_MESSAGE_CATEGORY_STATE_SETTING + 1 ) ,
DXGI_INFO_QUEUE_MESSAGE_CATEGORY_RESOURCE_MANIPULATION = ( DXGI_INFO_QUEUE_MESSAGE_CATEGORY_STATE_GETTING + 1 ) ,
DXGI_INFO_QUEUE_MESSAGE_CATEGORY_EXECUTION = ( DXGI_INFO_QUEUE_MESSAGE_CATEGORY_RESOURCE_MANIPULATION + 1 ) ,
DXGI_INFO_QUEUE_MESSAGE_CATEGORY_SHADER = ( DXGI_INFO_QUEUE_MESSAGE_CATEGORY_EXECUTION + 1 )
} DXGI_INFO_QUEUE_MESSAGE_CATEGORY;
typedef
enum DXGI_INFO_QUEUE_MESSAGE_SEVERITY
{
DXGI_INFO_QUEUE_MESSAGE_SEVERITY_CORRUPTION = 0,
DXGI_INFO_QUEUE_MESSAGE_SEVERITY_ERROR = ( DXGI_INFO_QUEUE_MESSAGE_SEVERITY_CORRUPTION + 1 ) ,
DXGI_INFO_QUEUE_MESSAGE_SEVERITY_WARNING = ( DXGI_INFO_QUEUE_MESSAGE_SEVERITY_ERROR + 1 ) ,
DXGI_INFO_QUEUE_MESSAGE_SEVERITY_INFO = ( DXGI_INFO_QUEUE_MESSAGE_SEVERITY_WARNING + 1 ) ,
DXGI_INFO_QUEUE_MESSAGE_SEVERITY_MESSAGE = ( DXGI_INFO_QUEUE_MESSAGE_SEVERITY_INFO + 1 )
} DXGI_INFO_QUEUE_MESSAGE_SEVERITY;
typedef int DXGI_INFO_QUEUE_MESSAGE_ID;
#define DXGI_INFO_QUEUE_MESSAGE_ID_STRING_FROM_APPLICATION 0
typedef struct DXGI_INFO_QUEUE_MESSAGE
{
DXGI_DEBUG_ID Producer;
DXGI_INFO_QUEUE_MESSAGE_CATEGORY Category;
DXGI_INFO_QUEUE_MESSAGE_SEVERITY Severity;
DXGI_INFO_QUEUE_MESSAGE_ID ID;
/* [annotation] */
_Field_size_(DescriptionByteLength) const char *pDescription;
SIZE_T DescriptionByteLength;
} DXGI_INFO_QUEUE_MESSAGE;
typedef struct DXGI_INFO_QUEUE_FILTER_DESC
{
UINT NumCategories;
/* [annotation] */
_Field_size_(NumCategories) DXGI_INFO_QUEUE_MESSAGE_CATEGORY *pCategoryList;
UINT NumSeverities;
/* [annotation] */
_Field_size_(NumSeverities) DXGI_INFO_QUEUE_MESSAGE_SEVERITY *pSeverityList;
UINT NumIDs;
/* [annotation] */
_Field_size_(NumIDs) DXGI_INFO_QUEUE_MESSAGE_ID *pIDList;
} DXGI_INFO_QUEUE_FILTER_DESC;
typedef struct DXGI_INFO_QUEUE_FILTER
{
DXGI_INFO_QUEUE_FILTER_DESC AllowList;
DXGI_INFO_QUEUE_FILTER_DESC DenyList;
} DXGI_INFO_QUEUE_FILTER;
#define DXGI_INFO_QUEUE_DEFAULT_MESSAGE_COUNT_LIMIT 1024
HRESULT WINAPI DXGIGetDebugInterface(REFIID riid, void **ppDebug);
extern RPC_IF_HANDLE __MIDL_itf_dxgidebug_0000_0000_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_dxgidebug_0000_0000_v0_0_s_ifspec;
#ifndef __IDXGIInfoQueue_INTERFACE_DEFINED__
#define __IDXGIInfoQueue_INTERFACE_DEFINED__
/* interface IDXGIInfoQueue */
/* [unique][local][object][uuid] */
EXTERN_C const IID IID_IDXGIInfoQueue;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("D67441C7-672A-476f-9E82-CD55B44949CE")
IDXGIInfoQueue : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE SetMessageCountLimit(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ UINT64 MessageCountLimit) = 0;
virtual void STDMETHODCALLTYPE ClearStoredMessages(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
virtual HRESULT STDMETHODCALLTYPE GetMessage(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ UINT64 MessageIndex,
/* [annotation] */
_Out_writes_bytes_opt_(*pMessageByteLength) DXGI_INFO_QUEUE_MESSAGE *pMessage,
/* [annotation] */
_Inout_ SIZE_T *pMessageByteLength) = 0;
virtual UINT64 STDMETHODCALLTYPE GetNumStoredMessagesAllowedByRetrievalFilters(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
virtual UINT64 STDMETHODCALLTYPE GetNumStoredMessages(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
virtual UINT64 STDMETHODCALLTYPE GetNumMessagesDiscardedByMessageCountLimit(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
virtual UINT64 STDMETHODCALLTYPE GetMessageCountLimit(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
virtual UINT64 STDMETHODCALLTYPE GetNumMessagesAllowedByStorageFilter(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
virtual UINT64 STDMETHODCALLTYPE GetNumMessagesDeniedByStorageFilter(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
virtual HRESULT STDMETHODCALLTYPE AddStorageFilterEntries(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_FILTER *pFilter) = 0;
virtual HRESULT STDMETHODCALLTYPE GetStorageFilter(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_Out_writes_bytes_opt_(*pFilterByteLength) DXGI_INFO_QUEUE_FILTER *pFilter,
/* [annotation] */
_Inout_ SIZE_T *pFilterByteLength) = 0;
virtual void STDMETHODCALLTYPE ClearStorageFilter(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
virtual HRESULT STDMETHODCALLTYPE PushEmptyStorageFilter(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
virtual HRESULT STDMETHODCALLTYPE PushDenyAllStorageFilter(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
virtual HRESULT STDMETHODCALLTYPE PushCopyOfStorageFilter(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
virtual HRESULT STDMETHODCALLTYPE PushStorageFilter(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_FILTER *pFilter) = 0;
virtual void STDMETHODCALLTYPE PopStorageFilter(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
virtual UINT STDMETHODCALLTYPE GetStorageFilterStackSize(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
virtual HRESULT STDMETHODCALLTYPE AddRetrievalFilterEntries(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_FILTER *pFilter) = 0;
virtual HRESULT STDMETHODCALLTYPE GetRetrievalFilter(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_Out_writes_bytes_opt_(*pFilterByteLength) DXGI_INFO_QUEUE_FILTER *pFilter,
/* [annotation] */
_Inout_ SIZE_T *pFilterByteLength) = 0;
virtual void STDMETHODCALLTYPE ClearRetrievalFilter(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
virtual HRESULT STDMETHODCALLTYPE PushEmptyRetrievalFilter(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
virtual HRESULT STDMETHODCALLTYPE PushDenyAllRetrievalFilter(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
virtual HRESULT STDMETHODCALLTYPE PushCopyOfRetrievalFilter(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
virtual HRESULT STDMETHODCALLTYPE PushRetrievalFilter(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_FILTER *pFilter) = 0;
virtual void STDMETHODCALLTYPE PopRetrievalFilter(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
virtual UINT STDMETHODCALLTYPE GetRetrievalFilterStackSize(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
virtual HRESULT STDMETHODCALLTYPE AddMessage(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_CATEGORY Category,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_SEVERITY Severity,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_ID ID,
/* [annotation] */
_In_ LPCSTR pDescription) = 0;
virtual HRESULT STDMETHODCALLTYPE AddApplicationMessage(
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_SEVERITY Severity,
/* [annotation] */
_In_ LPCSTR pDescription) = 0;
virtual HRESULT STDMETHODCALLTYPE SetBreakOnCategory(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_CATEGORY Category,
/* [annotation] */
_In_ BOOL bEnable) = 0;
virtual HRESULT STDMETHODCALLTYPE SetBreakOnSeverity(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_SEVERITY Severity,
/* [annotation] */
_In_ BOOL bEnable) = 0;
virtual HRESULT STDMETHODCALLTYPE SetBreakOnID(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_ID ID,
/* [annotation] */
_In_ BOOL bEnable) = 0;
virtual BOOL STDMETHODCALLTYPE GetBreakOnCategory(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_CATEGORY Category) = 0;
virtual BOOL STDMETHODCALLTYPE GetBreakOnSeverity(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_SEVERITY Severity) = 0;
virtual BOOL STDMETHODCALLTYPE GetBreakOnID(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_ID ID) = 0;
virtual void STDMETHODCALLTYPE SetMuteDebugOutput(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ BOOL bMute) = 0;
virtual BOOL STDMETHODCALLTYPE GetMuteDebugOutput(
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer) = 0;
};
#else /* C style interface */
typedef struct IDXGIInfoQueueVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
IDXGIInfoQueue * This,
/* [in] */ REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
IDXGIInfoQueue * This);
ULONG ( STDMETHODCALLTYPE *Release )(
IDXGIInfoQueue * This);
HRESULT ( STDMETHODCALLTYPE *SetMessageCountLimit )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ UINT64 MessageCountLimit);
void ( STDMETHODCALLTYPE *ClearStoredMessages )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
HRESULT ( STDMETHODCALLTYPE *GetMessage )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ UINT64 MessageIndex,
/* [annotation] */
_Out_writes_bytes_opt_(*pMessageByteLength) DXGI_INFO_QUEUE_MESSAGE *pMessage,
/* [annotation] */
_Inout_ SIZE_T *pMessageByteLength);
UINT64 ( STDMETHODCALLTYPE *GetNumStoredMessagesAllowedByRetrievalFilters )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
UINT64 ( STDMETHODCALLTYPE *GetNumStoredMessages )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
UINT64 ( STDMETHODCALLTYPE *GetNumMessagesDiscardedByMessageCountLimit )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
UINT64 ( STDMETHODCALLTYPE *GetMessageCountLimit )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
UINT64 ( STDMETHODCALLTYPE *GetNumMessagesAllowedByStorageFilter )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
UINT64 ( STDMETHODCALLTYPE *GetNumMessagesDeniedByStorageFilter )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
HRESULT ( STDMETHODCALLTYPE *AddStorageFilterEntries )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_FILTER *pFilter);
HRESULT ( STDMETHODCALLTYPE *GetStorageFilter )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_Out_writes_bytes_opt_(*pFilterByteLength) DXGI_INFO_QUEUE_FILTER *pFilter,
/* [annotation] */
_Inout_ SIZE_T *pFilterByteLength);
void ( STDMETHODCALLTYPE *ClearStorageFilter )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
HRESULT ( STDMETHODCALLTYPE *PushEmptyStorageFilter )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
HRESULT ( STDMETHODCALLTYPE *PushDenyAllStorageFilter )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
HRESULT ( STDMETHODCALLTYPE *PushCopyOfStorageFilter )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
HRESULT ( STDMETHODCALLTYPE *PushStorageFilter )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_FILTER *pFilter);
void ( STDMETHODCALLTYPE *PopStorageFilter )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
UINT ( STDMETHODCALLTYPE *GetStorageFilterStackSize )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
HRESULT ( STDMETHODCALLTYPE *AddRetrievalFilterEntries )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_FILTER *pFilter);
HRESULT ( STDMETHODCALLTYPE *GetRetrievalFilter )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_Out_writes_bytes_opt_(*pFilterByteLength) DXGI_INFO_QUEUE_FILTER *pFilter,
/* [annotation] */
_Inout_ SIZE_T *pFilterByteLength);
void ( STDMETHODCALLTYPE *ClearRetrievalFilter )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
HRESULT ( STDMETHODCALLTYPE *PushEmptyRetrievalFilter )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
HRESULT ( STDMETHODCALLTYPE *PushDenyAllRetrievalFilter )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
HRESULT ( STDMETHODCALLTYPE *PushCopyOfRetrievalFilter )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
HRESULT ( STDMETHODCALLTYPE *PushRetrievalFilter )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_FILTER *pFilter);
void ( STDMETHODCALLTYPE *PopRetrievalFilter )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
UINT ( STDMETHODCALLTYPE *GetRetrievalFilterStackSize )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
HRESULT ( STDMETHODCALLTYPE *AddMessage )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_CATEGORY Category,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_SEVERITY Severity,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_ID ID,
/* [annotation] */
_In_ LPCSTR pDescription);
HRESULT ( STDMETHODCALLTYPE *AddApplicationMessage )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_SEVERITY Severity,
/* [annotation] */
_In_ LPCSTR pDescription);
HRESULT ( STDMETHODCALLTYPE *SetBreakOnCategory )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_CATEGORY Category,
/* [annotation] */
_In_ BOOL bEnable);
HRESULT ( STDMETHODCALLTYPE *SetBreakOnSeverity )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_SEVERITY Severity,
/* [annotation] */
_In_ BOOL bEnable);
HRESULT ( STDMETHODCALLTYPE *SetBreakOnID )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_ID ID,
/* [annotation] */
_In_ BOOL bEnable);
BOOL ( STDMETHODCALLTYPE *GetBreakOnCategory )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_CATEGORY Category);
BOOL ( STDMETHODCALLTYPE *GetBreakOnSeverity )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_SEVERITY Severity);
BOOL ( STDMETHODCALLTYPE *GetBreakOnID )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ DXGI_INFO_QUEUE_MESSAGE_ID ID);
void ( STDMETHODCALLTYPE *SetMuteDebugOutput )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer,
/* [annotation] */
_In_ BOOL bMute);
BOOL ( STDMETHODCALLTYPE *GetMuteDebugOutput )(
IDXGIInfoQueue * This,
/* [annotation] */
_In_ DXGI_DEBUG_ID Producer);
END_INTERFACE
} IDXGIInfoQueueVtbl;
interface IDXGIInfoQueue
{
CONST_VTBL struct IDXGIInfoQueueVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define IDXGIInfoQueue_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define IDXGIInfoQueue_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define IDXGIInfoQueue_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define IDXGIInfoQueue_SetMessageCountLimit(This,Producer,MessageCountLimit) \
( (This)->lpVtbl -> SetMessageCountLimit(This,Producer,MessageCountLimit) )
#define IDXGIInfoQueue_ClearStoredMessages(This,Producer) \
( (This)->lpVtbl -> ClearStoredMessages(This,Producer) )
#define IDXGIInfoQueue_GetMessage(This,Producer,MessageIndex,pMessage,pMessageByteLength) \
( (This)->lpVtbl -> GetMessage(This,Producer,MessageIndex,pMessage,pMessageByteLength) )
#define IDXGIInfoQueue_GetNumStoredMessagesAllowedByRetrievalFilters(This,Producer) \
( (This)->lpVtbl -> GetNumStoredMessagesAllowedByRetrievalFilters(This,Producer) )
#define IDXGIInfoQueue_GetNumStoredMessages(This,Producer) \
( (This)->lpVtbl -> GetNumStoredMessages(This,Producer) )
#define IDXGIInfoQueue_GetNumMessagesDiscardedByMessageCountLimit(This,Producer) \
( (This)->lpVtbl -> GetNumMessagesDiscardedByMessageCountLimit(This,Producer) )
#define IDXGIInfoQueue_GetMessageCountLimit(This,Producer) \
( (This)->lpVtbl -> GetMessageCountLimit(This,Producer) )
#define IDXGIInfoQueue_GetNumMessagesAllowedByStorageFilter(This,Producer) \
( (This)->lpVtbl -> GetNumMessagesAllowedByStorageFilter(This,Producer) )
#define IDXGIInfoQueue_GetNumMessagesDeniedByStorageFilter(This,Producer) \
( (This)->lpVtbl -> GetNumMessagesDeniedByStorageFilter(This,Producer) )
#define IDXGIInfoQueue_AddStorageFilterEntries(This,Producer,pFilter) \
( (This)->lpVtbl -> AddStorageFilterEntries(This,Producer,pFilter) )
#define IDXGIInfoQueue_GetStorageFilter(This,Producer,pFilter,pFilterByteLength) \
( (This)->lpVtbl -> GetStorageFilter(This,Producer,pFilter,pFilterByteLength) )
#define IDXGIInfoQueue_ClearStorageFilter(This,Producer) \
( (This)->lpVtbl -> ClearStorageFilter(This,Producer) )
#define IDXGIInfoQueue_PushEmptyStorageFilter(This,Producer) \
( (This)->lpVtbl -> PushEmptyStorageFilter(This,Producer) )
#define IDXGIInfoQueue_PushDenyAllStorageFilter(This,Producer) \
( (This)->lpVtbl -> PushDenyAllStorageFilter(This,Producer) )
#define IDXGIInfoQueue_PushCopyOfStorageFilter(This,Producer) \
( (This)->lpVtbl -> PushCopyOfStorageFilter(This,Producer) )
#define IDXGIInfoQueue_PushStorageFilter(This,Producer,pFilter) \
( (This)->lpVtbl -> PushStorageFilter(This,Producer,pFilter) )
#define IDXGIInfoQueue_PopStorageFilter(This,Producer) \
( (This)->lpVtbl -> PopStorageFilter(This,Producer) )
#define IDXGIInfoQueue_GetStorageFilterStackSize(This,Producer) \
( (This)->lpVtbl -> GetStorageFilterStackSize(This,Producer) )
#define IDXGIInfoQueue_AddRetrievalFilterEntries(This,Producer,pFilter) \
( (This)->lpVtbl -> AddRetrievalFilterEntries(This,Producer,pFilter) )
#define IDXGIInfoQueue_GetRetrievalFilter(This,Producer,pFilter,pFilterByteLength) \
( (This)->lpVtbl -> GetRetrievalFilter(This,Producer,pFilter,pFilterByteLength) )
#define IDXGIInfoQueue_ClearRetrievalFilter(This,Producer) \
( (This)->lpVtbl -> ClearRetrievalFilter(This,Producer) )
#define IDXGIInfoQueue_PushEmptyRetrievalFilter(This,Producer) \
( (This)->lpVtbl -> PushEmptyRetrievalFilter(This,Producer) )
#define IDXGIInfoQueue_PushDenyAllRetrievalFilter(This,Producer) \
( (This)->lpVtbl -> PushDenyAllRetrievalFilter(This,Producer) )
#define IDXGIInfoQueue_PushCopyOfRetrievalFilter(This,Producer) \
( (This)->lpVtbl -> PushCopyOfRetrievalFilter(This,Producer) )
#define IDXGIInfoQueue_PushRetrievalFilter(This,Producer,pFilter) \
( (This)->lpVtbl -> PushRetrievalFilter(This,Producer,pFilter) )
#define IDXGIInfoQueue_PopRetrievalFilter(This,Producer) \
( (This)->lpVtbl -> PopRetrievalFilter(This,Producer) )
#define IDXGIInfoQueue_GetRetrievalFilterStackSize(This,Producer) \
( (This)->lpVtbl -> GetRetrievalFilterStackSize(This,Producer) )
#define IDXGIInfoQueue_AddMessage(This,Producer,Category,Severity,ID,pDescription) \
( (This)->lpVtbl -> AddMessage(This,Producer,Category,Severity,ID,pDescription) )
#define IDXGIInfoQueue_AddApplicationMessage(This,Severity,pDescription) \
( (This)->lpVtbl -> AddApplicationMessage(This,Severity,pDescription) )
#define IDXGIInfoQueue_SetBreakOnCategory(This,Producer,Category,bEnable) \
( (This)->lpVtbl -> SetBreakOnCategory(This,Producer,Category,bEnable) )
#define IDXGIInfoQueue_SetBreakOnSeverity(This,Producer,Severity,bEnable) \
( (This)->lpVtbl -> SetBreakOnSeverity(This,Producer,Severity,bEnable) )
#define IDXGIInfoQueue_SetBreakOnID(This,Producer,ID,bEnable) \
( (This)->lpVtbl -> SetBreakOnID(This,Producer,ID,bEnable) )
#define IDXGIInfoQueue_GetBreakOnCategory(This,Producer,Category) \
( (This)->lpVtbl -> GetBreakOnCategory(This,Producer,Category) )
#define IDXGIInfoQueue_GetBreakOnSeverity(This,Producer,Severity) \
( (This)->lpVtbl -> GetBreakOnSeverity(This,Producer,Severity) )
#define IDXGIInfoQueue_GetBreakOnID(This,Producer,ID) \
( (This)->lpVtbl -> GetBreakOnID(This,Producer,ID) )
#define IDXGIInfoQueue_SetMuteDebugOutput(This,Producer,bMute) \
( (This)->lpVtbl -> SetMuteDebugOutput(This,Producer,bMute) )
#define IDXGIInfoQueue_GetMuteDebugOutput(This,Producer) \
( (This)->lpVtbl -> GetMuteDebugOutput(This,Producer) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* __IDXGIInfoQueue_INTERFACE_DEFINED__ */
#ifndef __IDXGIDebug_INTERFACE_DEFINED__
#define __IDXGIDebug_INTERFACE_DEFINED__
/* interface IDXGIDebug */
/* [unique][local][object][uuid] */
EXTERN_C const IID IID_IDXGIDebug;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("119E7452-DE9E-40fe-8806-88F90C12B441")
IDXGIDebug : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE ReportLiveObjects(
GUID apiid,
DXGI_DEBUG_RLO_FLAGS flags) = 0;
};
#else /* C style interface */
typedef struct IDXGIDebugVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
IDXGIDebug * This,
/* [in] */ REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
IDXGIDebug * This);
ULONG ( STDMETHODCALLTYPE *Release )(
IDXGIDebug * This);
HRESULT ( STDMETHODCALLTYPE *ReportLiveObjects )(
IDXGIDebug * This,
GUID apiid,
DXGI_DEBUG_RLO_FLAGS flags);
END_INTERFACE
} IDXGIDebugVtbl;
interface IDXGIDebug
{
CONST_VTBL struct IDXGIDebugVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define IDXGIDebug_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define IDXGIDebug_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define IDXGIDebug_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define IDXGIDebug_ReportLiveObjects(This,apiid,flags) \
( (This)->lpVtbl -> ReportLiveObjects(This,apiid,flags) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* __IDXGIDebug_INTERFACE_DEFINED__ */
#ifndef __IDXGIDebug1_INTERFACE_DEFINED__
#define __IDXGIDebug1_INTERFACE_DEFINED__
/* interface IDXGIDebug1 */
/* [unique][local][object][uuid] */
EXTERN_C const IID IID_IDXGIDebug1;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("c5a05f0c-16f2-4adf-9f4d-a8c4d58ac550")
IDXGIDebug1 : public IDXGIDebug
{
public:
virtual void STDMETHODCALLTYPE EnableLeakTrackingForThread( void) = 0;
virtual void STDMETHODCALLTYPE DisableLeakTrackingForThread( void) = 0;
virtual BOOL STDMETHODCALLTYPE IsLeakTrackingEnabledForThread( void) = 0;
};
#else /* C style interface */
typedef struct IDXGIDebug1Vtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
IDXGIDebug1 * This,
/* [in] */ REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
IDXGIDebug1 * This);
ULONG ( STDMETHODCALLTYPE *Release )(
IDXGIDebug1 * This);
HRESULT ( STDMETHODCALLTYPE *ReportLiveObjects )(
IDXGIDebug1 * This,
GUID apiid,
DXGI_DEBUG_RLO_FLAGS flags);
void ( STDMETHODCALLTYPE *EnableLeakTrackingForThread )(
IDXGIDebug1 * This);
void ( STDMETHODCALLTYPE *DisableLeakTrackingForThread )(
IDXGIDebug1 * This);
BOOL ( STDMETHODCALLTYPE *IsLeakTrackingEnabledForThread )(
IDXGIDebug1 * This);
END_INTERFACE
} IDXGIDebug1Vtbl;
interface IDXGIDebug1
{
CONST_VTBL struct IDXGIDebug1Vtbl *lpVtbl;
};
#ifdef COBJMACROS
#define IDXGIDebug1_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define IDXGIDebug1_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define IDXGIDebug1_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define IDXGIDebug1_ReportLiveObjects(This,apiid,flags) \
( (This)->lpVtbl -> ReportLiveObjects(This,apiid,flags) )
#define IDXGIDebug1_EnableLeakTrackingForThread(This) \
( (This)->lpVtbl -> EnableLeakTrackingForThread(This) )
#define IDXGIDebug1_DisableLeakTrackingForThread(This) \
( (This)->lpVtbl -> DisableLeakTrackingForThread(This) )
#define IDXGIDebug1_IsLeakTrackingEnabledForThread(This) \
( (This)->lpVtbl -> IsLeakTrackingEnabledForThread(This) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* __IDXGIDebug1_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_dxgidebug_0000_0003 */
/* [local] */
DEFINE_GUID(IID_IDXGIInfoQueue,0xD67441C7,0x672A,0x476f,0x9E,0x82,0xCD,0x55,0xB4,0x49,0x49,0xCE);
DEFINE_GUID(IID_IDXGIDebug,0x119E7452,0xDE9E,0x40fe,0x88,0x06,0x88,0xF9,0x0C,0x12,0xB4,0x41);
DEFINE_GUID(IID_IDXGIDebug1,0xc5a05f0c,0x16f2,0x4adf,0x9f,0x4d,0xa8,0xc4,0xd5,0x8a,0xc5,0x50);
extern RPC_IF_HANDLE __MIDL_itf_dxgidebug_0000_0003_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_dxgidebug_0000_0003_v0_0_s_ifspec;
/* Additional Prototypes for ALL interfaces */
/* end of Additional Prototypes */
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,137 @@
//
// Copyright (C) Microsoft. All rights reserved.
//
#ifndef __dxgiformat_h__
#define __dxgiformat_h__
#define DXGI_FORMAT_DEFINED 1
typedef enum DXGI_FORMAT
{
DXGI_FORMAT_UNKNOWN = 0,
DXGI_FORMAT_R32G32B32A32_TYPELESS = 1,
DXGI_FORMAT_R32G32B32A32_FLOAT = 2,
DXGI_FORMAT_R32G32B32A32_UINT = 3,
DXGI_FORMAT_R32G32B32A32_SINT = 4,
DXGI_FORMAT_R32G32B32_TYPELESS = 5,
DXGI_FORMAT_R32G32B32_FLOAT = 6,
DXGI_FORMAT_R32G32B32_UINT = 7,
DXGI_FORMAT_R32G32B32_SINT = 8,
DXGI_FORMAT_R16G16B16A16_TYPELESS = 9,
DXGI_FORMAT_R16G16B16A16_FLOAT = 10,
DXGI_FORMAT_R16G16B16A16_UNORM = 11,
DXGI_FORMAT_R16G16B16A16_UINT = 12,
DXGI_FORMAT_R16G16B16A16_SNORM = 13,
DXGI_FORMAT_R16G16B16A16_SINT = 14,
DXGI_FORMAT_R32G32_TYPELESS = 15,
DXGI_FORMAT_R32G32_FLOAT = 16,
DXGI_FORMAT_R32G32_UINT = 17,
DXGI_FORMAT_R32G32_SINT = 18,
DXGI_FORMAT_R32G8X24_TYPELESS = 19,
DXGI_FORMAT_D32_FLOAT_S8X24_UINT = 20,
DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS = 21,
DXGI_FORMAT_X32_TYPELESS_G8X24_UINT = 22,
DXGI_FORMAT_R10G10B10A2_TYPELESS = 23,
DXGI_FORMAT_R10G10B10A2_UNORM = 24,
DXGI_FORMAT_R10G10B10A2_UINT = 25,
DXGI_FORMAT_R11G11B10_FLOAT = 26,
DXGI_FORMAT_R8G8B8A8_TYPELESS = 27,
DXGI_FORMAT_R8G8B8A8_UNORM = 28,
DXGI_FORMAT_R8G8B8A8_UNORM_SRGB = 29,
DXGI_FORMAT_R8G8B8A8_UINT = 30,
DXGI_FORMAT_R8G8B8A8_SNORM = 31,
DXGI_FORMAT_R8G8B8A8_SINT = 32,
DXGI_FORMAT_R16G16_TYPELESS = 33,
DXGI_FORMAT_R16G16_FLOAT = 34,
DXGI_FORMAT_R16G16_UNORM = 35,
DXGI_FORMAT_R16G16_UINT = 36,
DXGI_FORMAT_R16G16_SNORM = 37,
DXGI_FORMAT_R16G16_SINT = 38,
DXGI_FORMAT_R32_TYPELESS = 39,
DXGI_FORMAT_D32_FLOAT = 40,
DXGI_FORMAT_R32_FLOAT = 41,
DXGI_FORMAT_R32_UINT = 42,
DXGI_FORMAT_R32_SINT = 43,
DXGI_FORMAT_R24G8_TYPELESS = 44,
DXGI_FORMAT_D24_UNORM_S8_UINT = 45,
DXGI_FORMAT_R24_UNORM_X8_TYPELESS = 46,
DXGI_FORMAT_X24_TYPELESS_G8_UINT = 47,
DXGI_FORMAT_R8G8_TYPELESS = 48,
DXGI_FORMAT_R8G8_UNORM = 49,
DXGI_FORMAT_R8G8_UINT = 50,
DXGI_FORMAT_R8G8_SNORM = 51,
DXGI_FORMAT_R8G8_SINT = 52,
DXGI_FORMAT_R16_TYPELESS = 53,
DXGI_FORMAT_R16_FLOAT = 54,
DXGI_FORMAT_D16_UNORM = 55,
DXGI_FORMAT_R16_UNORM = 56,
DXGI_FORMAT_R16_UINT = 57,
DXGI_FORMAT_R16_SNORM = 58,
DXGI_FORMAT_R16_SINT = 59,
DXGI_FORMAT_R8_TYPELESS = 60,
DXGI_FORMAT_R8_UNORM = 61,
DXGI_FORMAT_R8_UINT = 62,
DXGI_FORMAT_R8_SNORM = 63,
DXGI_FORMAT_R8_SINT = 64,
DXGI_FORMAT_A8_UNORM = 65,
DXGI_FORMAT_R1_UNORM = 66,
DXGI_FORMAT_R9G9B9E5_SHAREDEXP = 67,
DXGI_FORMAT_R8G8_B8G8_UNORM = 68,
DXGI_FORMAT_G8R8_G8B8_UNORM = 69,
DXGI_FORMAT_BC1_TYPELESS = 70,
DXGI_FORMAT_BC1_UNORM = 71,
DXGI_FORMAT_BC1_UNORM_SRGB = 72,
DXGI_FORMAT_BC2_TYPELESS = 73,
DXGI_FORMAT_BC2_UNORM = 74,
DXGI_FORMAT_BC2_UNORM_SRGB = 75,
DXGI_FORMAT_BC3_TYPELESS = 76,
DXGI_FORMAT_BC3_UNORM = 77,
DXGI_FORMAT_BC3_UNORM_SRGB = 78,
DXGI_FORMAT_BC4_TYPELESS = 79,
DXGI_FORMAT_BC4_UNORM = 80,
DXGI_FORMAT_BC4_SNORM = 81,
DXGI_FORMAT_BC5_TYPELESS = 82,
DXGI_FORMAT_BC5_UNORM = 83,
DXGI_FORMAT_BC5_SNORM = 84,
DXGI_FORMAT_B5G6R5_UNORM = 85,
DXGI_FORMAT_B5G5R5A1_UNORM = 86,
DXGI_FORMAT_B8G8R8A8_UNORM = 87,
DXGI_FORMAT_B8G8R8X8_UNORM = 88,
DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM = 89,
DXGI_FORMAT_B8G8R8A8_TYPELESS = 90,
DXGI_FORMAT_B8G8R8A8_UNORM_SRGB = 91,
DXGI_FORMAT_B8G8R8X8_TYPELESS = 92,
DXGI_FORMAT_B8G8R8X8_UNORM_SRGB = 93,
DXGI_FORMAT_BC6H_TYPELESS = 94,
DXGI_FORMAT_BC6H_UF16 = 95,
DXGI_FORMAT_BC6H_SF16 = 96,
DXGI_FORMAT_BC7_TYPELESS = 97,
DXGI_FORMAT_BC7_UNORM = 98,
DXGI_FORMAT_BC7_UNORM_SRGB = 99,
DXGI_FORMAT_AYUV = 100,
DXGI_FORMAT_Y410 = 101,
DXGI_FORMAT_Y416 = 102,
DXGI_FORMAT_NV12 = 103,
DXGI_FORMAT_P010 = 104,
DXGI_FORMAT_P016 = 105,
DXGI_FORMAT_420_OPAQUE = 106,
DXGI_FORMAT_YUY2 = 107,
DXGI_FORMAT_Y210 = 108,
DXGI_FORMAT_Y216 = 109,
DXGI_FORMAT_NV11 = 110,
DXGI_FORMAT_AI44 = 111,
DXGI_FORMAT_IA44 = 112,
DXGI_FORMAT_P8 = 113,
DXGI_FORMAT_A8P8 = 114,
DXGI_FORMAT_B4G4R4A4_UNORM = 115,
DXGI_FORMAT_P208 = 130,
DXGI_FORMAT_V208 = 131,
DXGI_FORMAT_V408 = 132,
DXGI_FORMAT_FORCE_UINT = 0xffffffff
} DXGI_FORMAT;
#endif // __dxgiformat_h__

View file

@ -0,0 +1,111 @@
//
// Copyright (C) Microsoft. All rights reserved.
//
#ifndef __dxgitype_h__
#define __dxgitype_h__
#include "dxgicommon.h"
#include "dxgiformat.h"
#define _FACDXGI 0x87a
#define MAKE_DXGI_HRESULT(code) MAKE_HRESULT(1, _FACDXGI, code)
#define MAKE_DXGI_STATUS(code) MAKE_HRESULT(0, _FACDXGI, code)
// DXGI error messages have moved to winerror.h
#define DXGI_CPU_ACCESS_NONE ( 0 )
#define DXGI_CPU_ACCESS_DYNAMIC ( 1 )
#define DXGI_CPU_ACCESS_READ_WRITE ( 2 )
#define DXGI_CPU_ACCESS_SCRATCH ( 3 )
#define DXGI_CPU_ACCESS_FIELD 15
typedef struct DXGI_RGB
{
float Red;
float Green;
float Blue;
} DXGI_RGB;
#ifndef D3DCOLORVALUE_DEFINED
typedef struct _D3DCOLORVALUE {
float r;
float g;
float b;
float a;
} D3DCOLORVALUE;
#define D3DCOLORVALUE_DEFINED
#endif
typedef D3DCOLORVALUE DXGI_RGBA;
typedef struct DXGI_GAMMA_CONTROL
{
DXGI_RGB Scale;
DXGI_RGB Offset;
DXGI_RGB GammaCurve[ 1025 ];
} DXGI_GAMMA_CONTROL;
typedef struct DXGI_GAMMA_CONTROL_CAPABILITIES
{
BOOL ScaleAndOffsetSupported;
float MaxConvertedValue;
float MinConvertedValue;
UINT NumGammaControlPoints;
float ControlPointPositions[1025];
} DXGI_GAMMA_CONTROL_CAPABILITIES;
typedef enum DXGI_MODE_SCANLINE_ORDER
{
DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED = 0,
DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE = 1,
DXGI_MODE_SCANLINE_ORDER_UPPER_FIELD_FIRST = 2,
DXGI_MODE_SCANLINE_ORDER_LOWER_FIELD_FIRST = 3
} DXGI_MODE_SCANLINE_ORDER;
typedef enum DXGI_MODE_SCALING
{
DXGI_MODE_SCALING_UNSPECIFIED = 0,
DXGI_MODE_SCALING_CENTERED = 1,
DXGI_MODE_SCALING_STRETCHED = 2
} DXGI_MODE_SCALING;
typedef enum DXGI_MODE_ROTATION
{
DXGI_MODE_ROTATION_UNSPECIFIED = 0,
DXGI_MODE_ROTATION_IDENTITY = 1,
DXGI_MODE_ROTATION_ROTATE90 = 2,
DXGI_MODE_ROTATION_ROTATE180 = 3,
DXGI_MODE_ROTATION_ROTATE270 = 4
} DXGI_MODE_ROTATION;
typedef struct DXGI_MODE_DESC
{
UINT Width;
UINT Height;
DXGI_RATIONAL RefreshRate;
DXGI_FORMAT Format;
DXGI_MODE_SCANLINE_ORDER ScanlineOrdering;
DXGI_MODE_SCALING Scaling;
} DXGI_MODE_DESC;
typedef struct DXGI_JPEG_DC_HUFFMAN_TABLE
{
BYTE CodeCounts[12];
BYTE CodeValues[12];
} DXGI_JPEG_DC_HUFFMAN_TABLE;
typedef struct DXGI_JPEG_AC_HUFFMAN_TABLE
{
BYTE CodeCounts[16];
BYTE CodeValues[162];
} DXGI_JPEG_AC_HUFFMAN_TABLE;
typedef struct DXGI_JPEG_QUANTIZATION_TABLE
{
BYTE Elements[64];
} DXGI_JPEG_QUANTIZATION_TABLE;
#endif // __dxgitype_h__

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,116 @@
/*==========================================================================;
*
* Copyright (C) Microsoft Corporation. All Rights Reserved.
*
* File: pix3.h
* Content: PIX include file
*
****************************************************************************/
#pragma once
#ifndef _PIX3_H_
#define _PIX3_H_
#include <sal.h>
#ifndef __cplusplus
#error "Only C++ files can include pix.h. C is not supported."
#endif
#if defined(XBOX) || defined(_XBOX_ONE) || defined(_DURANGO)
#include "pix3_xbox.h"
#else
#include "pix3_win.h"
#endif
//
// The PIX event/marker APIs compile to nothing on retail builds and on x86 builds
//
#if (!defined(USE_PIX)) && ((defined(_DEBUG) || DBG || (defined(PROFILE) && !defined(FASTCAP)) || defined(PROFILE_BUILD)) && !defined(i386) && defined(_AMD64_) && !defined(_PREFAST_))
#define USE_PIX
#endif
#if defined(USE_PIX) && !defined(_AMD64_) && !defined(USE_PIX_ON_ALL_ARCHITECTURES)
#pragma message("Warning: Pix markers are only supported on AMD64")
#endif
// These flags are used by both PIXBeginCapture and PIXGetCaptureState
#define PIX_CAPTURE_TIMING (1 << 0)
#define PIX_CAPTURE_GPU (1 << 1)
#define PIX_CAPTURE_FUNCTION_SUMMARY (1 << 2)
#define PIX_CAPTURE_FUNCTION_DETAILS (1 << 3)
#define PIX_CAPTURE_CALLGRAPH (1 << 4)
#define PIX_CAPTURE_INSTRUCTION_TRACE (1 << 5)
#define PIX_CAPTURE_SYSTEM_MONITOR_COUNTERS (1 << 6)
#define PIX_CAPTURE_VIDEO (1 << 7)
#define PIX_CAPTURE_AUDIO (1 << 8)
typedef union PIXCaptureParameters
{
struct GpuCaptureParameters
{
PVOID reserved;
} GpuCaptureParameters;
struct TimingCaptureParameters
{
BOOL CaptureCallstacks;
PWSTR FileName;
} TimingCaptureParameters;
} PIXCaptureParameters, *PPIXCaptureParameters;
#if defined (USE_PIX) && (defined(_AMD64_) || defined(USE_PIX_ON_ALL_ARCHITECTURES))
#include "PIXEventsCommon.h"
#include "PIXEventsGenerated.h"
// Starts a programmatically controlled capture.
// captureFlags uses the PIX_CAPTURE_* family of flags to specify the type of capture to take
extern "C" HRESULT WINAPI PIXBeginCapture(DWORD captureFlags, _In_opt_ const PPIXCaptureParameters captureParameters);
// Stops a programmatically controlled capture
// If discard == TRUE, the captured data is discarded
// If discard == FALSE, the captured data is saved
extern "C" HRESULT WINAPI PIXEndCapture(BOOL discard);
extern "C" DWORD WINAPI PIXGetCaptureState();
extern "C" void WINAPI PIXReportCounter(_In_ PCWSTR name, float value);
#else
// Eliminate these APIs when not using PIX
inline HRESULT PIXBeginCapture(DWORD, _In_opt_ const PIXCaptureParameters*) { return S_OK; }
inline HRESULT PIXEndCapture(BOOL) { return S_OK; }
inline DWORD PIXGetCaptureState() { return 0; }
inline void PIXReportCounter(_In_ PCWSTR, float) {}
inline void PIXBeginEvent(UINT64, _In_ PCSTR, ...) {}
inline void PIXBeginEvent(UINT64, _In_ PCWSTR, ...) {}
inline void PIXBeginEvent(void*, UINT64, _In_ PCSTR, ...) {}
inline void PIXBeginEvent(void*, UINT64, _In_ PCWSTR, ...) {}
inline void PIXEndEvent() {}
inline void PIXEndEvent(void*) {}
inline void PIXSetMarker(UINT64, _In_ PCSTR, ...) {}
inline void PIXSetMarker(UINT64, _In_ PCWSTR, ...) {}
inline void PIXSetMarker(void*, UINT64, _In_ PCSTR, ...) {}
inline void PIXSetMarker(void*, UINT64, _In_ PCWSTR, ...) {}
inline void PIXScopedEvent(UINT64, _In_ PCSTR, ...) {}
inline void PIXScopedEvent(UINT64, _In_ PCWSTR, ...) {}
inline void PIXScopedEvent(void*, UINT64, _In_ PCSTR, ...) {}
inline void PIXScopedEvent(void*, UINT64, _In_ PCWSTR, ...) {}
#endif // USE_PIX
// Use these functions to specify colors to pass as metadata to a PIX event/marker API.
// Use PIX_COLOR() to specify a particular color for an event.
// Or, use PIX_COLOR_INDEX() to specify a set of unique event categories, and let PIX choose
// the colors to represent each category.
inline UINT PIX_COLOR(BYTE r, BYTE g, BYTE b) { return 0xff000000 | (r << 16) | (g << 8) | b; }
inline UINT PIX_COLOR_INDEX(BYTE i) { return i; }
const UINT PIX_COLOR_DEFAULT = PIX_COLOR_INDEX(0);
#endif // _PIX3_H_

View file

@ -0,0 +1,53 @@
/*==========================================================================;
*
* Copyright (C) Microsoft Corporation. All Rights Reserved.
*
* File: PIX3_win.h
* Content: PIX include file
* Don't include this file directly - use pix3.h
*
****************************************************************************/
#pragma once
#ifndef _PIX3_H_
#error "Don't include this file directly - use pix3.h"
#endif
#ifndef _PIX3_WIN_H_
#define _PIX3_WIN_H_
struct PIXEventsBlockInfo
{
};
struct PIXEventsThreadInfo
{
PIXEventsBlockInfo* block;
UINT64* biasedLimit;
UINT64* destination;
UINT64* limit;
UINT64 id;
};
// The following defines denote the different metadata values that have been used
// by tools to denote how to parse pix marker event data. The first two values
// are legacy values.
#define WINPIX_EVENT_UNICODE_VERSION 0
#define WINPIX_EVENT_ANSI_VERSION 1
#define WINPIX_EVENT_PIX3BLOB_VERSION 2
#define D3D12_EVENT_METADATA WINPIX_EVENT_PIX3BLOB_VERSION
__forceinline UINT64 PIXGetTimestampCounter()
{
LARGE_INTEGER time = {};
QueryPerformanceCounter(&time);
return time.QuadPart;
}
#define PIXSetCPUMarkerOnContext(context, metadata, ...) MakeCPUSetMarkerForContext(metadata, context, __VA_ARGS__)
#define PIXBeginCPUEventOnContext(context, metadata, ...) MakeCPUBeginEventForContext(metadata, context, __VA_ARGS__)
#define PIXEndCPUEventOnContext(context) MakeCPUEndEventForContext(context)
#endif //_PIX3_WIN_H_

View file

@ -0,0 +1,24 @@
/**
* This file is part of the mingw-w64 runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
*/
#ifndef _INC_WINAPIFAMILY
#define _INC_WINAPIFAMILY
#define WINAPI_PARTITION_DESKTOP 0x1
#define WINAPI_PARTITION_APP 0x2
#define WINAPI_FAMILY_APP WINAPI_PARTITION_APP
#define WINAPI_FAMILY_DESKTOP_APP (WINAPI_PARTITION_DESKTOP \
| WINAPI_PARTITION_APP)
/* WINAPI_FAMILY can be either desktop + App, or App. */
#ifndef WINAPI_FAMILY
#define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP
#endif
#define WINAPI_FAMILY_PARTITION(v) ((WINAPI_FAMILY & v) == v)
#define WINAPI_FAMILY_ONE_PARTITION(vset, v) ((WINAPI_FAMILY & vset) == v)
#endif

View file

@ -0,0 +1,3 @@
fcpp
*.o
*~

View file

@ -0,0 +1,38 @@
/*
* Copyright (c) 1993-2011 Daniel Stenberg
* All rights reserved.
*
* Redistribution and use in source and binary forms,
* with or without modification, are permitted provided
* that the following conditions are met:
*
* Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
*
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* Neither the name of the copyright holder nor the names
* of any other contributors may be used to endorse or
* promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*/

View file

@ -0,0 +1,56 @@
/******************************************************************************
* FREXXWARE
* ----------------------------------------------------------------------------
*
* Project: Frexx C Preprocessor
* $Source: /home/user/start/cpp/RCS/FPPBase.h,v $
* $Revision: 1.3 $
* $Date: 1993/12/06 13:51:20 $
* $Author: start $
* $State: Exp $
* $Locker: start $
*
* ----------------------------------------------------------------------------
* $Log: FPPBase.h,v $
* Revision 1.3 1993/12/06 13:51:20 start
* A lot of new stuff (too much to mention)
*
* Revision 1.2 1993/11/11 07:16:39 start
* New stuff
*
* Revision 1.2 1993/11/11 07:16:39 start
* New stuff
*
* Revision 1.1 1993/11/03 09:15:59 start
* Initial revision
*
*
*****************************************************************************/
#ifndef FPP_BASE_H
#define FPP_BASE_H
/*
** $Filename: libraries/FPPbase.h $
** $Release: 1.0 $
** $Date: 1993/12/06 13:51:20 $
**
** (C) Copyright 1992, 1993 by FrexxWare
** All Rights Reserved
*/
#include <exec/types.h>
#include <exec/libraries.h>
struct FPPBase {
struct Library LibNode;
UBYTE Flags;
UBYTE pad;
/* long word aligned */
ULONG SysLib;
ULONG DosLib;
ULONG SegList;
};
#define FPPNAME "fpp.library"
#endif

View file

@ -0,0 +1,35 @@
/******************************************************************************
* FREXXWARE
* ----------------------------------------------------------------------------
*
* Project: Frexx C Preprocessor
* $Source: /home/user/start/cpp/RCS/FPP_protos.h,v $
* $Revision: 1.3 $
* $Date: 1993/12/06 13:51:20 $
* $Author: start $
* $State: Exp $
* $Locker: start $
*
* ----------------------------------------------------------------------------
* $Log: FPP_protos.h,v $
* Revision 1.3 1993/12/06 13:51:20 start
* A lot of new stuff (too much to mention)
*
* Revision 1.2 1993/11/11 07:16:39 start
* New stuff
*
* Revision 1.2 1993/11/11 07:16:39 start
* New stuff
*
* Revision 1.1 1993/11/03 09:15:59 start
* Initial revision
*
*
*****************************************************************************/
/******************************************************
*
* FPP_protos.h
*
*******/
int fppPreProcess(struct fppTag *);

View file

@ -0,0 +1,13 @@
Frexx CPP (C Preprocessor)
Copyright (c) by Daniel Stenberg 1993 - 2011
This is a C preprocessor. It is a project based on public domain code, then
forked by Daniel in 1993 and future work has been done under a BSD license.
The C preprocessor is now (mostly?) ANSI C compliant, and some tweaks have
been applied to also make it fairly usable to process other data files, such
as HTML for simple web sites.
WWW: http://daniel.haxx.se/projects/fcpp/
Code: https://github.com/bagder/fcpp

251
ADVect/ext/bgfx/bgfx/3rdparty/fcpp/cpp.h vendored Normal file
View file

@ -0,0 +1,251 @@
/******************************************************************************
* FREXXWARE
* ----------------------------------------------------------------------------
*
* Project: Frexx C Preprocessor
* $Source: /home/user/start/cpp/RCS/cpp.h,v $
* $Revision: 1.3 $
* $Date: 1993/12/06 13:51:20 $
* $Author: start $
* $State: Exp $
* $Locker: start $
*
* ----------------------------------------------------------------------------
* $Log: cpp.h,v $
* Revision 1.3 1993/12/06 13:51:20 start
* A lot of new stuff (too much to mention)
*
* Revision 1.2 1993/11/11 07:16:39 start
* New stuff
*
* Revision 1.2 1993/11/11 07:16:39 start
* New stuff
*
* Revision 1.1 1993/11/03 09:15:59 start
* Initial revision
*
*
*****************************************************************************/
/*
* I n t e r n a l D e f i n i t i o n s f o r C P P
*
* In general, definitions in this file should not be changed.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef fpp_toupper
#define fpp_toupper(c) ((c) + ('A' - 'a'))
#endif /* no fpp_toupper */
#ifndef fpp_tolower
#define fpp_tolower(c) ((c) + ('a' - 'A'))
#endif /* no fpp_tolower */
#ifndef FPP_TRUE
#define FPP_TRUE 1
#define FPP_FALSE 0
#endif
#ifndef EOS
/*
* This is predefined in Decus C
*/
#define EOS '\0' /* End of string */
#endif
#define EOF_CHAR 0 /* Returned by fpp_get() on eof */
#define NULLST ((char *) NULL) /* Pointer to nowhere (linted) */
#define DEF_NOARGS (-1) /* #define foo vs #define foo() */
/*
* The following may need to change if the host system doesn't use ASCII.
*/
#define QUOTE_PARM 0x1C /* Magic quoting operator */
#define DEF_MAGIC 0x1D /* Magic for #defines */
#define TOK_SEP 0x1E /* Token concatenation delim. */
#define COM_SEP 0x1F /* Magic comment separator */
/*
* Note -- in Ascii, the following will map macro formals onto DEL + the
* C1 control character region (decimal 128 .. (128 + PAR_MAC)) which will
* be ok as long as PAR_MAC is less than 33). Note that the last PAR_MAC
* value is reserved for string substitution.
*/
#define MAC_PARM 0x7F /* Macro formals start here */
#ifndef OS9
#if (PAR_MAC >= 33)
#error "assertion fails -- PAR_MAC isn't less than 33"
#endif
#endif
#define LASTPARM (PAR_MAC - 1)
/*
* Character type codes.
*/
#define INV 0 /* Invalid, must be zero */
#define OP_EOE INV /* End of expression */
#define DIG 1 /* Digit */
#define LET 2 /* Identifier start */
#define FIRST_BINOP OP_ADD
#define OP_ADD 3
#define OP_SUB 4
#define OP_MUL 5
#define OP_DIV 6
#define OP_MOD 7
#define OP_ASL 8
#define OP_ASR 9
#define OP_AND 10 /* &, not && */
#define OP_OR 11 /* |, not || */
#define OP_XOR 12
#define OP_EQ 13
#define OP_NE 14
#define OP_LT 15
#define OP_LE 16
#define OP_GE 17
#define OP_GT 18
#define OP_ANA 19 /* && */
#define OP_ORO 20 /* || */
#define OP_QUE 21 /* ? */
#define OP_COL 22 /* : */
#define OP_CMA 23 /* , (relevant?) */
#define LAST_BINOP OP_CMA /* Last binary operand */
/*
* The following are unary.
*/
#define FIRST_UNOP OP_PLU /* First Unary operand */
#define OP_PLU 24 /* + (draft ANSI standard) */
#define OP_NEG 25 /* - */
#define OP_COM 26 /* ~ */
#define OP_NOT 27 /* ! */
#define LAST_UNOP OP_NOT
#define OP_LPA 28 /* ( */
#define OP_RPA 29 /* ) */
#define OP_END 30 /* End of expression marker */
#define OP_MAX (OP_END + 1) /* Number of operators */
#define OP_FAIL (OP_END + 1) /* For error returns */
/*
* The following are for lexical scanning only.
*/
#define QUO 65 /* Both flavors of quotation */
#define DOT 66 /* . might start a number */
#define SPA 67 /* Space and tab */
#define BSH 68 /* Just a backslash */
#define END 69 /* EOF */
/*
* These bits are set in ifstack[]
*/
#define WAS_COMPILING 1 /* FPP_TRUE if compile set at entry */
#define ELSE_SEEN 2 /* FPP_TRUE when #else processed */
#define FPP_TRUE_SEEN 4 /* FPP_TRUE when #if FPP_TRUE processed */
/*
* Define bits for the basic types and their adjectives
*/
#define T_CHAR 1
#define T_INT 2
#define T_FLOAT 4
#define T_DOUBLE 8
#define T_SHORT 16
#define T_LONG 32
#define T_SIGNED 64
#define T_UNSIGNED 128
#define T_PTR 256 /* Pointer */
#define T_FPTR 512 /* Pointer to functions */
/*
* The DEFBUF structure stores information about #defined
* macros. Note that the defbuf->repl information is always
* in malloc storage.
*/
typedef struct defbuf {
struct defbuf *link; /* Next define in chain */
char *repl; /* -> replacement */
int hash; /* Symbol table hash */
int nargs; /* For define(args) */
char name[1]; /* #define name */
} DEFBUF;
/*
* The FILEINFO structure stores information about open files
* and macros being expanded.
*/
typedef struct fileinfo {
char *bptr; /* Buffer pointer */
int line; /* for include or macro */
FILE *fp; /* File if non-null */
struct fileinfo *parent; /* Link to includer */
char *filename; /* File/macro name */
char *progname; /* From #line statement */
unsigned int unrecur; /* For macro recursion */
char buffer[1]; /* current input line */
} FILEINFO;
/*
* The SIZES structure is used to store the values for #if sizeof
*/
typedef struct sizes {
short bits; /* If this bit is set, */
short size; /* this is the datum size value */
short psize; /* this is the pointer size */
} SIZES;
/*
* nomacarg is a built-in #define on Decus C.
*/
#ifdef nomacarg
#define cput generate /* cput concatenates tokens */
#else
#if COMMENT_INVISIBLE
#define cput(c) { if (c != TOK_SEP && c != COM_SEP) putchar(c); }
#else
#define cput(c) { if (c != TOK_SEP) putchar(c); }
#endif
#endif
#ifndef nomacarg
#define streq(s1, s2) (strcmp(s1, s2) == 0)
#endif
/*
* Note: IO_NORMAL and IO_ERROR are defined in the Decus C stdio.h file
*/
#ifndef IO_NORMAL
#define IO_NORMAL 0
#endif
#ifndef IO_ERROR
#define IO_ERROR 1
#endif
/*
* Externs
*/
#include "fpp.h" /* structs and defines */
#include "cppadd.h" /* Added prototypes for ANSI complience! */
#ifdef AMIGA
#include <dos.h>
extern int _OSERR;
#endif
extern char type[]; /* Character classifier */
#define compiling global->ifstack[0]
#if DEBUG
extern int debug; /* Debug level */
#endif
extern SIZES size_table[]; /* For #if sizeof sizes */
#define MAX_SPACE_SIZE 512 /* maximum number of whitespaces possible
to remember */

View file

@ -0,0 +1,605 @@
/******************************************************************************
Copyright (c) 1993 - 2011 Daniel Stenberg
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.
******************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include "cppdef.h"
#include "cpp.h"
#if defined(AMIGA)
#include <dos.h>
#if defined(SHARED)
int _OSERR=0;
char *_ProgramName="junk";
void __stdargs _XCEXIT(long a) { return; }
#endif
#endif
FILE_LOCAL ReturnCode fpp_output(struct Global *, int); /* Output one character */
FILE_LOCAL void fpp_sharp(struct Global *);
INLINE FILE_LOCAL ReturnCode fpp_cppmain(struct Global *);
int fppPreProcess(struct fppTag *tags)
{
size_t i=0;
ReturnCode ret; /* cpp return code */
int retVal; /* fppPreProcess return code */
struct Global *global;
global=(struct Global *)malloc(sizeof(struct Global));
if(!global)
return(FPP_OUT_OF_MEMORY);
memset(global, 0, sizeof(struct Global));
global->infile=NULL;
global->line=0;
global->wrongline=0;
global->errors=0;
global->recursion=0;
global->rec_recover=FPP_TRUE;
global->instring=FPP_FALSE;
global->inmacro=FPP_FALSE;
global->workp=NULL;
global->keepcomments = FPP_FALSE; /* Write out comments flag */
global->cflag = FPP_FALSE; /* -C option (keep comments) */
global->eflag = FPP_FALSE; /* -E option (never fail) */
global->nflag = 0; /* -N option (no predefines) */
global->wflag = FPP_FALSE; /* -W option (write #defines) */
global->ifstack[0]=FPP_TRUE; /* #if information */
global->ifptr = global->ifstack;
global->incend = global->incdir;
/* names defined at cpp start */
global->preset[0]="frexxcpp"; /* This is the Frexx cpp program */
#if defined( amiga )
global->preset[1]="amiga";
global->preset[2]="m68000";
global->preset[3]="amigados";
global->preset[4]= NULL; /* Must be last */
#elif defined( unix )
global->preset[1]="unix";
global->preset[2]= NULL;
#endif
/* Note: order is important */
global->magic[0] = "__LINE__";
global->magic[1] = "__FILE__";
global->magic[2] = "__FUNCTION__";
global->magic[3] = "__FUNC_LINE__";
global->magic[4] = NULL; /* Must be last */
global->funcline = 0;
global->cplusplus=1;
global->sharpfilename=NULL;
global->parmp=NULL;
global->nargs=0;
global->macro=NULL;
global->evalue=0;
global->depends=NULL;
global->input=NULL;
global->output=NULL;
global->error=NULL;
global->first_file=NULL;
global->userdata=NULL;
global->linelines=FPP_TRUE;
global->warnillegalcpp = FPP_FALSE;
global->outputLINE = FPP_TRUE;
global->warnnoinclude = FPP_TRUE;
global->showversion = FPP_TRUE;
global->showincluded = FPP_FALSE;
global->showspace = FPP_FALSE;
global->nestcomments = FPP_FALSE;
global->warnnestcomments = FPP_FALSE;
global->outputfile = FPP_TRUE;
global->included = 0;
global->comment = FPP_FALSE;
global->rightconcat = FPP_FALSE;
global->work[0] = '\0';
global->initialfunc = NULL;
global->allowincludelocal = FPP_TRUE;
memset(global->symtab, 0, SBSIZE * sizeof(DEFBUF *));
ret=fpp_initdefines(global); /* O.S. specific def's */
if(ret)
return(ret);
fpp_dooptions(global, tags); /* Command line -flags */
ret=fpp_addfile(global, stdin, global->work); /* "open" main input file */
global->out = global->outputfile;
if(!ret)
ret=fpp_cppmain(global); /* Process main file */
if ((i = (global->ifptr - global->ifstack)) != 0) {
#if OLD_PREPROCESSOR
fpp_cwarn(global, ERROR_IFDEF_DEPTH, i);
#else
fpp_cerror(global, ERROR_IFDEF_DEPTH, i);
#endif
}
fflush(stdout);
// BK - fclose(stdout);
fpp_delalldefines(global);
retVal = IO_NORMAL;
if (global->errors > 0 && !global->eflag)
retVal = IO_ERROR;
free(global->tokenbuf);
free(global->functionname);
free(global->spacebuf);
free(global);
return retVal; /* No errors or -E option set */
}
INLINE FILE_LOCAL
ReturnCode fpp_cppmain(struct Global *global)
{
/*
* Main process for cpp -- copies tokens from the current input
* stream (main file, include file, or a macro) to the output
* file.
*/
int c; /* Current character */
int counter; /* newlines and spaces */
ReturnCode ret; /* return code variable type */
long bracelevel = 0;
long parenlevel = 0;
long bracketlevel = 0;
int fake = 0;
#define MAX_FUNC_LENGTH 50
char tempfunc[MAX_FUNC_LENGTH + 1];
char tempfunc2[MAX_FUNC_LENGTH + 1];
char define = 0; /* probability of a function define phase in the program */
char prev = 0; /* previous type */
char go = 0;
unsigned include = 0;
char initfunc = 0;
/* Initialize for reading tokens */
global->tokenbsize = 50;
global->tokenbuf = malloc(global->tokenbsize + 1);
if(!global->tokenbuf)
return(FPP_OUT_OF_MEMORY);
global->functionname = malloc(global->tokenbsize + 1);
if(!global->functionname)
return(FPP_OUT_OF_MEMORY);
global->functionname[0] = '\0';
if(global->showspace) {
global->spacebuf = (char *)malloc(MAX_SPACE_SIZE);
if(!global->spacebuf)
return(FPP_OUT_OF_MEMORY);
}
if(global->showversion)
fpp_Error(global, VERSION_TEXT);
/*
* Explicitly output a #line at the start of cpp output so
* that lint (etc.) knows the name of the original source
* file. If we don't do this explicitly, we may get
* the name of the first #include file instead.
*/
if(global->linelines) /* if #line lines are wanted! */
fpp_sharp(global);
/*
* This loop is started "from the top" at the beginning of each line
* wrongline is set FPP_TRUE in many places if it is necessary to write
* a #line record. (But we don't write them when expanding macros.)
*
* The counter variable has two different uses: at
* the start of a line, it counts the number of blank lines that
* have been skipped over. These are then either output via
* #line records or by outputting explicit blank lines.
* When expanding tokens within a line, the counter remembers
* whether a blank/tab has been output. These are dropped
* at the end of the line, and replaced by a single blank
* within lines.
*/
include = global->included;
while(include--) {
fpp_openinclude(global, global->include[(unsigned)include], FPP_TRUE);
}
for (;;) {
counter = 0; /* Count empty lines */
for (;;) { /* For each line, ... */
global->comment = FPP_FALSE; /* No comment yet! */
global->chpos = 0; /* Count whitespaces */
while (type[(c = fpp_get(global))] == SPA) /* Skip leading blanks */
if(global->showspace) {
if(global->chpos<MAX_SPACE_SIZE-1)
/* we still have buffer to store this! */
global->spacebuf[global->chpos++]=(char)c;
}
if (c == '\n') { /* If line's all blank, */
if(global->comment) {
/* A comment was output! */
fpp_Putchar(global, '\n');
}
else
++counter; /* Do nothing now */
}
else if (c == '#') { /* Is 1st non-space '#' */
global->keepcomments = FPP_FALSE; /* Don't pass comments */
ret = fpp_control(global, &counter); /* Yes, do a #command */
if(ret)
return(ret);
global->keepcomments = (global->cflag && compiling);
}
else if (c == EOF_CHAR) /* At end of file? */
break;
else if (!compiling) { /* #ifdef false? */
fpp_skipnl(global); /* Skip to newline */
counter++; /* Count it, too. */
} else {
break; /* Actual token */
}
}
if (c == EOF_CHAR) /* Exit process at */
break; /* End of file */
/*
* If the loop didn't terminate because of end of file, we
* know there is a token to compile. First, clean up after
* absorbing newlines. counter has the number we skipped.
*/
if(global->linelines) { /* if #line lines are wanted! */
if ((global->wrongline && global->infile->fp != NULL) || counter > 4)
fpp_sharp(global); /* Output # line number */
else { /* If just a few, stuff */
while (--counter >= 0) /* them out ourselves */
fpp_Putchar(global, (int)'\n');
}
}
if(global->showspace) {
/* Show all whitespaces! */
global->spacebuf[global->chpos] = '\0';
fpp_Putstring(global, global->spacebuf);
}
/*
* Process each token on this line.
*/
fpp_unget(global); /* Reread the char. */
for (;;) { /* For the whole line, */
do { /* Token concat. loop */
for (global->chpos = counter = 0; (type[(c = fpp_get(global))] == SPA);) {
#if COMMENT_INVISIBLE
if (c != COM_SEP)
counter++;
#else
if(global->showspace && global->chpos < MAX_SPACE_SIZE-1) {
global->spacebuf[global->chpos++]=(char)c;
}
counter++; /* Skip over blanks */
#endif
}
if (c == EOF_CHAR || c == '\n')
break; /* Exit line loop */
else if (counter > 0) { /* If we got any spaces */
if(!global->showspace) /* We don't output all spaces */
fpp_Putchar(global, (int)' ');/* Output one space */
else {
global->spacebuf[global->chpos] = '\0';
fpp_Putstring(global, global->spacebuf); /* Output all whitespaces */
}
}
if((ret=fpp_macroid(global, &c))) /* Grab the token */
return(ret);
} while (type[c] == LET && fpp_catenate(global, 0, &ret) && !ret);
if(ret)
/* If the loop was broken because of a fatal error! */
return(ret);
if (c == EOF_CHAR || c == '\n') /* From macro exp error */
break; /* Exit line loop */
go++;
switch (type[c]) {
case LET:
go =0;
/* Quite ordinary token */
fpp_Putstring(global, global->tokenbuf);
if(!define) {
/* Copy the name */
strncpy(tempfunc, global->tokenbuf, MAX_FUNC_LENGTH);
tempfunc[MAX_FUNC_LENGTH]=0;
}
/* fputs(global->tokenbuf, stdout); */
break;
case DIG: /* Output a number */
case DOT: /* Dot may begin floats */
go = 0;
ret=fpp_scannumber(global, c, (ReturnCode(*)(struct Global *, int))fpp_output);
if(ret)
return(ret);
fpp_catenate(global, 1, &ret); /* Check to see if the number is the lhs of a macro concat */
if(ret)
return(ret);
break;
case QUO: /* char or string const */
go = 0;
/* Copy it to output */
if(!global->webmode) {
ret=fpp_scanstring(global, c,
(ReturnCode(*)(struct Global *, int))fpp_output);
if(ret)
return(ret);
break;
}
/* FALLTHROUGH */
default: /* Some other character */
define++;
switch(c) {
case '{':
if(! bracelevel++ && define > 2) {
/*
* This is a starting brace. If there is a probability of a
* function defining, we copy the `tempfunc' function name to
* `global->functionname'.
*/
strcpy(global->functionname, tempfunc2);
global->funcline = global->line;
if(global->outputfunctions) {
/*
* Output the discovered function name to stderr!
*/
fpp_Error(global, "#> Function defined at line %d: %s <#\n",
global->line,
global->functionname);
}
if(global->initialfunc) {
int a;
for(a=0; a<global->excluded; a++) {
/* check for excluded functions */
if(!strcmp(global->functionname,
global->excludedinit[a]))
break;
}
if(a==global->excluded) {
fpp_expstuff(global, "__brace__", "{");
fpp_expstuff(global, "__init_func__", global->initialfunc);
initfunc = FPP_TRUE;
}
}
}
break;
case '}':
go = 0;
if( (--bracelevel == initfunc) &&
strcmp(global->infile->filename, "__init_func__") ) {
/* we just stepped out of the function! */
global->functionname[0] = '\0';
global->funcline = 0;
define = 1;
if(initfunc) {
fpp_Putchar(global, '}');
bracelevel--;
initfunc=0;
}
}
fake = 0;
break;
case ';':
case ',':
if(go == 2) {
define = 1;
fake = 0;
go--;
break;
}
break;
case '(':
if(! parenlevel++ && !bracelevel) {
if(go == 2) {
/* foobar(text) -> "(" is found. This can't be a
function */
go--;
define = 1;
break;
}
if( define < 2 && prev == LET) {
/* This is the first parenthesis on the ground brace
level, and we did previously not have a probable
function name */
strncpy(tempfunc2, global->tokenbuf, MAX_FUNC_LENGTH);
tempfunc2[MAX_FUNC_LENGTH]=0;
define++;
}
else {
/* we have a fake start */
fake++;
}
}
break;
case ')':
if(! --parenlevel && !bracelevel && define>1 && !fake) {
/*
* The starting parentheses level and
* the starting brace level.
* This might be the start of a function defining coming
* up!
*/
define++; /* increase probability */
fake = 0;
go = 1;
}
break;
case '[':
bracketlevel++;
break;
case ']':
bracketlevel--;
break;
}
define--; /* decrease function probability */
fpp_Putchar(global, c); /* Just output it */
break;
} /* Switch ends */
prev = type[c];
} /* Line for loop */
if (c == '\n') { /* Compiling at EOL? */
fpp_Putchar(global, '\n'); /* Output newline, if */
if (global->infile->fp == NULL) /* Expanding a macro, */
global->wrongline = FPP_TRUE; /* Output # line later */
}
} /* Continue until EOF */
if(global->showbalance) {
if(bracketlevel) {
fpp_cwarn(global, WARN_BRACKET_DEPTH, bracketlevel);
}
if(parenlevel) {
fpp_cwarn(global, WARN_PAREN_DEPTH, parenlevel);
}
if(bracelevel) {
fpp_cwarn(global, WARN_BRACE_DEPTH, bracelevel);
}
}
if (global->wflag) {
global->out = FPP_TRUE; /* enable fpp_output */
fpp_outdefines(global); /* Write out #defines */
}
return(FPP_OK);
}
FILE_LOCAL
ReturnCode fpp_output(struct Global *global, int c)
{
/*
* Output one character to stdout -- fpp_output() is passed as an
* argument to fpp_scanstring()
*/
#if COMMENT_INVISIBLE
if (c != TOK_SEP && c != COM_SEP)
#else
if (c != TOK_SEP)
#endif
fpp_Putchar(global, c);
return(FPP_OK);
}
void fpp_Putchar(struct Global *global, int c)
{
/*
* Output one character to stdout or to fpp_output function!
*/
if(!global->out)
return;
#if defined(UNIX)
if(global->output)
global->output(c, global->userdata);
else
putchar(c);
#else /* amiga */
global->output(c, global->userdata);
#endif
}
void fpp_Putstring(struct Global *global, char *string)
{
/*
* Output a string! One letter at a time to the fpp_Putchar routine!
*/
if(!string)
return;
while(*string)
fpp_Putchar(global, *string++);
}
void fpp_Putint(struct Global *global, int number)
{
/*
* Output the number as a string.
*/
char buffer[16]; /* an integer can't be that big! */
char *point=buffer;
sprintf(buffer, "%d", number);
while(*point)
fpp_Putchar(global, *point++);
}
FILE_LOCAL
void fpp_sharp(struct Global *global)
{
/*
* Output a line number line.
*/
char *name;
if (global->keepcomments) /* Make sure # comes on */
fpp_Putchar(global, '\n'); /* a fresh, new line. */
/* printf("#%s %d", LINE_PREFIX, global->line); */
fpp_Putchar(global, '#');
if(global->outputLINE)
fpp_Putstring(global, LINE_PREFIX);
fpp_Putchar(global, ' ');
fpp_Putint(global, global->line);
if (global->infile->fp != NULL) {
name = (global->infile->progname != NULL)
? global->infile->progname : global->infile->filename;
if (global->sharpfilename == NULL
|| (global->sharpfilename != NULL && !streq(name, global->sharpfilename))) {
if (global->sharpfilename != NULL)
free(global->sharpfilename);
global->sharpfilename = fpp_savestring(global, name);
/* printf(" \"%s\"", name); */
fpp_Putstring(global, " \"");
fpp_Putstring(global, name);
fpp_Putchar(global, '\"');
}
}
fpp_Putchar(global, '\n');
global->wrongline = FPP_FALSE;
return;
}

View file

@ -0,0 +1,774 @@
/******************************************************************************
Copyright (c) 1999 Daniel Stenberg
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.
******************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include "cppdef.h"
#include "cpp.h"
#ifdef _AMIGA
#include <proto/dos.h>
#endif
FILE_LOCAL void fpp_dump_line(struct Global *, int *);
FILE_LOCAL ReturnCode fpp_doif(struct Global *, int);
INLINE FILE_LOCAL ReturnCode fpp_doinclude(struct Global *);
INLINE FILE_LOCAL int fpp_hasdirectory(char *, char *);
/*
* Generate (by hand-inspection) a set of unique values for each control
* operator. Note that this is not guaranteed to work for non-Ascii
* machines. CPP won't compile if there are hash conflicts.
*/
#define L_assert ('a' + ('s' << 1))
#define L_define ('d' + ('f' << 1))
#define L_elif ('e' + ('i' << 1))
#define L_else ('e' + ('s' << 1))
#define L_endif ('e' + ('d' << 1))
#define L_error ('e' + ('r' << 1))
#define L_if ('i' + (EOS << 1))
#define L_ifdef ('i' + ('d' << 1))
#define L_ifndef ('i' + ('n' << 1))
#define L_include ('i' + ('c' << 1))
#define L_line ('l' + ('n' << 1))
#define L_nogood (EOS + (EOS << 1)) /* To catch #i */
#define L_pragma ('p' + ('a' << 1))
#define L_undef ('u' + ('d' << 1))
ReturnCode fpp_control( struct Global *global,
int *counter ) /* Pending newline counter */
{
/*
* Process #control lines. Simple commands are processed inline,
* while complex commands have their own subroutines.
*
* The counter is used to force out a newline before #line, and
* #pragma commands. This prevents these commands from ending up at
* the end of the previous line if cpp is invoked with the -C option.
*/
int c;
char *tp;
int hash;
char *ep;
ReturnCode ret;
c = fpp_skipws( global );
if( c == '\n' || c == EOF_CHAR )
{
(*counter)++;
return(FPP_OK);
}
if( !isdigit(c) )
fpp_scanid( global, c ); /* Get #word to tokenbuf */
else
{
fpp_unget( global ); /* Hack -- allow #123 as a */
strcpy( global->tokenbuf, "line" ); /* synonym for #line 123 */
}
hash = (global->tokenbuf[1] == EOS) ? L_nogood : (global->tokenbuf[0] + (global->tokenbuf[2] << 1));
switch( hash )
{
case L_assert:
tp = "assert";
break;
case L_define:
tp = "define";
break;
case L_elif:
tp = "elif";
break;
case L_else:
tp = "else";
break;
case L_endif:
tp = "endif";
break;
case L_error:
tp = "error";
break;
case L_if:
tp = "if";
break;
case L_ifdef:
tp = "ifdef";
break;
case L_ifndef:
tp = "ifndef";
break;
case L_include:
tp = "include";
break;
case L_line:
tp = "line";
break;
case L_pragma:
tp = "pragma";
break;
case L_undef:
tp = "undef";
break;
default:
hash = L_nogood;
case L_nogood:
tp = "";
break;
}
if( !streq( tp, global->tokenbuf ) )
hash = L_nogood;
/*
* hash is set to a unique value corresponding to the
* control keyword (or L_nogood if we think it's nonsense).
*/
if( global->infile->fp == NULL )
fpp_cwarn( global, WARN_CONTROL_LINE_IN_MACRO, global->tokenbuf );
if( !compiling )
{ /* Not compiling now */
switch( hash )
{
case L_if: /* These can't turn */
case L_ifdef: /* compilation on, but */
case L_ifndef: /* we must nest #if's */
if( ++global->ifptr >= &global->ifstack[BLK_NEST] )
{
fpp_cfatal( global, FATAL_TOO_MANY_NESTINGS, global->tokenbuf );
return( FPP_TOO_MANY_NESTED_STATEMENTS );
}
*global->ifptr = 0; /* !WAS_COMPILING */
case L_line: /* Many */
/*
* Are pragma's always processed?
*/
case L_pragma: /* options */
case L_include: /* are uninteresting */
case L_define: /* if we */
case L_undef: /* aren't */
case L_assert: /* compiling. */
case L_error:
fpp_dump_line( global, counter ); /* Ignore rest of line */
return(FPP_OK);
}
}
/*
* Make sure that #line and #pragma are output on a fresh line.
*/
if( *counter > 0 && (hash == L_line || hash == L_pragma) )
{
fpp_Putchar( global, '\n' );
(*counter)--;
}
switch( hash )
{
case L_line:
/*
* Parse the line to update the line number and "progname"
* field and line number for the next input line.
* Set wrongline to force it out later.
*/
c = fpp_skipws( global );
global->workp = global->work; /* Save name in work */
while( c != '\n' && c != EOF_CHAR )
{
if( (ret = fpp_save( global, c )) )
return(ret);
c = fpp_get( global );
}
fpp_unget( global );
if( (ret = fpp_save( global, EOS )) )
return(ret);
/*
* Split #line argument into <line-number> and <name>
* We subtract 1 as we want the number of the next line.
*/
global->line = atoi(global->work) - 1; /* Reset line number */
for( tp = global->work; isdigit(*tp) || type[(unsigned)*tp] == SPA; tp++)
; /* Skip over digits */
if( *tp != EOS )
{
/* Got a filename, so: */
if( *tp == '"' && (ep = strrchr(tp + 1, '"')) != NULL )
{
tp++; /* Skip over left quote */
*ep = EOS; /* And ignore right one */
}
if( global->infile->progname != NULL )
/* Give up the old name if it's allocated. */
free( global->infile->progname );
global->infile->progname = fpp_savestring( global, tp );
}
global->wrongline = FPP_TRUE; /* Force output later */
break;
case L_include:
ret = fpp_doinclude( global );
if( ret )
return(ret);
break;
case L_define:
ret = fpp_dodefine( global );
if( ret )
return(ret);
break;
case L_undef:
fpp_doundef( global );
break;
case L_else:
if( global->ifptr == &global->ifstack[0] )
{
fpp_cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf );
fpp_dump_line( global, counter );
return( FPP_OK );
}
else if( (*global->ifptr & ELSE_SEEN) != 0 )
{
fpp_cerror( global, ERROR_STRING_MAY_NOT_FOLLOW_ELSE, global->tokenbuf );
fpp_dump_line( global, counter );
return( FPP_OK );
}
*global->ifptr |= ELSE_SEEN;
if( (*global->ifptr & WAS_COMPILING) != 0 )
{
if( compiling || (*global->ifptr & FPP_TRUE_SEEN) != 0 )
compiling = FPP_FALSE;
else
{
compiling = FPP_TRUE;
}
}
break;
case L_elif:
if( global->ifptr == &global->ifstack[0] )
{
fpp_cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf );
fpp_dump_line( global, counter );
return( FPP_OK );
}
else if( (*global->ifptr & ELSE_SEEN) != 0 )
{
fpp_cerror( global, ERROR_STRING_MAY_NOT_FOLLOW_ELSE, global->tokenbuf );
fpp_dump_line( global, counter );
return( FPP_OK );
}
if( (*global->ifptr & (WAS_COMPILING | FPP_TRUE_SEEN)) != WAS_COMPILING )
{
compiling = FPP_FALSE; /* Done compiling stuff */
fpp_dump_line( global, counter ); /* Skip this clause */
return( FPP_OK );
}
ret = fpp_doif( global, L_if );
if( ret )
return(ret);
break;
case L_error:
fpp_cerror(global, ERROR_ERROR);
break;
case L_if:
case L_ifdef:
case L_ifndef:
if( ++global->ifptr < &global->ifstack[BLK_NEST] )
{
*global->ifptr = WAS_COMPILING;
ret = fpp_doif( global, hash );
if( ret )
return(ret);
break;
}
fpp_cfatal( global, FATAL_TOO_MANY_NESTINGS, global->tokenbuf );
return( FPP_TOO_MANY_NESTED_STATEMENTS );
case L_endif:
if( global->ifptr == &global->ifstack[0] )
{
fpp_cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf );
fpp_dump_line( global, counter );
return(FPP_OK);
}
if( !compiling && (*global->ifptr & WAS_COMPILING) != 0 )
global->wrongline = FPP_TRUE;
compiling = ((*global->ifptr & WAS_COMPILING) != 0);
--global->ifptr;
break;
case L_assert:
{
int result;
ret = fpp_eval( global, &result );
if(ret)
return(ret);
if( result == 0 )
fpp_cerror( global, ERROR_PREPROC_FAILURE );
}
break;
case L_pragma:
/*
* #pragma is provided to pass "options" to later
* passes of the compiler. cpp doesn't have any yet.
*/
fpp_Putstring( global, "#pragma " );
while( (c = fpp_get( global ) ) != '\n' && c != EOF_CHAR )
fpp_Putchar( global, c );
fpp_unget( global );
fpp_Putchar( global, '\n' );
break;
default:
/*
* Undefined #control keyword.
* Note: the correct behavior may be to warn and
* pass the line to a subsequent compiler pass.
* This would allow #asm or similar extensions.
*/
if( global->warnillegalcpp )
fpp_cwarn( global, WARN_ILLEGAL_COMMAND, global->tokenbuf );
fpp_Putchar( global, '#' );
fpp_Putstring( global, global->tokenbuf );
fpp_Putchar( global, ' ' );
while( (c = fpp_get( global ) ) != '\n' && c != EOF_CHAR )
fpp_Putchar( global, c );
fpp_unget( global );
fpp_Putchar( global, '\n' );
break;
}
if( hash != L_include )
{
#if OLD_PREPROCESSOR
/*
* Ignore the rest of the #control line so you can write
* #if foo
* #endif foo
*/
fpp_dump_line( global, counter ); /* Take common exit */
return( FPP_OK );
#else
if( fpp_skipws( global ) != '\n' )
{
fpp_cwarn( global, WARN_UNEXPECTED_TEXT_IGNORED );
fpp_skipnl( global );
}
#endif
}
(*counter)++;
return( FPP_OK );
}
FILE_LOCAL
void fpp_dump_line(struct Global *global, int *counter)
{
fpp_skipnl( global ); /* Ignore rest of line */
(*counter)++;
}
FILE_LOCAL
ReturnCode fpp_doif(struct Global *global, int hash)
{
/*
* Process an #if, #ifdef, or #ifndef. The latter two are straightforward,
* while #if needs a subroutine of its own to evaluate the expression.
*
* fpp_doif() is called only if compiling is FPP_TRUE. If false, compilation
* is always supressed, so we don't need to evaluate anything. This
* supresses unnecessary warnings.
*/
int c;
int found;
ReturnCode ret;
if( (c = fpp_skipws( global ) ) == '\n' || c == EOF_CHAR )
{
fpp_unget( global );
fpp_cerror( global, ERROR_MISSING_ARGUMENT );
#if !OLD_PREPROCESSOR
fpp_skipnl( global ); /* Prevent an extra */
fpp_unget( global ); /* Error message */
#endif
return(FPP_OK);
}
if( hash == L_if )
{
fpp_unget( global );
ret = fpp_eval( global, &found );
if( ret )
return( ret );
found = (found != 0); /* Evaluate expr, != 0 is FPP_TRUE */
hash = L_ifdef; /* #if is now like #ifdef */
}
else
{
if( type[c] != LET )
{ /* Next non-blank isn't letter */
/* ... is an error */
fpp_cerror( global, ERROR_MISSING_ARGUMENT );
#if !OLD_PREPROCESSOR
fpp_skipnl( global ); /* Prevent an extra */
fpp_unget( global ); /* Error message */
#endif
return(FPP_OK);
}
found = ( fpp_lookid( global, c ) != NULL ); /* Look for it in symbol table */
}
if( found == (hash == L_ifdef) )
{
compiling = FPP_TRUE;
*global->ifptr |= FPP_TRUE_SEEN;
}
else
compiling = FPP_FALSE;
return(FPP_OK);
}
INLINE FILE_LOCAL
ReturnCode fpp_doinclude( struct Global *global )
{
/*
* Process the #include control line.
* There are three variations:
*
* #include "file" search somewhere relative to the
* current source file, if not found,
* treat as #include <file>.
*
* #include <file> Search in an implementation-dependent
* list of places.
*
* #include token Expand the token, it must be one of
* "file" or <file>, process as such.
*
* Note: the November 12 draft forbids '>' in the #include <file> format.
* This restriction is unnecessary and not implemented.
*/
int c;
int delim;
ReturnCode ret;
delim = fpp_skipws( global );
if( (ret = fpp_macroid( global, &delim )) )
return(ret);
if( delim != '<' && delim != '"' )
{
fpp_cerror( global, ERROR_INCLUDE_SYNTAX );
return( FPP_OK );
}
if( delim == '<' )
delim = '>';
global->workp = global->work;
while( (c = fpp_get(global)) != '\n' && c != EOF_CHAR )
if( (ret = fpp_save( global, c )) ) /* Put it away. */
return( ret );
fpp_unget( global ); /* Force nl after include */
/*
* The draft is unclear if the following should be done.
*/
while( --global->workp >= global->work &&
(*global->workp == ' ' || *global->workp == '\t') )
; /* Trim blanks from filename */
if( *global->workp != delim )
{
fpp_cerror( global, ERROR_INCLUDE_SYNTAX );
return(FPP_OK);
}
*global->workp = EOS; /* Terminate filename */
ret = fpp_openinclude( global, global->work, (delim == '"') );
if( ret && global->warnnoinclude )
{
/*
* Warn if #include file isn't there.
*/
fpp_cwarn( global, WARN_CANNOT_OPEN_INCLUDE, global->work );
}
return( FPP_OK );
}
#ifdef _AMIGA
ReturnCode MultiAssignLoad( struct Global *global, char *incptr, char *filename, char *tmpname );
#endif
ReturnCode fpp_openinclude( struct Global *global,
char *filename, /* Input file name */
int searchlocal ) /* FPP_TRUE if #include "file" */
{
/*
* Actually open an include file. This routine is only called from
* fpp_doinclude() above, but was written as a separate subroutine for
* programmer convenience. It searches the list of directories
* and actually opens the file, linking it into the list of
* active files. Returns ReturnCode. No error message is printed.
*/
char **incptr;
char tmpname[NWORK]; /* Filename work area */
size_t len;
if( filename[0] == '/' )
{
if( ! fpp_openfile( global, filename ) )
return(FPP_OK);
}
if( searchlocal && global->allowincludelocal )
{
/*
* Look in local directory first.
* Try to open filename relative to the directory of the current
* source file (as opposed to the current directory). (ARF, SCK).
* Note that the fully qualified pathname is always built by
* discarding the last pathname component of the source file
* name then tacking on the #include argument.
*/
if( fpp_hasdirectory( global->infile->filename, tmpname ) )
strcat( tmpname, filename );
else
strcpy( tmpname, filename );
if( ! fpp_openfile( global, tmpname ) )
return(FPP_OK);
}
/*
* Look in any directories specified by -I command line
* arguments, then in the builtin search list.
*/
for( incptr = global->incdir; incptr < global->incend; incptr++ )
{
len = strlen(*incptr);
if( len + strlen(filename) >= sizeof(tmpname) )
{
fpp_cfatal( global, FATAL_FILENAME_BUFFER_OVERFLOW );
return( FPP_FILENAME_BUFFER_OVERFLOW );
}
else
{
if( (*incptr)[len-1] != '/' )
sprintf( tmpname, "%s/%s", *incptr, filename );
else
sprintf( tmpname, "%s%s", *incptr, filename );
if( !fpp_openfile( global, tmpname ) )
return(FPP_OK);
}
}
return( FPP_NO_INCLUDE );
}
INLINE FILE_LOCAL
int fpp_hasdirectory( char *source, /* Directory to examine */
char *result ) /* Put directory stuff here */
{
/*
* If a device or directory is found in the source filename string, the
* node/device/directory part of the string is copied to result and
* fpp_hasdirectory returns FPP_TRUE. Else, nothing is copied and it returns FPP_FALSE.
*/
char *tp2;
if( (tp2 = strrchr( source, '/' ) ) == NULL )
return(FPP_FALSE);
strncpy( result, source, tp2 - source + 1 );
result[tp2 - source + 1] = EOS;
return( FPP_TRUE );
}
#ifdef _AMIGA
//
// amp July 9, 1997
//
// Use the OS Luke...
//
// We do the sneaky version and let the OS do all
// the hard work so we don't have to mess around
// a lot ;)
//
ReturnCode MultiAssignLoad( struct Global *global, char *incptr, char *filename, char *tmpname )
{ /* MultiAssignLoad */
struct MsgPort *FSTask;
struct DevProc *DevProc = NULL;
LONG RtnCode = FPP_NO_INCLUDE;
FSTask = GetFileSysTask();
do
{
//
// This should not bring up a requester.
// check to see if cpp does in fact tweek
// the process WindowPtr.
//
DevProc = GetDeviceProc( incptr, DevProc );
if( DevProc )
{
SetFileSysTask( DevProc->dvp_Port );
//
// Normally we would pass the lock and filename
// to the Load() routine, which would CD to the
// directory and Open(filename), but in order to
// satisfy the exisiting fpp_openfile() function, we
// bite the bullet and build the complete pathspec
// rather than add the standard Load() routine.
//
if( NameFromLock( DevProc->dvp_Lock, tmpname, NWORK ) )
{
AddPart( tmpname, filename, NWORK );
RtnCode = fpp_openfile( global, tmpname );
if( ! RtnCode )
break;
}
}
} while ( RtnCode &&
DevProc &&
(DevProc->dvp_Flags & DVPF_ASSIGN) &&
IoErr() == ERROR_OBJECT_NOT_FOUND); /* repeat if multi-assign */
SetFileSysTask( FSTask );
if( DevProc )
FreeDeviceProc( DevProc );
return RtnCode;
} /* MultiAssignLoad */
#endif //_AMIGA

View file

@ -0,0 +1,413 @@
/******************************************************************************
Copyright (c) 1999 Daniel Stenberg
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.
******************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include <time.h> /*OIS*0.92*/
#include "cppdef.h"
#include "cpp.h"
ReturnCode fpp_openfile(struct Global *global, char *filename)
{
/*
* Open a file, add it to the linked list of open files.
* This is called only from fpp_openfile() in cpp2.c.
*/
FILE *fp;
ReturnCode ret;
if (global->openfile)
fp = global->openfile(filename, "r", global->userdata);
else
fp = fopen(filename, "r");
if (fp == NULL)
ret=FPP_OPEN_ERROR;
else
ret=fpp_addfile(global, fp, filename);
if(!ret && global->depends) {
global->depends(filename, global->userdata);
}
if(!ret && global->showincluded) {
/* no error occured! */
fpp_Error(global, "cpp: included \"");
fpp_Error(global, filename);
fpp_Error(global, "\"\n");
}
return(ret);
}
ReturnCode fpp_addfile(struct Global *global,
FILE *fp, /* Open file pointer */
char *filename) /* Name of the file */
{
/*
* Initialize tables for this open file. This is called from fpp_openfile()
* above (for #include files), and from the entry to cpp to open the main
* input file. It calls a common routine, fpp_getfile() to build the FILEINFO
* structure which is used to read characters. (fpp_getfile() is also called
* to setup a macro replacement.)
*/
FILEINFO *file;
ReturnCode ret;
ret = fpp_getfile(global, NBUFF, filename, &file);
if(ret)
return(ret);
file->fp = fp; /* Better remember FILE * */
file->buffer[0] = EOS; /* Initialize for first read */
global->line = 1; /* Working on line 1 now */
global->wrongline = FPP_TRUE; /* Force out initial #line */
return(FPP_OK);
}
int fpp_dooptions(struct Global *global, struct fppTag *tags)
{
/*
* fpp_dooptions is called to process command line arguments (-Detc).
* It is called only at cpp startup.
*/
DEFBUF *dp;
char end=FPP_FALSE; /* end of taglist */
while(tags && !end) {
switch(tags->tag) {
case FPPTAG_END:
end=FPP_TRUE;
break;
case FPPTAG_INITFUNC:
global->initialfunc = (char *) tags->data;
break;
case FPPTAG_DISPLAYFUNCTIONS:
global->outputfunctions = tags->data?1:0;
break;
case FPPTAG_RIGHTCONCAT:
global->rightconcat = tags->data?1:0;
break;
case FPPTAG_OUTPUTMAIN:
global->outputfile = tags->data?1:0;
break;
case FPPTAG_NESTED_COMMENTS:
global->nestcomments = tags->data?1:0;
break;
case FPPTAG_WARNMISSINCLUDE:
global->warnnoinclude = tags->data?1:0;
break;
case FPPTAG_WARN_NESTED_COMMENTS:
global->warnnestcomments = tags->data?1:0;
break;
case FPPTAG_OUTPUTSPACE:
global->showspace = tags->data?1:0;
break;
case FPPTAG_OUTPUTBALANCE:
global->showbalance = tags->data?1:0;
break;
case FPPTAG_OUTPUTINCLUDES:
global->showincluded = tags->data?1:0;
break;
case FPPTAG_SHOWVERSION:
global->showversion = tags->data?1:0;
break;
case FPPTAG_WARNILLEGALCPP:
global->warnillegalcpp = tags->data?1:0;
break;
case FPPTAG_OUTPUTLINE:
global->outputLINE = tags->data?1:0;
break;
case FPPTAG_KEEPCOMMENTS:
if(tags->data) {
global->cflag = FPP_TRUE;
global->keepcomments = FPP_TRUE;
}
break;
case FPPTAG_DEFINE:
/*
* If the option is just "-Dfoo", make it -Dfoo=1
*/
{
char *symbol=(char *)tags->data;
char *text=symbol;
while (*text != EOS && *text != '=')
text++;
if (*text == EOS)
text = "1";
else
*text++ = EOS;
/*
* Now, save the word and its definition.
*/
dp = fpp_defendel(global, symbol, FPP_FALSE);
if(!dp)
return(FPP_OUT_OF_MEMORY);
dp->repl = fpp_savestring(global, text);
dp->nargs = DEF_NOARGS;
}
break;
case FPPTAG_IGNORE_NONFATAL:
global->eflag = FPP_TRUE;
break;
case FPPTAG_INCLUDE_DIR:
if (global->incend >= &global->incdir[NINCLUDE]) {
fpp_cfatal(global, FATAL_TOO_MANY_INCLUDE_DIRS);
return(FPP_TOO_MANY_INCLUDE_DIRS);
}
*global->incend++ = (char *)tags->data;
break;
case FPPTAG_INCLUDE_FILE:
case FPPTAG_INCLUDE_MACRO_FILE:
if (global->included >= NINCLUDE) {
fpp_cfatal(global, FATAL_TOO_MANY_INCLUDE_FILES);
return(FPP_TOO_MANY_INCLUDE_FILES);
}
global->include[(unsigned)global->included] = (char *)tags->data;
global->includeshow[(unsigned)global->included] =
(tags->tag == FPPTAG_INCLUDE_FILE);
global->included++;
break;
case FPPTAG_BUILTINS:
global->nflag|=(tags->data?NFLAG_BUILTIN:0);
break;
case FPPTAG_PREDEFINES:
global->nflag|=(tags->data?NFLAG_PREDEFINE:0);
break;
case FPPTAG_IGNORE_CPLUSPLUS:
global->cplusplus=!tags->data;
break;
case FPPTAG_SIZEOF_TABLE:
{
SIZES *sizp; /* For -S */
int size; /* For -S */
int isdatum; /* FPP_FALSE for -S* */
int endtest; /* For -S */
char *text=(char *)tags->data;
sizp = size_table;
if ((isdatum = (*text != '*'))) /* If it's just -S, */
endtest = T_FPTR; /* Stop here */
else { /* But if it's -S* */
text++; /* Step over '*' */
endtest = 0; /* Stop at end marker */
}
while (sizp->bits != endtest && *text != EOS) {
if (!isdigit(*text)) { /* Skip to next digit */
text++;
continue;
}
size = 0; /* Compile the value */
while (isdigit(*text)) {
size *= 10;
size += (*text++ - '0');
}
if (isdatum)
sizp->size = size; /* Datum size */
else
sizp->psize = size; /* Pointer size */
sizp++;
}
if (sizp->bits != endtest)
fpp_cwarn(global, WARN_TOO_FEW_VALUES_TO_SIZEOF, NULL);
else if (*text != EOS)
fpp_cwarn(global, WARN_TOO_MANY_VALUES_TO_SIZEOF, NULL);
}
break;
case FPPTAG_UNDEFINE:
if (fpp_defendel(global, (char *)tags->data, FPP_TRUE) == NULL)
fpp_cwarn(global, WARN_NOT_DEFINED, tags->data);
break;
case FPPTAG_OUTPUT_DEFINES:
global->wflag++;
break;
case FPPTAG_INPUT_NAME:
strcpy(global->work, tags->data); /* Remember input filename */
global->first_file=tags->data;
break;
case FPPTAG_DEPENDS:
global->depends=(void (*)(char *, void *))tags->data;
break;
case FPPTAG_INPUT:
global->input=(char *(*)(char *, int, void *))tags->data;
break;
case FPPTAG_OUTPUT:
global->output=(void (*)(int, void *))tags->data;
break;
case FPPTAG_ERROR:
global->error=(void (*)(void *, char *, va_list))tags->data;
break;
case FPPTAG_USERDATA:
global->userdata=tags->data;
break;
case FPPTAG_LINE:
global->linelines= tags->data?1:0;
break;
case FPPTAG_EXCLFUNC:
global->excludedinit[ global->excluded++ ] = (char *)tags->data;
break;
case FPPTAG_WEBMODE:
global->webmode=(tags->data?1:0);
break;
case FPPTAG_ALLOW_INCLUDE_LOCAL:
global->allowincludelocal=(tags->data?1:0);
break;
case FPPTAG_FILEOPENFUNC:
global->openfile = (FILE* (*)(char *,char *,void *))tags->data;
break;
default:
fpp_cwarn(global, WARN_INTERNAL_ERROR, NULL);
break;
}
tags++;
}
return(0);
}
ReturnCode fpp_initdefines(struct Global *global)
{
/*
* Initialize the built-in #define's. There are two flavors:
* #define decus 1 (static definitions)
* #define __FILE__ ?? (dynamic, evaluated by magic)
* Called only on cpp startup.
*
* Note: the built-in static definitions are supressed by the -N option.
* __LINE__, __FILE__, __TIME__ and __DATE__ are always present.
*/
char **pp;
char *tp;
DEFBUF *dp;
struct tm *tm;
int i;
time_t tvec;
static char months[12][4] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
/*
* Predefine the built-in symbols. Allow the
* implementor to pre-define a symbol as "" to
* eliminate it.
*/
if (!(global->nflag & NFLAG_BUILTIN)) {
for (pp = global->preset; *pp != NULL; pp++) {
if (*pp[0] != EOS) {
dp = fpp_defendel(global, *pp, FPP_FALSE);
if(!dp)
return(FPP_OUT_OF_MEMORY);
dp->repl = fpp_savestring(global, "1");
dp->nargs = DEF_NOARGS;
}
}
}
/*
* The magic pre-defines (__FILE__ and __LINE__ are
* initialized with negative argument counts. fpp_expand()
* notices this and calls the appropriate routine.
* DEF_NOARGS is one greater than the first "magic" definition.
*/
if (!(global->nflag & NFLAG_PREDEFINE)) {
for (pp = global->magic, i = DEF_NOARGS; *pp != NULL; pp++) {
dp = fpp_defendel(global, *pp, FPP_FALSE);
if(!dp)
return(FPP_OUT_OF_MEMORY);
dp->nargs = --i;
}
#if OK_DATE
/*
* Define __DATE__ as today's date.
*/
dp = fpp_defendel(global, "__DATE__", FPP_FALSE);
tp = malloc(32);
if(!tp || !dp)
return(FPP_OUT_OF_MEMORY);
dp->repl = tp;
dp->nargs = DEF_NOARGS;
time(&tvec);
tm = localtime(&tvec);
sprintf(tp, "\"%3s %2d %4d\"", /* "Aug 20 1988" */
months[tm->tm_mon],
tm->tm_mday,
tm->tm_year + 1900);
/*
* Define __TIME__ as this moment's time.
*/
dp = fpp_defendel(global, "__TIME__", FPP_FALSE);
tp = malloc(11);
if(!tp || !dp)
return(FPP_OUT_OF_MEMORY);
dp->repl = tp;
dp->nargs = DEF_NOARGS;
sprintf(tp, "\"%2d:%02d:%02d\"", /* "20:42:31" */
tm->tm_hour,
tm->tm_min,
tm->tm_sec);
#endif
}
return(FPP_OK);
}
void fpp_delbuiltindefines(struct Global *global)
{
/*
* Delete the built-in #define's.
*/
char **pp;
/*
* Delete the built-in symbols, unless -WW.
*/
if (global->wflag < 2) {
for (pp = global->preset; *pp != NULL; pp++) {
fpp_defendel(global, *pp, FPP_TRUE);
}
}
/*
* The magic pre-defines __FILE__ and __LINE__
*/
for (pp = global->magic; *pp != NULL; pp++) {
fpp_defendel(global, *pp, FPP_TRUE);
}
#if OK_DATE
/*
* Undefine __DATE__.
*/
fpp_defendel(global, "__DATE__", FPP_TRUE);
/*
* Undefine __TIME__.
*/
fpp_defendel(global, "__TIME__", FPP_TRUE);
#endif
return;
}

View file

@ -0,0 +1,634 @@
/******************************************************************************
Copyright (c) 1999 Daniel Stenberg
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.
******************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include "cppdef.h"
#include "cpp.h"
INLINE FILE_LOCAL ReturnCode fpp_checkparm(struct Global *, int, DEFBUF *, int);
INLINE FILE_LOCAL ReturnCode fpp_stparmscan(struct Global *, int);
INLINE FILE_LOCAL ReturnCode fpp_textput(struct Global *, char *);
FILE_LOCAL ReturnCode fpp_charput(struct Global *, int);
INLINE FILE_LOCAL ReturnCode fpp_expcollect(struct Global *);
INLINE FILE_LOCAL char *fpp_doquoting(char *, char *);
ReturnCode fpp_dodefine(struct Global *global)
{
/*
* Called from control when a #define is scanned. This module
* parses formal parameters and the replacement string. When
* the formal parameter name is encountered in the replacement
* string, it is replaced by a character in the range 128 to
* 128+NPARAM (this allows up to 32 parameters within the
* Dec Multinational range). If cpp is ported to an EBCDIC
* machine, you will have to make other arrangements.
*
* There is some special case code to distinguish
* #define foo bar
* from #define foo() bar
*
* Also, we make sure that
* #define foo foo
* expands to "foo" but doesn't put cpp into an infinite loop.
*
* A warning message is printed if you redefine a symbol to a
* different text. I.e,
* #define foo 123
* #define foo 123
* is ok, but
* #define foo 123
* #define foo +123
* is not.
*
* The following subroutines are called from define():
* fpp_checkparm called when a token is scanned. It checks through the
* array of formal parameters. If a match is found, the
* token is replaced by a control byte which will be used
* to locate the parameter when the macro is expanded.
* fpp_textput puts a string in the macro work area (parm[]), updating
* parmp to point to the first free byte in parm[].
* fpp_textput() tests for work buffer overflow.
* fpp_charput puts a single character in the macro work area (parm[])
* in a manner analogous to fpp_textput().
*/
int c;
DEFBUF *dp; /* -> new definition */
int isredefine; /* FPP_TRUE if redefined */
char *old = NULL; /* Remember redefined */
ReturnCode ret;
#if OK_CONCAT
int quoting; /* Remember we saw a # */
#endif
if (type[(c = fpp_skipws(global))] != LET) {
fpp_cerror(global, ERROR_DEFINE_SYNTAX);
global->inmacro = FPP_FALSE; /* Stop <newline> hack */
return(FPP_OK);
}
isredefine = FPP_FALSE; /* Set if redefining */
if ((dp = fpp_lookid(global, c)) == NULL) { /* If not known now */
dp = fpp_defendel(global, global->tokenbuf, FPP_FALSE); /* Save the name */
if(!dp)
return(FPP_OUT_OF_MEMORY);
} else { /* It's known: */
isredefine = FPP_TRUE; /* Remember this fact */
old = dp->repl; /* Remember replacement */
dp->repl = NULL; /* No replacement now */
}
global->parlist[0] = global->parmp = global->parm; /* Setup parm buffer */
if ((c = fpp_get(global)) == '(') { /* With arguments? */
global->nargs = 0; /* Init formals counter */
do { /* Collect formal parms */
if (global->nargs >= LASTPARM) {
fpp_cfatal(global, FATAL_TOO_MANY_ARGUMENTS_MACRO);
return(FPP_TOO_MANY_ARGUMENTS);
} else if ((c = fpp_skipws(global)) == ')')
break; /* Got them all */
else if (type[c] != LET) { /* Bad formal syntax */
fpp_cerror(global, ERROR_DEFINE_SYNTAX);
global->inmacro = FPP_FALSE; /* Stop <newline> hack */
return(FPP_OK);
}
fpp_scanid(global, c); /* Get the formal param */
global->parlist[global->nargs++] = global->parmp; /* Save its start */
ret=fpp_textput(global, global->tokenbuf); /* Save text in parm[] */
if(ret)
return(ret);
} while ((c = fpp_skipws(global)) == ','); /* Get another argument */
if (c != ')') { /* Must end at ) */
fpp_cerror(global, ERROR_DEFINE_SYNTAX);
global->inmacro = FPP_FALSE; /* Stop <newline> hack */
return(FPP_OK);
}
c = ' '; /* Will skip to body */
}
else {
/*
* DEF_NOARGS is needed to distinguish between
* "#define foo" and "#define foo()".
*/
global->nargs = DEF_NOARGS; /* No () parameters */
}
if (type[c] == SPA) /* At whitespace? */
c = fpp_skipws(global); /* Not any more. */
global->workp = global->work; /* Replacement put here */
global->inmacro = FPP_TRUE; /* Keep \<newline> now */
quoting = 0; /* No # seen yet. */
while (c != EOF_CHAR && c != '\n') { /* Compile macro body */
#if OK_CONCAT
if (c == '#') { /* Token concatenation? */
if ((c = fpp_get(global)) != '#') { /* No, not really */
quoting = 1; /* Maybe quoting op. */
continue;
}
while (global->workp > global->work && type[(unsigned)*(global->workp - 1)] == SPA)
--global->workp; /* Erase leading spaces */
// if ((ret=save(global, TOK_SEP))) /* Stuff a delimiter */
// return(ret);
c = fpp_skipws(global); /* Eat whitespace */
continue;
}
#endif
switch (type[c]) {
case LET:
#if OK_CONCAT
ret=fpp_checkparm(global, c, dp, quoting); /* Might be a formal */
#else
ret=fpp_checkparm(c, dp); /* Might be a formal */
#endif
if(ret)
return(ret);
break;
case DIG: /* Number in mac. body */
case DOT: /* Maybe a float number */
ret=fpp_scannumber(global, c, fpp_save); /* Scan it off */
if(ret)
return(ret);
break;
case QUO: /* String in mac. body */
ret=fpp_stparmscan(global, c);
if(ret)
return(ret);
break;
case BSH: /* Backslash */
ret=fpp_save(global, '\\');
if(ret)
return(ret);
if ((c = fpp_get(global)) == '\n')
global->wrongline = FPP_TRUE;
ret=fpp_save(global, c);
if(ret)
return(ret);
break;
case SPA: /* Absorb whitespace */
/*
* Note: the "end of comment" marker is passed on
* to allow comments to separate tokens.
*/
if (global->workp[-1] == ' ') /* Absorb multiple */
break; /* spaces */
else if (c == '\t')
c = ' '; /* Normalize tabs */
/* Fall through to store character */
default: /* Other character */
ret=fpp_save(global, c);
if(ret)
return(ret);
break;
}
c = fpp_get(global);
quoting = 0; /* Only when immediately*/
/* preceding a formal */
}
global->inmacro = FPP_FALSE; /* Stop newline hack */
fpp_unget(global); /* For control check */
if (global->workp > global->work && global->workp[-1] == ' ') /* Drop trailing blank */
global->workp--;
*global->workp = EOS; /* Terminate work */
dp->repl = fpp_savestring(global, global->work); /* Save the string */
dp->nargs = global->nargs; /* Save arg count */
if (isredefine) { /* Error if redefined */
if ((old != NULL && dp->repl != NULL && !streq(old, dp->repl))
|| (old == NULL && dp->repl != NULL)
|| (old != NULL && dp->repl == NULL)) {
fpp_cerror(global, ERROR_REDEFINE, dp->name);
}
if (old != NULL) /* We don't need the */
free(old); /* old definition now. */
}
return(FPP_OK);
}
INLINE FILE_LOCAL
ReturnCode fpp_checkparm(struct Global *global,
int c,
DEFBUF *dp,
int quoting) /* Preceded by a # ? */
{
/*
* Replace this param if it's defined. Note that the macro name is a
* possible replacement token. We stuff DEF_MAGIC in front of the token
* which is treated as a LETTER by the token scanner and eaten by
* the fpp_output routine. This prevents the macro expander from
* looping if someone writes "#define foo foo".
*/
int i;
char *cp;
ReturnCode ret=FPP_OK;
fpp_scanid(global, c); /* Get parm to tokenbuf */
for (i = 0; i < global->nargs; i++) { /* For each argument */
if (streq(global->parlist[i], global->tokenbuf)) { /* If it's known */
#if OK_CONCAT
if (quoting) { /* Special handling of */
ret=fpp_save(global, QUOTE_PARM); /* #formal inside defn */
if(ret)
return(ret);
}
#endif
ret=fpp_save(global, i + MAC_PARM); /* Save a magic cookie */
return(ret); /* And exit the search */
}
}
if (streq(dp->name, global->tokenbuf)) /* Macro name in body? */
ret=fpp_save(global, DEF_MAGIC); /* Save magic marker */
for (cp = global->tokenbuf; *cp != EOS;) /* And fpp_save */
ret=fpp_save(global, *cp++); /* The token itself */
return(ret);
}
INLINE FILE_LOCAL
ReturnCode fpp_stparmscan(struct Global *global, int delim)
{
/*
* Normal string parameter scan.
*/
unsigned char *wp;
int i;
ReturnCode ret;
wp = (unsigned char *)global->workp; /* Here's where it starts */
ret=fpp_scanstring(global, delim, fpp_save);
if(ret)
return(ret); /* Exit on fpp_scanstring error */
global->workp[-1] = EOS; /* Erase trailing quote */
wp++; /* -> first string content byte */
for (i = 0; i < global->nargs; i++) {
if (streq(global->parlist[i], (char *)wp)) {
*wp++ = MAC_PARM + PAR_MAC; /* Stuff a magic marker */
*wp++ = (i + MAC_PARM); /* Make a formal marker */
*wp = wp[-3]; /* Add on closing quote */
global->workp = (char *)wp + 1; /* Reset string end */
return(FPP_OK);
}
}
global->workp[-1] = wp[-1]; /* Nope, reset end quote. */
return(FPP_OK);
}
void fpp_doundef(struct Global *global)
/*
* Remove the symbol from the defined list.
* Called from the #control processor.
*/
{
int c;
if (type[(c = fpp_skipws(global))] != LET)
fpp_cerror(global, ERROR_ILLEGAL_UNDEF);
else {
fpp_scanid(global, c); /* Get name to tokenbuf */
(void) fpp_defendel(global, global->tokenbuf, FPP_TRUE);
}
}
INLINE FILE_LOCAL
ReturnCode fpp_textput(struct Global *global, char *text)
{
/*
* Put the string in the parm[] buffer.
*/
size_t size;
size = strlen(text) + 1;
if ((global->parmp + size) >= &global->parm[NPARMWORK]) {
fpp_cfatal(global, FATAL_MACRO_AREA_OVERFLOW);
return(FPP_WORK_AREA_OVERFLOW);
} else {
strcpy(global->parmp, text);
global->parmp += size;
}
return(FPP_OK);
}
FILE_LOCAL
ReturnCode fpp_charput(struct Global *global, int c)
{
/*
* Put the byte in the parm[] buffer.
*/
if (global->parmp >= &global->parm[NPARMWORK]) {
fpp_cfatal(global, FATAL_MACRO_AREA_OVERFLOW);
return(FPP_WORK_AREA_OVERFLOW);
}
*global->parmp++ = c;
return(FPP_OK);
}
/*
* M a c r o E x p a n s i o n
*/
ReturnCode fpp_expand(struct Global *global, DEFBUF *tokenp)
{
/*
* Expand a macro. Called from the cpp mainline routine (via subroutine
* fpp_macroid()) when a token is found in the symbol table. It calls
* fpp_expcollect() to parse actual parameters, checking for the correct number.
* It then creates a "file" containing a single line containing the
* macro with actual parameters inserted appropriately. This is
* "pushed back" onto the input stream. (When the fpp_get() routine runs
* off the end of the macro line, it will dismiss the macro itself.)
*/
int c;
FILEINFO *file;
ReturnCode ret=FPP_OK;
/*
* If no macro is pending, save the name of this macro
* for an eventual error message.
*/
if (global->recursion++ == 0)
global->macro = tokenp;
else if (global->recursion == RECURSION_LIMIT) {
fpp_cerror(global, ERROR_RECURSIVE_MACRO, tokenp->name, global->macro->name);
if (global->rec_recover) {
do {
c = fpp_get(global);
} while (global->infile != NULL && global->infile->fp == NULL);
fpp_unget(global);
global->recursion = 0;
return(FPP_OK);
}
}
/*
* Here's a macro to expand.
*/
global->nargs = 0; /* Formals counter */
global->parmp = global->parm; /* Setup parm buffer */
switch (tokenp->nargs) {
case (-2): /* __LINE__ */
if(global->infile->fp)
/* This is a file */
sprintf(global->work, "%d", global->line);
else
/* This is a macro! Find out the file line number! */
for (file = global->infile; file != NULL; file = file->parent) {
if (file->fp != NULL) {
sprintf(global->work, "%d", file->line);
break;
}
}
ret=fpp_ungetstring(global, global->work);
if(ret)
return(ret);
break;
case (-3): /* __FILE__ */
for (file = global->infile; file != NULL; file = file->parent) {
if (file->fp != NULL) {
sprintf(global->work, "\"%s\"", (file->progname != NULL)
? file->progname : file->filename);
ret=fpp_ungetstring(global, global->work);
if(ret)
return(ret);
break;
}
}
break;
case (-4): /* __FUNC__ */
sprintf(global->work, "\"%s\"", global->functionname[0]?
global->functionname : "<unknown function>");
ret=fpp_ungetstring(global, global->work);
if(ret)
return(ret);
break;
case (-5): /* __FUNC_LINE__ */
sprintf(global->work, "%d", global->funcline);
ret=fpp_ungetstring(global, global->work);
if(ret)
return(ret);
break;
default:
/*
* Nothing funny about this macro.
*/
if (tokenp->nargs < 0) {
fpp_cfatal(global, FATAL_ILLEGAL_MACRO, tokenp->name);
return(FPP_ILLEGAL_MACRO);
}
while ((c = fpp_skipws(global)) == '\n') /* Look for (, skipping */
global->wrongline = FPP_TRUE; /* spaces and newlines */
if (c != '(') {
/*
* If the programmer writes
* #define foo() ...
* ...
* foo [no ()]
* just write foo to the output stream.
*/
fpp_unget(global);
fpp_cwarn(global, WARN_MACRO_NEEDS_ARGUMENTS, tokenp->name);
/* fputs(tokenp->name, stdout); */
fpp_Putstring(global, tokenp->name);
return(FPP_OK);
} else if (!(ret=fpp_expcollect(global))) { /* Collect arguments */
if (tokenp->nargs != global->nargs) { /* Should be an error? */
fpp_cwarn(global, WARN_WRONG_NUMBER_ARGUMENTS, tokenp->name);
}
} else { /* Collect arguments */
return(ret); /* We failed in argument colleting! */
}
case DEF_NOARGS: /* No parameters just stuffs */
ret=fpp_expstuff(global, tokenp->name, tokenp->repl); /* expand macro */
} /* nargs switch */
return(ret);
}
INLINE FILE_LOCAL
ReturnCode fpp_expcollect(struct Global *global)
{
/*
* Collect the actual parameters for this macro.
*/
int c;
int paren; /* For embedded ()'s */
ReturnCode ret;
for (;;) {
paren = 0; /* Collect next arg. */
while ((c = fpp_skipws(global)) == '\n')/* Skip over whitespace */
global->wrongline = FPP_TRUE; /* and newlines. */
if (c == ')') { /* At end of all args? */
/*
* Note that there is a guard byte in parm[]
* so we don't have to check for overflow here.
*/
*global->parmp = EOS; /* Make sure terminated */
break; /* Exit collection loop */
}
else if (global->nargs >= LASTPARM) {
fpp_cfatal(global, FATAL_TOO_MANY_ARGUMENTS_EXPANSION);
return(FPP_TOO_MANY_ARGUMENTS);
}
global->parlist[global->nargs++] = global->parmp; /* At start of new arg */
for (;; c = fpp_cget(global)) { /* Collect arg's bytes */
if (c == EOF_CHAR) {
fpp_cerror(global, ERROR_EOF_IN_ARGUMENT);
return(FPP_EOF_IN_MACRO); /* Sorry. */
}
else if (c == '\\') { /* Quote next character */
fpp_charput(global, c); /* Save the \ for later */
fpp_charput(global, fpp_cget(global)); /* Save the next char. */
continue; /* And go get another */
}
else if (type[c] == QUO) { /* Start of string? */
ret=fpp_scanstring(global, c, (ReturnCode (*)(struct Global *, int))fpp_charput); /* Scan it off */
if(ret)
return(ret);
continue; /* Go get next char */
}
else if (c == '(') /* Worry about balance */
paren++; /* To know about commas */
else if (c == ')') { /* Other side too */
if (paren == 0) { /* At the end? */
fpp_unget(global); /* Look at it later */
break; /* Exit arg getter. */
}
paren--; /* More to come. */
}
else if (c == ',' && paren == 0) /* Comma delimits args */
break;
else if (c == '\n') /* Newline inside arg? */
global->wrongline = FPP_TRUE; /* We'll need a #line */
fpp_charput(global, c); /* Store this one */
} /* Collect an argument */
fpp_charput(global, EOS); /* Terminate argument */
} /* Collect all args. */
return(FPP_OK); /* Normal return */
}
#if OK_CONCAT
INLINE FILE_LOCAL
char *fpp_doquoting(char *to, char *from)
{
*to++ = '"';
while (*from) {
if (*from == '\\' || *from == '"')
*to++ = '\\';
*to++ = *from++;
}
*to++ = '"';
return to;
}
#endif
ReturnCode fpp_expstuff(struct Global *global,
char *MacroName,
char *MacroReplace)
{
/*
* Stuff the macro body, replacing formal parameters by actual parameters.
*/
int c; /* Current character */
char *inp; /* -> repl string */
char *defp; /* -> macro output buff */
size_t size; /* Actual parm. size */
char *defend; /* -> output buff end */
int string_magic; /* String formal hack */
FILEINFO *file; /* Funny #include */
ReturnCode ret;
#if OK_CONCAT
char quoting; /* Quote macro argument */
#endif
ret = fpp_getfile(global, NBUFF, MacroName, &file);
if(ret)
return(ret);
inp = MacroReplace; /* -> macro replacement */
defp = file->buffer; /* -> output buffer */
defend = defp + (NBUFF - 1); /* Note its end */
if (inp != NULL) {
quoting = 0;
while ((c = (*inp++ & 0xFF)) != EOS) {
#if OK_CONCAT
if (c == QUOTE_PARM) { /* Special token for # */
quoting = 1; /* set flag, for later */
continue; /* Get next character */
}
#endif
if (c >= MAC_PARM && c <= (MAC_PARM + PAR_MAC)) {
string_magic = (c == (MAC_PARM + PAR_MAC));
if (string_magic)
c = (*inp++ & 0xFF);
/*
* Replace formal parameter by actual parameter string.
*/
if ((c -= MAC_PARM) < global->nargs) {
size = strlen(global->parlist[c]);
#if OK_CONCAT
if (quoting) {
size++;
size *= 2; /* worst case condition */
}
#endif
if ((defp + size) >= defend) {
fpp_cfatal(global, FATAL_OUT_OF_SPACE_IN_ARGUMENT, MacroName);
return(FPP_OUT_OF_SPACE_IN_MACRO_EXPANSION);
}
/*
* Erase the extra set of quotes.
*/
if (string_magic && defp[-1] == global->parlist[c][0]) {
strcpy(defp-1, global->parlist[c]);
defp += (size - 2);
}
#if OK_CONCAT
else if (quoting)
defp = fpp_doquoting(defp, global->parlist[c]);
#endif
else {
strcpy(defp, global->parlist[c]);
defp += size;
}
}
}
else if (defp >= defend) {
fpp_cfatal(global, FATAL_OUT_OF_SPACE_IN_ARGUMENT, MacroName);
return(FPP_OUT_OF_SPACE_IN_MACRO_EXPANSION);
} else
*defp++ = c;
quoting = 0;
}
}
*defp = EOS;
return(FPP_OK);
}

View file

@ -0,0 +1,904 @@
/******************************************************************************
Copyright (c) 1999 Daniel Stenberg
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.
******************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include "cppdef.h"
#include "cpp.h"
INLINE FILE_LOCAL ReturnCode fpp_evallex(struct Global *, int, int *);
INLINE FILE_LOCAL ReturnCode fpp_dosizeof(struct Global *, int *);
INLINE FILE_LOCAL int fpp_bittest(int);
INLINE FILE_LOCAL int fpp_evalnum(struct Global *, int);
INLINE FILE_LOCAL int fpp_evalchar(struct Global *, int);
INLINE FILE_LOCAL int *fpp_evaleval(struct Global *, int *, int, int);
/*
* Evaluate an #if expression.
*/
static char *opname[] = { /* For debug and error messages */
"end of expression", "val", "id",
"+", "-", "*", "/", "%",
"<<", ">>", "&", "|", "^",
"==", "!=", "<", "<=", ">=", ">",
"&&", "||", "?", ":", ",",
"unary +", "unary -", "~", "!", "(", ")", "(none)",
};
/*
* opdope[] has the operator precedence:
* Bits
* 7 Unused (so the value is always positive)
* 6-2 Precedence (000x .. 017x)
* 1-0 Binary op. flags:
* 01 The binop flag should be set/cleared when this op is seen.
* 10 The new value of the binop flag.
* Note: Expected, New binop
* constant 0 1 Binop, end, or ) should follow constants
* End of line 1 0 End may not be preceeded by an operator
* binary 1 0 Binary op follows a value, value follows.
* unary 0 0 Unary op doesn't follow a value, value follows
* ( 0 0 Doesn't follow value, value or unop follows
* ) 1 1 Follows value. Op follows.
*/
static char opdope[OP_MAX] = {
0001, /* End of expression */
0002, /* Digit */
0000, /* Letter (identifier) */
0141, 0141, 0151, 0151, 0151, /* ADD, SUB, MUL, DIV, MOD */
0131, 0131, 0101, 0071, 0071, /* ASL, ASR, AND, OR, XOR */
0111, 0111, 0121, 0121, 0121, 0121, /* EQ, NE, LT, LE, GE, GT */
0061, 0051, 0041, 0041, 0031, /* ANA, ORO, QUE, COL, CMA */
/*
* Unary op's follow
*/
0160, 0160, 0160, 0160, /* NEG, PLU, COM, NOT */
0170, 0013, 0023, /* LPA, RPA, END */
};
/*
* OP_QUE and OP_RPA have alternate precedences:
*/
#define OP_RPA_PREC 0013
#define OP_QUE_PREC 0034
/*
* S_ANDOR and S_QUEST signal "short-circuit" boolean evaluation, so that
* #if FOO != 0 && 10 / FOO ...
* doesn't generate an error message. They are stored in optab.skip.
*/
#define S_ANDOR 2
#define S_QUEST 1
typedef struct optab {
char op; /* Operator */
char prec; /* Its precedence */
char skip; /* Short-circuit: FPP_TRUE to skip */
} OPTAB;
#ifdef nomacargs
FILE_LOCAL int
isbinary(op)
int op;
{
return (op >= FIRST_BINOP && op <= LAST_BINOP);
}
FILE_LOCAL int
isunary(op)
int op;
{
return (op >= FIRST_UNOP && op <= LAST_UNOP);
}
#else
#define isbinary(op) (op >= FIRST_BINOP && op <= LAST_BINOP)
#define isunary(op) (op >= FIRST_UNOP && op <= LAST_UNOP)
#endif
/*
* The following definitions are used to specify basic variable sizes.
*/
#if OK_SIZEOF
#ifndef S_CHAR
#define S_CHAR (sizeof (char))
#endif
#ifndef S_SINT
#ifdef manx /* Aztec/Manx C does not like "short int" */
#define S_SINT (sizeof (short))
#else
#define S_SINT (sizeof (short int))
#endif
#endif
#ifndef S_INT
#define S_INT (sizeof (int))
#endif
#ifndef S_LINT
#define S_LINT (sizeof (long int))
#endif
#ifndef S_FLOAT
#define S_FLOAT (sizeof (float))
#endif
#ifndef S_DOUBLE
#define S_DOUBLE (sizeof (double))
#endif
#ifndef S_PCHAR
#define S_PCHAR (sizeof (char *))
#endif
#ifndef S_PSINT
#ifdef manx /* Aztec/Manx C does not like "short int" */
#define S_PSINT (sizeof (short *))
#else
#define S_PSINT (sizeof (short int *))
#endif
#endif
#ifndef S_PINT
#define S_PINT (sizeof (int *))
#endif
#ifndef S_PLINT
#define S_PLINT (sizeof (long int *))
#endif
#ifndef S_PFLOAT
#define S_PFLOAT (sizeof (float *))
#endif
#ifndef S_PDOUBLE
#define S_PDOUBLE (sizeof (double *))
#endif
#ifndef S_PFPTR
#define S_PFPTR (sizeof (int (*)()))
#endif
typedef struct types {
short type; /* This is the bit if */
char *name; /* this is the token word */
} TYPES;
static TYPES basic_types[] = {
{ T_CHAR, "char", },
{ T_INT, "int", },
{ T_FLOAT, "float", },
{ T_DOUBLE, "double", },
{ T_SHORT, "short", },
{ T_LONG, "long", },
{ T_SIGNED, "signed", },
{ T_UNSIGNED, "unsigned", },
{ 0, NULL, }, /* Signal end */
};
/*
* Test_table[] is used to test for illegal combinations.
*/
static short test_table[] = {
T_FLOAT | T_DOUBLE | T_LONG | T_SHORT,
T_FLOAT | T_DOUBLE | T_CHAR | T_INT,
T_FLOAT | T_DOUBLE | T_SIGNED | T_UNSIGNED,
T_LONG | T_SHORT | T_CHAR,
0 /* end marker */
};
/*
* The order of this table is important -- it is also referenced by
* the command line processor to allow run-time overriding of the
* built-in size values. The order must not be changed:
* char, short, int, long, float, double (func pointer)
*/
SIZES size_table[] = {
{ T_CHAR, S_CHAR, S_PCHAR }, /* char */
{ T_SHORT, S_SINT, S_PSINT }, /* short int */
{ T_INT, S_INT, S_PINT }, /* int */
{ T_LONG, S_LINT, S_PLINT }, /* long */
{ T_FLOAT, S_FLOAT, S_PFLOAT }, /* float */
{ T_DOUBLE, S_DOUBLE, S_PDOUBLE }, /* double */
{ T_FPTR, 0, S_PFPTR }, /* int (*()) */
{ 0, 0, 0 }, /* End of table */
};
#endif /* OK_SIZEOF */
ReturnCode fpp_eval(struct Global *global, int *eval)
{
/*
* Evaluate an expression. Straight-forward operator precedence.
* This is called from fpp_control() on encountering an #if statement.
* It calls the following routines:
* fpp_evallex Lexical analyser -- returns the type and value of
* the next input token.
* fpp_evaleval Evaluate the current operator, given the values on
* the value stack. Returns a pointer to the (new)
* value stack.
* For compatiblity with older cpp's, this return returns 1 (FPP_TRUE)
* if a syntax error is detected.
*/
int op; /* Current operator */
int *valp; /* -> value vector */
OPTAB *opp; /* Operator stack */
int prec; /* Op precedence */
int binop; /* Set if binary op. needed */
int op1; /* Operand from stack */
int skip; /* For short-circuit testing */
int value[NEXP]; /* Value stack */
OPTAB opstack[NEXP]; /* Operand stack */
ReturnCode ret;
char again=FPP_TRUE;
valp = value;
opp = opstack;
opp->op = OP_END; /* Mark bottom of stack */
opp->prec = opdope[OP_END]; /* And its precedence */
opp->skip = 0; /* Not skipping now */
binop = 0;
while(again) {
ret=fpp_evallex(global, opp->skip, &op);
if(ret)
return(ret);
if (op == OP_SUB && binop == 0)
op = OP_NEG; /* Unary minus */
else if (op == OP_ADD && binop == 0)
op = OP_PLU; /* Unary plus */
else if (op == OP_FAIL) {
*eval=1; /* Error in evallex */
return(FPP_OK);
}
if (op == DIG) { /* Value? */
if (binop != 0) {
fpp_cerror(global, ERROR_MISPLACED_CONSTANT);
*eval=1;
return(FPP_OK);
} else if (valp >= &value[NEXP-1]) {
fpp_cerror(global, ERROR_IF_OVERFLOW);
*eval=1;
return(FPP_OK);
} else {
*valp++ = global->evalue;
binop = 1;
}
again=FPP_TRUE;
continue;
} else if (op > OP_END) {
fpp_cerror(global, ERROR_ILLEGAL_IF_LINE);
*eval=1;
return(FPP_OK);
}
prec = opdope[op];
if (binop != (prec & 1)) {
fpp_cerror(global, ERROR_OPERATOR, opname[op]);
*eval=1;
return(FPP_OK);
}
binop = (prec & 2) >> 1;
do {
if (prec > opp->prec) {
if (op == OP_LPA)
prec = OP_RPA_PREC;
else if (op == OP_QUE)
prec = OP_QUE_PREC;
op1 = opp->skip; /* Save skip for test */
/*
* Push operator onto op. stack.
*/
opp++;
if (opp >= &opstack[NEXP]) {
fpp_cerror(global, ERROR_EXPR_OVERFLOW, opname[op]);
*eval=1;
return(FPP_OK);
}
opp->op = op;
opp->prec = prec;
skip = (valp[-1] != 0); /* Short-circuit tester */
/*
* Do the short-circuit stuff here. Short-circuiting
* stops automagically when operators are evaluated.
*/
if ((op == OP_ANA && !skip)
|| (op == OP_ORO && skip))
opp->skip = S_ANDOR; /* And/or skip starts */
else if (op == OP_QUE) /* Start of ?: operator */
opp->skip = (op1 & S_ANDOR) | ((!skip) ? S_QUEST : 0);
else if (op == OP_COL) { /* : inverts S_QUEST */
opp->skip = (op1 & S_ANDOR)
| (((op1 & S_QUEST) != 0) ? 0 : S_QUEST);
}
else { /* Other ops leave */
opp->skip = op1; /* skipping unchanged. */
}
again=FPP_TRUE;
continue;
}
/*
* Pop operator from op. stack and evaluate it.
* End of stack and '(' are specials.
*/
skip = opp->skip; /* Remember skip value */
switch ((op1 = opp->op)) { /* Look at stacked op */
case OP_END: /* Stack end marker */
if (op == OP_EOE) {
*eval=valp[-1]; /* Finished ok. */
return(FPP_OK);
}
/* Read another op. */
again=FPP_TRUE;
continue;
case OP_LPA: /* ( on stack */
if (op != OP_RPA) { /* Matches ) on input */
fpp_cerror(global, ERROR_UNBALANCED_PARENS, opname[op]);
*eval=1;
return(FPP_OK);
}
opp--; /* Unstack it */
/* -- Fall through */
case OP_QUE:
/* Evaluate true expr. */
again=FPP_TRUE;
continue;
case OP_COL: /* : on stack. */
opp--; /* Unstack : */
if (opp->op != OP_QUE) { /* Matches ? on stack? */
fpp_cerror(global, ERROR_MISPLACED, opname[(unsigned)opp->op]);
*eval=1;
return(FPP_OK);
}
/*
* Evaluate op1.
*/
default: /* Others: */
opp--; /* Unstack the operator */
valp = fpp_evaleval(global, valp, op1, skip);
again=FPP_FALSE;
} /* op1 switch end */
} while (!again); /* Stack unwind loop */
}
return(FPP_OK);
}
INLINE FILE_LOCAL
ReturnCode fpp_evallex(struct Global *global,
int skip, /* FPP_TRUE if short-circuit evaluation */
int *op)
{
/*
* Set *op to next fpp_eval operator or value. Called from fpp_eval(). It
* calls a special-purpose routines for 'char' strings and
* numeric values:
* fpp_evalchar called to evaluate 'x'
* fpp_evalnum called to evaluate numbers.
*/
int c, c1, t;
ReturnCode ret;
char loop;
do { /* while(loop); */
/* again: */
loop=FPP_FALSE;
do { /* Collect the token */
c = fpp_skipws(global);
if((ret=fpp_macroid(global, &c)))
return(ret);
if (c == EOF_CHAR || c == '\n') {
fpp_unget(global);
*op=OP_EOE; /* End of expression */
return(FPP_OK);
}
} while ((t = type[c]) == LET && fpp_catenate(global, 0, &ret) && !ret);
if(ret)
/* If the loop was broken because of a fatal error! */
return(ret);
if (t == INV) { /* Total nonsense */
if (!skip) {
if (isascii(c) && isprint(c))
fpp_cerror(global, ERROR_ILLEGAL_CHARACTER, c);
else
fpp_cerror(global, ERROR_ILLEGAL_CHARACTER2, c);
}
return(FPP_ILLEGAL_CHARACTER);
} else if (t == QUO) { /* ' or " */
if (c == '\'') { /* Character constant */
global->evalue = fpp_evalchar(global, skip); /* Somewhat messy */
*op=DIG; /* Return a value */
return(FPP_OK);
}
fpp_cerror(global, ERROR_STRING_IN_IF);
return(FPP_CANT_USE_STRING_IN_IF);
} else if (t == LET) { /* ID must be a macro */
if (streq(global->tokenbuf, "defined")) { /* Or defined name */
c1 = c = fpp_skipws(global);
if (c == '(') /* Allow defined(name) */
c = fpp_skipws(global);
if (type[c] == LET) {
global->evalue = (fpp_lookid(global, c) != NULL);
if (c1 != '(' /* Need to balance */
|| fpp_skipws(global) == ')') { /* Did we balance? */
*op=DIG;
return(FPP_OK); /* Parsed ok */
}
}
fpp_cerror(global, ERROR_DEFINED_SYNTAX);
return(FPP_BAD_IF_DEFINED_SYNTAX);
}
#if OK_SIZEOF
else if (streq(global->tokenbuf, "sizeof")) { /* New sizeof hackery */
ret=fpp_dosizeof(global, op); /* Gets own routine */
return(ret);
}
#endif
global->evalue = 0;
*op=DIG;
return(FPP_OK);
}
else if (t == DIG) { /* Numbers are harder */
global->evalue = fpp_evalnum(global, c);
}
else if (strchr("!=<>&|\\", c) != NULL) {
/*
* Process a possible multi-byte lexeme.
*/
c1 = fpp_cget(global); /* Peek at next char */
switch (c) {
case '!':
if (c1 == '=') {
*op=OP_NE;
return(FPP_OK);
}
break;
case '=':
if (c1 != '=') { /* Can't say a=b in #if */
fpp_unget(global);
fpp_cerror(global, ERROR_ILLEGAL_ASSIGN);
return (FPP_IF_ERROR);
}
*op=OP_EQ;
return(FPP_OK);
case '>':
case '<':
if (c1 == c) {
*op= ((c == '<') ? OP_ASL : OP_ASR);
return(FPP_OK);
} else if (c1 == '=') {
*op= ((c == '<') ? OP_LE : OP_GE);
return(FPP_OK);
}
break;
case '|':
case '&':
if (c1 == c) {
*op= ((c == '|') ? OP_ORO : OP_ANA);
return(FPP_OK);
}
break;
case '\\':
if (c1 == '\n') { /* Multi-line if */
loop=FPP_TRUE;
break;
}
fpp_cerror(global, ERROR_ILLEGAL_BACKSLASH);
return(FPP_IF_ERROR);
}
if(!loop)
fpp_unget(global);
}
} while(loop);
*op=t;
return(FPP_OK);
}
#if OK_SIZEOF
INLINE FILE_LOCAL
ReturnCode fpp_dosizeof(struct Global *global, int *result)
{
/*
* Process the sizeof (basic type) operation in an #if string.
* Sets evalue to the size and returns
* DIG success
* OP_FAIL bad parse or something.
*/
int c;
TYPES *tp;
SIZES *sizp;
short *testp;
short typecode;
ReturnCode ret;
if ((c = fpp_skipws(global)) != '(') {
fpp_unget(global);
fpp_cerror(global, ERROR_SIZEOF_SYNTAX);
return(FPP_SIZEOF_ERROR);
}
/*
* Scan off the tokens.
*/
typecode = 0;
while ((c = fpp_skipws(global))) {
if((ret=fpp_macroid(global, &c)))
return(ret);
/* (I) return on fail! */
if (c == EOF_CHAR || c == '\n') {
/* End of line is a bug */
fpp_unget(global);
fpp_cerror(global, ERROR_SIZEOF_SYNTAX);
return(FPP_SIZEOF_ERROR);
} else if (c == '(') { /* thing (*)() func ptr */
if (fpp_skipws(global) == '*'
&& fpp_skipws(global) == ')') { /* We found (*) */
if (fpp_skipws(global) != '(') /* Let () be optional */
fpp_unget(global);
else if (fpp_skipws(global) != ')') {
fpp_unget(global);
fpp_cerror(global, ERROR_SIZEOF_SYNTAX);
return(FPP_SIZEOF_ERROR);
}
typecode |= T_FPTR; /* Function pointer */
} else { /* Junk is a bug */
fpp_unget(global);
fpp_cerror(global, ERROR_SIZEOF_SYNTAX);
return(FPP_SIZEOF_ERROR);
}
}
else if (type[c] != LET) /* Exit if not a type */
break;
else if (!fpp_catenate(global, 0, &ret) && !ret) { /* Maybe combine tokens */
/*
* Look for this unexpandable token in basic_types.
* The code accepts "int long" as well as "long int"
* which is a minor bug as bugs go (and one shared with
* a lot of C compilers).
*/
for (tp = basic_types; tp->name != NULLST; tp++) {
if (streq(global->tokenbuf, tp->name))
break;
}
if (tp->name == NULLST) {
fpp_cerror(global, ERROR_SIZEOF_UNKNOWN, global->tokenbuf);
return(FPP_SIZEOF_ERROR);
}
typecode |= tp->type; /* Or in the type bit */
} else if(ret)
return(ret);
}
/*
* We are at the end of the type scan. Chew off '*' if necessary.
*/
if (c == '*') {
typecode |= T_PTR;
c = fpp_skipws(global);
}
if (c == ')') { /* Last syntax check */
for (testp = test_table; *testp != 0; testp++) {
if (!fpp_bittest(typecode & *testp)) {
fpp_cerror(global, ERROR_SIZEOF_ILLEGAL_TYPE);
return(FPP_SIZEOF_ERROR);
}
}
/*
* We assume that all function pointers are the same size:
* sizeof (int (*)()) == sizeof (float (*)())
* We assume that signed and unsigned don't change the size:
* sizeof (signed int) == (sizeof unsigned int)
*/
if ((typecode & T_FPTR) != 0) /* Function pointer */
typecode = T_FPTR | T_PTR;
else { /* Var or var * datum */
typecode &= ~(T_SIGNED | T_UNSIGNED);
if ((typecode & (T_SHORT | T_LONG)) != 0)
typecode &= ~T_INT;
}
if ((typecode & ~T_PTR) == 0) {
fpp_cerror(global, ERROR_SIZEOF_NO_TYPE);
return(FPP_SIZEOF_ERROR);
}
/*
* Exactly one bit (and possibly T_PTR) may be set.
*/
for (sizp = size_table; sizp->bits != 0; sizp++) {
if ((typecode & ~T_PTR) == sizp->bits) {
global->evalue = ((typecode & T_PTR) != 0)
? sizp->psize : sizp->size;
*result=DIG;
return(FPP_OK);
}
} /* We shouldn't fail */
fpp_cerror(global, ERROR_SIZEOF_BUG, typecode);
return(FPP_SIZEOF_ERROR);
}
fpp_unget(global);
fpp_cerror(global, ERROR_SIZEOF_SYNTAX);
return(FPP_SIZEOF_ERROR);
}
INLINE FILE_LOCAL
int fpp_bittest(int value)
{
/*
* FPP_TRUE if value is zero or exactly one bit is set in value.
*/
#if (4096 & ~(-4096)) == 0
return ((value & ~(-value)) == 0);
#else
/*
* Do it the hard way (for non 2's complement machines)
*/
return (value == 0 || value ^ (value - 1) == (value * 2 - 1));
#endif
}
#endif /* OK_SIZEOF */
INLINE FILE_LOCAL
int fpp_evalnum(struct Global *global, int c)
{
/*
* Expand number for #if lexical analysis. Note: fpp_evalnum recognizes
* the unsigned suffix, but only returns a signed int value.
*/
int value;
int base;
int c1;
if (c != '0')
base = 10;
else if ((c = fpp_cget(global)) == 'x' || c == 'X') {
base = 16;
c = fpp_cget(global);
}
else base = 8;
value = 0;
for (;;) {
c1 = c;
if (isascii(c) && isupper(c1))
c1 = fpp_tolower(c1);
if (c1 >= 'a')
c1 -= ('a' - 10);
else c1 -= '0';
if (c1 < 0 || c1 >= base)
break;
value *= base;
value += c1;
c = fpp_cget(global);
}
if (c == 'u' || c == 'U') /* Unsigned nonsense */
c = fpp_cget(global);
fpp_unget(global);
return (value);
}
INLINE FILE_LOCAL
int fpp_evalchar(struct Global *global,
int skip) /* FPP_TRUE if short-circuit evaluation */
/*
* Get a character constant
*/
{
int c;
int value;
int count;
global->instring = FPP_TRUE;
if ((c = fpp_cget(global)) == '\\') {
switch ((c = fpp_cget(global))) {
case 'a': /* New in Standard */
#if ('a' == '\a' || '\a' == ALERT)
value = ALERT; /* Use predefined value */
#else
value = '\a'; /* Use compiler's value */
#endif
break;
case 'b':
value = '\b';
break;
case 'f':
value = '\f';
break;
case 'n':
value = '\n';
break;
case 'r':
value = '\r';
break;
case 't':
value = '\t';
break;
case 'v': /* New in Standard */
#if ('v' == '\v' || '\v' == VT)
value = VT; /* Use predefined value */
#else
value = '\v'; /* Use compiler's value */
#endif
break;
case 'x': /* '\xFF' */
count = 3;
value = 0;
while ((((c = fpp_get(global)) >= '0' && c <= '9')
|| (c >= 'a' && c <= 'f')
|| (c >= 'A' && c <= 'F'))
&& (--count >= 0)) {
value *= 16;
value += (c <= '9') ? (c - '0') : ((c & 0xF) + 9);
}
fpp_unget(global);
break;
default:
if (c >= '0' && c <= '7') {
count = 3;
value = 0;
while (c >= '0' && c <= '7' && --count >= 0) {
value *= 8;
value += (c - '0');
c = fpp_get(global);
}
fpp_unget(global);
} else
value = c;
break;
}
} else if (c == '\'')
value = 0;
else value = c;
/*
* We warn on multi-byte constants and try to hack
* (big|little)endian machines.
*/
#if BIG_ENDIAN
count = 0;
#endif
while ((c = fpp_get(global)) != '\'' && c != EOF_CHAR && c != '\n') {
if (!skip)
fpp_cwarn(global, WARN_MULTIBYTE_NOT_PORTABLE, c);
#if BIG_ENDIAN
count += BITS_CHAR;
value += (c << count);
#else
value <<= BITS_CHAR;
value += c;
#endif
}
global->instring = FPP_FALSE;
return (value);
}
INLINE FILE_LOCAL
int *fpp_evaleval(struct Global *global,
int *valp,
int op,
int skip) /* FPP_TRUE if short-circuit evaluation */
{
/*
* Apply the argument operator to the data on the value stack.
* One or two values are popped from the value stack and the result
* is pushed onto the value stack.
*
* OP_COL is a special case.
*
* fpp_evaleval() returns the new pointer to the top of the value stack.
*/
int v1, v2 = 0;
if (isbinary(op))
v2 = *--valp;
v1 = *--valp;
switch (op) {
case OP_EOE:
break;
case OP_ADD:
v1 += v2;
break;
case OP_SUB:
v1 -= v2;
break;
case OP_MUL:
v1 *= v2;
break;
case OP_DIV:
case OP_MOD:
if (v2 == 0) {
if (!skip) {
fpp_cwarn(global, WARN_DIVISION_BY_ZERO,
(op == OP_DIV) ? "divide" : "mod");
}
v1 = 0;
}
else if (op == OP_DIV)
v1 /= v2;
else
v1 %= v2;
break;
case OP_ASL:
v1 <<= v2;
break;
case OP_ASR:
v1 >>= v2;
break;
case OP_AND:
v1 &= v2;
break;
case OP_OR:
v1 |= v2;
break;
case OP_XOR:
v1 ^= v2;
break;
case OP_EQ:
v1 = (v1 == v2);
break;
case OP_NE:
v1 = (v1 != v2);
break;
case OP_LT:
v1 = (v1 < v2);
break;
case OP_LE:
v1 = (v1 <= v2);
break;
case OP_GE:
v1 = (v1 >= v2);
break;
case OP_GT:
v1 = (v1 > v2);
break;
case OP_ANA:
v1 = (v1 && v2);
break;
case OP_ORO:
v1 = (v1 || v2);
break;
case OP_COL:
/*
* v1 has the "true" value, v2 the "false" value.
* The top of the value stack has the test.
*/
v1 = (*--valp) ? v1 : v2;
break;
case OP_NEG:
v1 = (-v1);
break;
case OP_PLU:
break;
case OP_COM:
v1 = ~v1;
break;
case OP_NOT:
v1 = !v1;
break;
default:
fpp_cerror(global, ERROR_IF_OPERAND, op);
v1 = 0;
}
*valp++ = v1;
return (valp);
}

1168
ADVect/ext/bgfx/bgfx/3rdparty/fcpp/cpp6.c vendored Normal file

File diff suppressed because it is too large Load diff

Some files were not shown because too many files have changed in this diff Show more