3rdparty: Updated bgfx, bimg, and bx to latest upstream. [Ryan Holtz]

This commit is contained in:
mooglyguy 2018-12-05 19:45:08 +01:00
parent 9a81ec7eaf
commit 0bd02131b6
2524 changed files with 609200 additions and 98094 deletions

View File

@ -5,7 +5,6 @@ os:
environment:
matrix:
- TOOLSET: vs2015
- TOOLSET: vs2017
configuration:

View File

@ -11,8 +11,8 @@ addons:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.8
- g++-4.8
- gcc-5
- g++-5
- clang
before_script:
@ -20,7 +20,7 @@ before_script:
- git clone --depth 1 https://github.com/bkaradzic/bimg ../bimg
script:
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then make build CXX="g++-4.8" CC="gcc-4.8"; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then make build CXX="g++-5" CC="gcc-5"; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then make build; fi
branches:
@ -30,4 +30,4 @@ branches:
notifications:
email: false
osx_image: xcode7.3
osx_image: xcode9.3

View File

@ -16,11 +16,11 @@ indent_size = 4
indent_style = tab
indent_size = 4
[ocornut-imgui/*]
[dear-imgui/*]
indent_style = space
indent_size = 4
[ocornut-imgui/*.inl]
[dear-imgui/*.inl]
indent_style = space
indent_size = 4

View File

@ -6,6 +6,8 @@
#pragma once
//#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS
//---- 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
@ -13,7 +15,7 @@
//---- Define assertion handler. Defaults to calling assert().
#include <assert.h>
#define IM_ASSERT(_EXPR, ...) assert(_EXPR)
#define IM_ASSERT(_EXPR) assert(_EXPR)
//---- Define attributes of all API symbols declarations, e.g. for DLL under Windows.
//#define IMGUI_API __declspec( dllexport )

File diff suppressed because it is too large Load Diff

2051
3rdparty/bgfx/3rdparty/dear-imgui/imgui.h vendored Normal file

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 @@
#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

@ -12,7 +12,7 @@ namespace ImGui
// Setup
ImVec2 picker_pos = ImGui::GetCursorScreenPos();
ImVec2 sv_picker_size = ImVec2(256.0f, 256.0f); // Saturation/Value picking box
float bars_width = ImGui::GetWindowFontSize() + style.FramePadding.y*2.0f; // Width of Hue/Alpha picking bars (using Framepadding.y to match the ColorButton sides)
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;

View File

@ -512,8 +512,6 @@ namespace ImGui
Begin("##Overlay",
NULL,
ImVec2(0, 0),
0.f,
ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings |
ImGuiWindowFlags_AlwaysAutoResize);
@ -968,8 +966,6 @@ namespace ImGui
SetNextWindowSize(dock.size);
bool ret = Begin(label,
opened,
dock.size,
-1.0f,
ImGuiWindowFlags_NoCollapse | extra_flags);
m_end_action = EndAction_End;
dock.pos = GetWindowPos();

View File

@ -1,5 +1,5 @@
// https://github.com/CedricGuillemet/ImGuizmo
// v 1.04 WIP
// v 1.61 WIP
//
// The MIT License(MIT)
//
@ -105,18 +105,21 @@ void EditTransform(const Camera& camera, matrix_t& matrix)
namespace ImGuizmo
{
// call inside your own window and before Manipulate() in order to draw gizmo to that window.
IMGUI_API void SetDrawlist();
// call BeginFrame right after ImGui_XXXX_NewFrame();
void BeginFrame();
IMGUI_API void BeginFrame();
// return true if mouse cursor is over any gizmo control (axis, plan or screen component)
bool IsOver();
IMGUI_API bool IsOver();
// return true if mouse IsOver or if the gizmo is in moving state
bool IsUsing();
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
void Enable(bool enable);
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
@ -130,13 +133,16 @@ namespace ImGuizmo
// ImGuizmo::RecomposeMatrixFromComponents(matrixTranslation, matrixRotation, matrixScale, gizmoMatrix.m16);
//
// These functions have some numerical stability issues for now. Use with caution.
void DecomposeMatrixToComponents(const float *matrix, float *translation, float *rotation, float *scale);
void RecomposeMatrixFromComponents(const float *translation, const float *rotation, const float *scale, float *matrix);
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);
void SetRect(float x, float y, float width, float height);
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
void DrawCube(const float *view, const float *projection, float *matrix);
IMGUI_API void DrawCube(const float *view, const float *projection, const float *matrix);
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.
@ -147,6 +153,7 @@ namespace ImGuizmo
TRANSLATE,
ROTATE,
SCALE,
BOUNDS,
};
enum MODE
@ -155,5 +162,5 @@ namespace ImGuizmo
WORLD
};
void Manipulate(const float *view, const float *projection, OPERATION operation, MODE mode, float *matrix, float *deltaMatrix = 0, float *snap = 0, float *localBounds = NULL, float *boundsSnap = NULL);
IMGUI_API void Manipulate(const float *view, const float *projection, OPERATION operation, MODE mode, float *matrix, float *deltaMatrix = 0, float *snap = 0, float *localBounds = NULL, float *boundsSnap = NULL);
};

View File

@ -16,7 +16,7 @@ namespace ImGui
unsigned char* mem_data = (unsigned char*)mem_data_void;
BeginChild("##scrolling", ImVec2(0, -GetItemsLineHeightWithSpacing()));
BeginChild("##scrolling", ImVec2(0, -GetFrameHeight()));
if (ImGui::BeginPopupContextWindow() )
{
@ -89,7 +89,7 @@ namespace ImGui
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(ImGuiTextEditCallbackData* data)
static int Callback(ImGuiInputTextCallbackData* data)
{
int* p_cursor_pos = (int*)data->UserData;
if (!data->HasSelection())
@ -202,7 +202,7 @@ namespace ImGui
Separator();
AlignFirstTextHeightToWidgets();
AlignTextToFramePadding();
PushItemWidth(50);
PushAllowKeyboardFocus(false);
int rows_backup = Rows;

View File

@ -4,6 +4,10 @@
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)
{
@ -83,8 +87,11 @@ bool RangeSliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v1, float* v
new_value = ImLerp(v_min, v_max, clicked_t);
}
char fmt[64];
snprintf(fmt, 64, "%%.%df", decimal_precision);
// Round past decimal precision
new_value = RoundScalar(new_value, 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))
@ -105,7 +112,7 @@ bool RangeSliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v1, float* v
}
// Calculate slider grab positioning
float grab_t = SliderBehaviorCalcRatioFromValue(*v1, v_min, v_max, power, linear_zero_pos);
float grab_t = SliderCalcRatioFromValueFloat(ImGuiDataType_Float, *v1, v_min, v_max, power, linear_zero_pos);
// Draw
if (!is_horizontal)
@ -119,7 +126,7 @@ bool RangeSliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v1, float* v
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 = SliderBehaviorCalcRatioFromValue(*v2, v_min, v_max, power, linear_zero_pos);
grab_t = SliderCalcRatioFromValueFloat(ImGuiDataType_Float, *v2, v_min, v_max, power, linear_zero_pos);
// Draw
if (!is_horizontal)
@ -172,7 +179,7 @@ bool RangeSliderFloat(const char* label, float* v1, float* v2, float v_min, floa
if (!display_format)
display_format = "(%.3f, %.3f)";
int decimal_precision = ParseFormatPrecision(display_format, 3);
int decimal_precision = ImParseFormatPrecision(display_format, 3);
// Tabbing or CTRL-clicking on Slider turns it into an input box
bool start_text_input = false;
@ -188,8 +195,13 @@ bool RangeSliderFloat(const char* label, float* v1, float* v2, float v_min, floa
g.ScalarAsInputTextId = 0;
}
}
if (start_text_input || (g.ActiveId == id && g.ScalarAsInputTextId == id))
return InputScalarAsWidgetReplacement(frame_bb, label, ImGuiDataType_Float, v1, id, decimal_precision);
{
char fmt[64];
snprintf(fmt, 64, "%%.%df", decimal_precision);
return InputScalarAsWidgetReplacement(frame_bb, id, label, ImGuiDataType_Float, v1, fmt);
}
ItemSize(total_bb, style.FramePadding.y);

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

View File

@ -1,305 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// File: D3D10_1Shader.h
// Content: D3D10.1 Shader Types and APIs
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __D3D10_1SHADER_H__
#define __D3D10_1SHADER_H__
#include "d3d10shader.h"
//----------------------------------------------------------------------------
// Shader debugging structures
//----------------------------------------------------------------------------
typedef enum _D3D10_SHADER_DEBUG_REGTYPE
{
D3D10_SHADER_DEBUG_REG_INPUT,
D3D10_SHADER_DEBUG_REG_OUTPUT,
D3D10_SHADER_DEBUG_REG_CBUFFER,
D3D10_SHADER_DEBUG_REG_TBUFFER,
D3D10_SHADER_DEBUG_REG_TEMP,
D3D10_SHADER_DEBUG_REG_TEMPARRAY,
D3D10_SHADER_DEBUG_REG_TEXTURE,
D3D10_SHADER_DEBUG_REG_SAMPLER,
D3D10_SHADER_DEBUG_REG_IMMEDIATECBUFFER,
D3D10_SHADER_DEBUG_REG_LITERAL,
D3D10_SHADER_DEBUG_REG_UNUSED,
D3D11_SHADER_DEBUG_REG_INTERFACE_POINTERS,
D3D11_SHADER_DEBUG_REG_UAV,
D3D10_SHADER_DEBUG_REG_FORCE_DWORD = 0x7fffffff,
} D3D10_SHADER_DEBUG_REGTYPE;
typedef enum _D3D10_SHADER_DEBUG_SCOPETYPE
{
D3D10_SHADER_DEBUG_SCOPE_GLOBAL,
D3D10_SHADER_DEBUG_SCOPE_BLOCK,
D3D10_SHADER_DEBUG_SCOPE_FORLOOP,
D3D10_SHADER_DEBUG_SCOPE_STRUCT,
D3D10_SHADER_DEBUG_SCOPE_FUNC_PARAMS,
D3D10_SHADER_DEBUG_SCOPE_STATEBLOCK,
D3D10_SHADER_DEBUG_SCOPE_NAMESPACE,
D3D10_SHADER_DEBUG_SCOPE_ANNOTATION,
D3D10_SHADER_DEBUG_SCOPE_FORCE_DWORD = 0x7fffffff,
} D3D10_SHADER_DEBUG_SCOPETYPE;
typedef enum _D3D10_SHADER_DEBUG_VARTYPE
{
D3D10_SHADER_DEBUG_VAR_VARIABLE,
D3D10_SHADER_DEBUG_VAR_FUNCTION,
D3D10_SHADER_DEBUG_VAR_FORCE_DWORD = 0x7fffffff,
} D3D10_SHADER_DEBUG_VARTYPE;
/////////////////////////////////////////////////////////////////////
// These are the serialized structures that get written to the file
/////////////////////////////////////////////////////////////////////
typedef struct _D3D10_SHADER_DEBUG_TOKEN_INFO
{
UINT File; // offset into file list
UINT Line; // line #
UINT Column; // column #
UINT TokenLength;
UINT TokenId; // offset to LPCSTR of length TokenLength in string datastore
} D3D10_SHADER_DEBUG_TOKEN_INFO;
// Variable list
typedef struct _D3D10_SHADER_DEBUG_VAR_INFO
{
// Index into token list for declaring identifier
UINT TokenId;
D3D10_SHADER_VARIABLE_TYPE Type;
// register and component for this variable, only valid/necessary for arrays
UINT Register;
UINT Component;
// gives the original variable that declared this variable
UINT ScopeVar;
// this variable's offset in its ScopeVar
UINT ScopeVarOffset;
} D3D10_SHADER_DEBUG_VAR_INFO;
typedef struct _D3D10_SHADER_DEBUG_INPUT_INFO
{
// index into array of variables of variable to initialize
UINT Var;
// input, cbuffer, tbuffer
D3D10_SHADER_DEBUG_REGTYPE InitialRegisterSet;
// set to cbuffer or tbuffer slot, geometry shader input primitive #,
// identifying register for indexable temp, or -1
UINT InitialBank;
// -1 if temp, otherwise gives register in register set
UINT InitialRegister;
// -1 if temp, otherwise gives component
UINT InitialComponent;
// initial value if literal
UINT InitialValue;
} D3D10_SHADER_DEBUG_INPUT_INFO;
typedef struct _D3D10_SHADER_DEBUG_SCOPEVAR_INFO
{
// Index into variable token
UINT TokenId;
D3D10_SHADER_DEBUG_VARTYPE VarType; // variable or function (different namespaces)
D3D10_SHADER_VARIABLE_CLASS Class;
UINT Rows; // number of rows (matrices)
UINT Columns; // number of columns (vectors and matrices)
// In an array of structures, one struct member scope is provided, and
// you'll have to add the array stride times the index to the variable
// index you find, then find that variable in this structure's list of
// variables.
// gives a scope to look up struct members. -1 if not a struct
UINT StructMemberScope;
// number of array indices
UINT uArrayIndices; // a[3][2][1] has 3 indices
// maximum array index for each index
// offset to UINT[uArrayIndices] in UINT datastore
UINT ArrayElements; // a[3][2][1] has {3, 2, 1}
// how many variables each array index moves
// offset to UINT[uArrayIndices] in UINT datastore
UINT ArrayStrides; // a[3][2][1] has {2, 1, 1}
UINT uVariables;
// index of the first variable, later variables are offsets from this one
UINT uFirstVariable;
} D3D10_SHADER_DEBUG_SCOPEVAR_INFO;
// scope data, this maps variable names to debug variables (useful for the watch window)
typedef struct _D3D10_SHADER_DEBUG_SCOPE_INFO
{
D3D10_SHADER_DEBUG_SCOPETYPE ScopeType;
UINT Name; // offset to name of scope in strings list
UINT uNameLen; // length of name string
UINT uVariables;
UINT VariableData; // Offset to UINT[uVariables] indexing the Scope Variable list
} D3D10_SHADER_DEBUG_SCOPE_INFO;
// instruction outputs
typedef struct _D3D10_SHADER_DEBUG_OUTPUTVAR
{
// index variable being written to, if -1 it's not going to a variable
UINT Var;
// range data that the compiler expects to be true
UINT uValueMin, uValueMax;
INT iValueMin, iValueMax;
FLOAT fValueMin, fValueMax;
BOOL bNaNPossible, bInfPossible;
} D3D10_SHADER_DEBUG_OUTPUTVAR;
typedef struct _D3D10_SHADER_DEBUG_OUTPUTREG_INFO
{
// Only temp, indexable temp, and output are valid here
D3D10_SHADER_DEBUG_REGTYPE OutputRegisterSet;
// -1 means no output
UINT OutputReg;
// if a temp array, identifier for which one
UINT TempArrayReg;
// -1 means masked out
UINT OutputComponents[4];
D3D10_SHADER_DEBUG_OUTPUTVAR OutputVars[4];
// when indexing the output, get the value of this register, then add
// that to uOutputReg. If uIndexReg is -1, then there is no index.
// find the variable whose register is the sum (by looking in the ScopeVar)
// and component matches, then set it. This should only happen for indexable
// temps and outputs.
UINT IndexReg;
UINT IndexComp;
} D3D10_SHADER_DEBUG_OUTPUTREG_INFO;
// per instruction data
typedef struct _D3D10_SHADER_DEBUG_INST_INFO
{
UINT Id; // Which instruction this is in the bytecode
UINT Opcode; // instruction type
// 0, 1, or 2
UINT uOutputs;
// up to two outputs per instruction
D3D10_SHADER_DEBUG_OUTPUTREG_INFO pOutputs[2];
// index into the list of tokens for this instruction's token
UINT TokenId;
// how many function calls deep this instruction is
UINT NestingLevel;
// list of scopes from outer-most to inner-most
// Number of scopes
UINT Scopes;
UINT ScopeInfo; // Offset to UINT[uScopes] specifying indices of the ScopeInfo Array
// list of variables accessed by this instruction
// Number of variables
UINT AccessedVars;
UINT AccessedVarsInfo; // Offset to UINT[AccessedVars] specifying indices of the ScopeVariableInfo Array
} D3D10_SHADER_DEBUG_INST_INFO;
typedef struct _D3D10_SHADER_DEBUG_FILE_INFO
{
UINT FileName; // Offset to LPCSTR for file name
UINT FileNameLen; // Length of file name
UINT FileData; // Offset to LPCSTR of length FileLen
UINT FileLen; // Length of file
} D3D10_SHADER_DEBUG_FILE_INFO;
typedef struct _D3D10_SHADER_DEBUG_INFO
{
UINT Size; // sizeof(D3D10_SHADER_DEBUG_INFO)
UINT Creator; // Offset to LPCSTR for compiler version
UINT EntrypointName; // Offset to LPCSTR for Entry point name
UINT ShaderTarget; // Offset to LPCSTR for shader target
UINT CompileFlags; // flags used to compile
UINT Files; // number of included files
UINT FileInfo; // Offset to D3D10_SHADER_DEBUG_FILE_INFO[Files]
UINT Instructions; // number of instructions
UINT InstructionInfo; // Offset to D3D10_SHADER_DEBUG_INST_INFO[Instructions]
UINT Variables; // number of variables
UINT VariableInfo; // Offset to D3D10_SHADER_DEBUG_VAR_INFO[Variables]
UINT InputVariables; // number of variables to initialize before running
UINT InputVariableInfo; // Offset to D3D10_SHADER_DEBUG_INPUT_INFO[InputVariables]
UINT Tokens; // number of tokens to initialize
UINT TokenInfo; // Offset to D3D10_SHADER_DEBUG_TOKEN_INFO[Tokens]
UINT Scopes; // number of scopes
UINT ScopeInfo; // Offset to D3D10_SHADER_DEBUG_SCOPE_INFO[Scopes]
UINT ScopeVariables; // number of variables declared
UINT ScopeVariableInfo; // Offset to D3D10_SHADER_DEBUG_SCOPEVAR_INFO[Scopes]
UINT UintOffset; // Offset to the UINT datastore, all UINT offsets are from this offset
UINT StringOffset; // Offset to the string datastore, all string offsets are from this offset
} D3D10_SHADER_DEBUG_INFO;
//----------------------------------------------------------------------------
// ID3D10ShaderReflection1:
//----------------------------------------------------------------------------
//
// Interface definitions
//
typedef interface ID3D10ShaderReflection1 ID3D10ShaderReflection1;
typedef interface ID3D10ShaderReflection1 *LPD3D10SHADERREFLECTION1;
// {C3457783-A846-47CE-9520-CEA6F66E7447}
DEFINE_GUID(IID_ID3D10ShaderReflection1,
0xc3457783, 0xa846, 0x47ce, 0x95, 0x20, 0xce, 0xa6, 0xf6, 0x6e, 0x74, 0x47);
#undef INTERFACE
#define INTERFACE ID3D10ShaderReflection1
DECLARE_INTERFACE_(ID3D10ShaderReflection1, IUnknown)
{
STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
STDMETHOD(GetDesc)(THIS_ _Out_ D3D10_SHADER_DESC *pDesc) PURE;
STDMETHOD_(ID3D10ShaderReflectionConstantBuffer*, GetConstantBufferByIndex)(THIS_ UINT Index) PURE;
STDMETHOD_(ID3D10ShaderReflectionConstantBuffer*, GetConstantBufferByName)(THIS_ LPCSTR Name) PURE;
STDMETHOD(GetResourceBindingDesc)(THIS_ UINT ResourceIndex, _Out_ D3D10_SHADER_INPUT_BIND_DESC *pDesc) PURE;
STDMETHOD(GetInputParameterDesc)(THIS_ UINT ParameterIndex, _Out_ D3D10_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
STDMETHOD(GetOutputParameterDesc)(THIS_ UINT ParameterIndex, _Out_ D3D10_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
STDMETHOD_(ID3D10ShaderReflectionVariable*, GetVariableByName)(THIS_ LPCSTR Name) PURE;
STDMETHOD(GetResourceBindingDescByName)(THIS_ LPCSTR Name, _Out_ D3D10_SHADER_INPUT_BIND_DESC *pDesc) PURE;
STDMETHOD(GetMovInstructionCount)(THIS_ _Out_ UINT* pCount) PURE;
STDMETHOD(GetMovcInstructionCount)(THIS_ _Out_ UINT* pCount) PURE;
STDMETHOD(GetConversionInstructionCount)(THIS_ _Out_ UINT* pCount) PURE;
STDMETHOD(GetBitwiseInstructionCount)(THIS_ _Out_ UINT* pCount) PURE;
STDMETHOD(GetGSInputPrimitive)(THIS_ _Out_ D3D10_PRIMITIVE* pPrim) PURE;
STDMETHOD(IsLevel9Shader)(THIS_ _Out_ BOOL* pbLevel9Shader) PURE;
STDMETHOD(IsSampleFrequencyShader)(THIS_ _Out_ BOOL* pbSampleFrequency) PURE;
};
//////////////////////////////////////////////////////////////////////////////
// APIs //////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
extern "C" {
#endif //__cplusplus
#ifdef __cplusplus
}
#endif //__cplusplus
#endif //__D3D10_1SHADER_H__

File diff suppressed because it is too large Load Diff

View File

@ -1,146 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// File: D3D10Misc.h
// Content: D3D10 Device Creation APIs
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __D3D10MISC_H__
#define __D3D10MISC_H__
#include "d3d10.h"
// ID3D10Blob has been made version-neutral and moved to d3dcommon.h.
#ifdef __cplusplus
extern "C" {
#endif //__cplusplus
///////////////////////////////////////////////////////////////////////////
// D3D10_DRIVER_TYPE
// ----------------
//
// This identifier is used to determine the implementation of Direct3D10
// to be used.
//
// Pass one of these values to D3D10CreateDevice
//
///////////////////////////////////////////////////////////////////////////
typedef enum D3D10_DRIVER_TYPE
{
D3D10_DRIVER_TYPE_HARDWARE = 0,
D3D10_DRIVER_TYPE_REFERENCE = 1,
D3D10_DRIVER_TYPE_NULL = 2,
D3D10_DRIVER_TYPE_SOFTWARE = 3,
D3D10_DRIVER_TYPE_WARP = 5,
} D3D10_DRIVER_TYPE;
DEFINE_GUID(GUID_DeviceType,
0xd722fb4d, 0x7a68, 0x437a, 0xb2, 0x0c, 0x58, 0x04, 0xee, 0x24, 0x94, 0xa6);
///////////////////////////////////////////////////////////////////////////
// D3D10CreateDevice
// ------------------
//
// pAdapter
// If NULL, D3D10CreateDevice will choose the primary adapter and
// create a new instance from a temporarily created IDXGIFactory.
// If non-NULL, D3D10CreateDevice will register the appropriate
// device, if necessary (via IDXGIAdapter::RegisterDrver), before
// creating the device.
// DriverType
// Specifies the driver type to be created: hardware, reference or
// null.
// Software
// HMODULE of a DLL implementing a software rasterizer. Must be NULL for
// non-Software driver types.
// Flags
// Any of those documented for D3D10CreateDevice.
// SDKVersion
// SDK version. Use the D3D10_SDK_VERSION macro.
// ppDevice
// Pointer to returned interface.
//
// Return Values
// Any of those documented for
// CreateDXGIFactory
// IDXGIFactory::EnumAdapters
// IDXGIAdapter::RegisterDriver
// D3D10CreateDevice
//
///////////////////////////////////////////////////////////////////////////
HRESULT WINAPI D3D10CreateDevice(
_In_opt_ IDXGIAdapter *pAdapter,
D3D10_DRIVER_TYPE DriverType,
HMODULE Software,
UINT Flags,
UINT SDKVersion,
_Out_opt_ ID3D10Device **ppDevice);
///////////////////////////////////////////////////////////////////////////
// D3D10CreateDeviceAndSwapChain
// ------------------------------
//
// ppAdapter
// If NULL, D3D10CreateDevice will choose the primary adapter and
// create a new instance from a temporarily created IDXGIFactory.
// If non-NULL, D3D10CreateDevice will register the appropriate
// device, if necessary (via IDXGIAdapter::RegisterDrver), before
// creating the device.
// DriverType
// Specifies the driver type to be created: hardware, reference or
// null.
// Software
// HMODULE of a DLL implementing a software rasterizer. Must be NULL for
// non-Software driver types.
// Flags
// Any of those documented for D3D10CreateDevice.
// SDKVersion
// SDK version. Use the D3D10_SDK_VERSION macro.
// pSwapChainDesc
// Swap chain description, may be NULL.
// ppSwapChain
// Pointer to returned interface. May be NULL.
// ppDevice
// Pointer to returned interface.
//
// Return Values
// Any of those documented for
// CreateDXGIFactory
// IDXGIFactory::EnumAdapters
// IDXGIAdapter::RegisterDriver
// D3D10CreateDevice
// IDXGIFactory::CreateSwapChain
//
///////////////////////////////////////////////////////////////////////////
HRESULT WINAPI D3D10CreateDeviceAndSwapChain(
_In_opt_ IDXGIAdapter *pAdapter,
D3D10_DRIVER_TYPE DriverType,
HMODULE Software,
UINT Flags,
UINT SDKVersion,
_In_opt_ DXGI_SWAP_CHAIN_DESC *pSwapChainDesc,
_Out_opt_ IDXGISwapChain **ppSwapChain,
_Out_opt_ ID3D10Device **ppDevice);
///////////////////////////////////////////////////////////////////////////
// D3D10CreateBlob:
// -----------------
// Creates a Buffer of n Bytes
//////////////////////////////////////////////////////////////////////////
HRESULT WINAPI D3D10CreateBlob(SIZE_T NumBytes, _Out_ LPD3D10BLOB *ppBuffer);
#ifdef __cplusplus
}
#endif //__cplusplus
#endif //__D3D10EFFECT_H__

File diff suppressed because it is too large Load Diff

View File

@ -1,547 +0,0 @@
//////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// File: D3D10Shader.h
// Content: D3D10 Shader Types and APIs
//
//////////////////////////////////////////////////////////////////////////////
#ifndef __D3D10SHADER_H__
#define __D3D10SHADER_H__
#include "d3d10.h"
//---------------------------------------------------------------------------
// D3D10_TX_VERSION:
// --------------
// Version token used to create a procedural texture filler in effects
// Used by D3D10Fill[]TX functions
//---------------------------------------------------------------------------
#define D3D10_TX_VERSION(_Major,_Minor) (('T' << 24) | ('X' << 16) | ((_Major) << 8) | (_Minor))
//----------------------------------------------------------------------------
// D3D10SHADER flags:
// -----------------
// D3D10_SHADER_DEBUG
// Insert debug file/line/type/symbol information.
//
// D3D10_SHADER_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.
//
// D3D10_SHADER_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.
//
// D3D10_SHADER_PACK_MATRIX_ROW_MAJOR
// Unless explicitly specified, matrices will be packed in row-major order
// on input and output from the shader.
//
// D3D10_SHADER_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.
//
// D3D10_SHADER_PARTIAL_PRECISION
// Force all computations in resulting shader to occur at partial precision.
// This may result in faster evaluation of shaders on some hardware.
//
// D3D10_SHADER_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.
//
// D3D10_SHADER_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.
//
// D3D10_SHADER_NO_PRESHADER
// Disables Preshaders. Using this flag will cause the compiler to not
// pull out static expression for evaluation on the host cpu
//
// D3D10_SHADER_AVOID_FLOW_CONTROL
// Hint compiler to avoid flow-control constructs where possible.
//
// D3D10_SHADER_PREFER_FLOW_CONTROL
// Hint compiler to prefer flow-control constructs where possible.
//
// D3D10_SHADER_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.
//
// D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY
// This enables older shaders to compile to 4_0 targets.
//
//----------------------------------------------------------------------------
#define D3D10_SHADER_DEBUG (1 << 0)
#define D3D10_SHADER_SKIP_VALIDATION (1 << 1)
#define D3D10_SHADER_SKIP_OPTIMIZATION (1 << 2)
#define D3D10_SHADER_PACK_MATRIX_ROW_MAJOR (1 << 3)
#define D3D10_SHADER_PACK_MATRIX_COLUMN_MAJOR (1 << 4)
#define D3D10_SHADER_PARTIAL_PRECISION (1 << 5)
#define D3D10_SHADER_FORCE_VS_SOFTWARE_NO_OPT (1 << 6)
#define D3D10_SHADER_FORCE_PS_SOFTWARE_NO_OPT (1 << 7)
#define D3D10_SHADER_NO_PRESHADER (1 << 8)
#define D3D10_SHADER_AVOID_FLOW_CONTROL (1 << 9)
#define D3D10_SHADER_PREFER_FLOW_CONTROL (1 << 10)
#define D3D10_SHADER_ENABLE_STRICTNESS (1 << 11)
#define D3D10_SHADER_ENABLE_BACKWARDS_COMPATIBILITY (1 << 12)
#define D3D10_SHADER_IEEE_STRICTNESS (1 << 13)
#define D3D10_SHADER_WARNINGS_ARE_ERRORS (1 << 18)
#define D3D10_SHADER_RESOURCES_MAY_ALIAS (1 << 19)
#define D3D10_ENABLE_UNBOUNDED_DESCRIPTOR_TABLES (1 << 20)
#define D3D10_ALL_RESOURCES_BOUND (1 << 21)
// optimization level flags
#define D3D10_SHADER_OPTIMIZATION_LEVEL0 (1 << 14)
#define D3D10_SHADER_OPTIMIZATION_LEVEL1 0
#define D3D10_SHADER_OPTIMIZATION_LEVEL2 ((1 << 14) | (1 << 15))
#define D3D10_SHADER_OPTIMIZATION_LEVEL3 (1 << 15)
typedef D3D_SHADER_MACRO D3D10_SHADER_MACRO;
typedef D3D10_SHADER_MACRO* LPD3D10_SHADER_MACRO;
typedef D3D_SHADER_VARIABLE_CLASS D3D10_SHADER_VARIABLE_CLASS;
typedef D3D10_SHADER_VARIABLE_CLASS* LPD3D10_SHADER_VARIABLE_CLASS;
typedef D3D_SHADER_VARIABLE_FLAGS D3D10_SHADER_VARIABLE_FLAGS;
typedef D3D10_SHADER_VARIABLE_FLAGS* LPD3D10_SHADER_VARIABLE_FLAGS;
typedef D3D_SHADER_VARIABLE_TYPE D3D10_SHADER_VARIABLE_TYPE;
typedef D3D10_SHADER_VARIABLE_TYPE* LPD3D10_SHADER_VARIABLE_TYPE;
typedef D3D_SHADER_INPUT_FLAGS D3D10_SHADER_INPUT_FLAGS;
typedef D3D10_SHADER_INPUT_FLAGS* LPD3D10_SHADER_INPUT_FLAGS;
typedef D3D_SHADER_INPUT_TYPE D3D10_SHADER_INPUT_TYPE;
typedef D3D10_SHADER_INPUT_TYPE* LPD3D10_SHADER_INPUT_TYPE;
typedef D3D_SHADER_CBUFFER_FLAGS D3D10_SHADER_CBUFFER_FLAGS;
typedef D3D10_SHADER_CBUFFER_FLAGS* LPD3D10_SHADER_CBUFFER_FLAGS;
typedef D3D_CBUFFER_TYPE D3D10_CBUFFER_TYPE;
typedef D3D10_CBUFFER_TYPE* LPD3D10_CBUFFER_TYPE;
typedef D3D_NAME D3D10_NAME;
typedef D3D_RESOURCE_RETURN_TYPE D3D10_RESOURCE_RETURN_TYPE;
typedef D3D_REGISTER_COMPONENT_TYPE D3D10_REGISTER_COMPONENT_TYPE;
typedef D3D_INCLUDE_TYPE D3D10_INCLUDE_TYPE;
// ID3D10Include has been made version-neutral and moved to d3dcommon.h.
typedef interface ID3DInclude ID3D10Include;
typedef interface ID3DInclude* LPD3D10INCLUDE;
#define IID_ID3D10Include IID_ID3DInclude
//----------------------------------------------------------------------------
// ID3D10ShaderReflection:
//----------------------------------------------------------------------------
//
// Structure definitions
//
typedef struct _D3D10_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
D3D10_PRIMITIVE_TOPOLOGY GSOutputTopology; // Geometry shader output topology
UINT GSMaxOutputVertexCount; // Geometry shader maximum output vertex count
} D3D10_SHADER_DESC;
typedef struct _D3D10_SHADER_BUFFER_DESC
{
LPCSTR Name; // Name of the constant buffer
D3D10_CBUFFER_TYPE Type; // Indicates that this is a CBuffer or TBuffer
UINT Variables; // Number of member variables
UINT Size; // Size of CB (in bytes)
UINT uFlags; // Buffer description flags
} D3D10_SHADER_BUFFER_DESC;
typedef struct _D3D10_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
} D3D10_SHADER_VARIABLE_DESC;
typedef struct _D3D10_SHADER_TYPE_DESC
{
D3D10_SHADER_VARIABLE_CLASS Class; // Variable class (e.g. object, matrix, etc.)
D3D10_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)
} D3D10_SHADER_TYPE_DESC;
typedef struct _D3D10_SHADER_INPUT_BIND_DESC
{
LPCSTR Name; // Name of the resource
D3D10_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
D3D10_RESOURCE_RETURN_TYPE ReturnType; // Return type (if texture)
D3D10_SRV_DIMENSION Dimension; // Dimension (if texture)
UINT NumSamples; // Number of samples (0 if not MS texture)
} D3D10_SHADER_INPUT_BIND_DESC;
typedef struct _D3D10_SIGNATURE_PARAMETER_DESC
{
LPCSTR SemanticName; // Name of the semantic
UINT SemanticIndex; // Index of the semantic
UINT Register; // Number of member variables
D3D10_NAME SystemValueType;// A predefined system value, or D3D10_NAME_UNDEFINED if not applicable
D3D10_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 D3D10_COMPONENT_MASK values)
} D3D10_SIGNATURE_PARAMETER_DESC;
//
// Interface definitions
//
typedef interface ID3D10ShaderReflectionType ID3D10ShaderReflectionType;
typedef interface ID3D10ShaderReflectionType *LPD3D10SHADERREFLECTIONTYPE;
// {C530AD7D-9B16-4395-A979-BA2ECFF83ADD}
interface DECLSPEC_UUID("C530AD7D-9B16-4395-A979-BA2ECFF83ADD") ID3D10ShaderReflectionType;
DEFINE_GUID(IID_ID3D10ShaderReflectionType,
0xc530ad7d, 0x9b16, 0x4395, 0xa9, 0x79, 0xba, 0x2e, 0xcf, 0xf8, 0x3a, 0xdd);
#undef INTERFACE
#define INTERFACE ID3D10ShaderReflectionType
DECLARE_INTERFACE(ID3D10ShaderReflectionType)
{
STDMETHOD(GetDesc)(THIS_ D3D10_SHADER_TYPE_DESC *pDesc) PURE;
STDMETHOD_(ID3D10ShaderReflectionType*, GetMemberTypeByIndex)(THIS_ UINT Index) PURE;
STDMETHOD_(ID3D10ShaderReflectionType*, GetMemberTypeByName)(THIS_ LPCSTR Name) PURE;
STDMETHOD_(LPCSTR, GetMemberTypeName)(THIS_ UINT Index) PURE;
};
typedef interface ID3D10ShaderReflectionVariable ID3D10ShaderReflectionVariable;
typedef interface ID3D10ShaderReflectionVariable *LPD3D10SHADERREFLECTIONVARIABLE;
// {1BF63C95-2650-405d-99C1-3636BD1DA0A1}
interface DECLSPEC_UUID("1BF63C95-2650-405d-99C1-3636BD1DA0A1") ID3D10ShaderReflectionVariable;
DEFINE_GUID(IID_ID3D10ShaderReflectionVariable,
0x1bf63c95, 0x2650, 0x405d, 0x99, 0xc1, 0x36, 0x36, 0xbd, 0x1d, 0xa0, 0xa1);
#undef INTERFACE
#define INTERFACE ID3D10ShaderReflectionVariable
DECLARE_INTERFACE(ID3D10ShaderReflectionVariable)
{
STDMETHOD(GetDesc)(THIS_ _Out_ D3D10_SHADER_VARIABLE_DESC *pDesc) PURE;
STDMETHOD_(ID3D10ShaderReflectionType*, GetType)(THIS) PURE;
};
typedef interface ID3D10ShaderReflectionConstantBuffer ID3D10ShaderReflectionConstantBuffer;
typedef interface ID3D10ShaderReflectionConstantBuffer *LPD3D10SHADERREFLECTIONCONSTANTBUFFER;
// {66C66A94-DDDD-4b62-A66A-F0DA33C2B4D0}
interface DECLSPEC_UUID("66C66A94-DDDD-4b62-A66A-F0DA33C2B4D0") ID3D10ShaderReflectionConstantBuffer;
DEFINE_GUID(IID_ID3D10ShaderReflectionConstantBuffer,
0x66c66a94, 0xdddd, 0x4b62, 0xa6, 0x6a, 0xf0, 0xda, 0x33, 0xc2, 0xb4, 0xd0);
#undef INTERFACE
#define INTERFACE ID3D10ShaderReflectionConstantBuffer
DECLARE_INTERFACE(ID3D10ShaderReflectionConstantBuffer)
{
STDMETHOD(GetDesc)(THIS_ _Out_ D3D10_SHADER_BUFFER_DESC *pDesc) PURE;
STDMETHOD_(ID3D10ShaderReflectionVariable*, GetVariableByIndex)(THIS_ UINT Index) PURE;
STDMETHOD_(ID3D10ShaderReflectionVariable*, GetVariableByName)(THIS_ LPCSTR Name) PURE;
};
typedef interface ID3D10ShaderReflection ID3D10ShaderReflection;
typedef interface ID3D10ShaderReflection *LPD3D10SHADERREFLECTION;
// {D40E20B6-F8F7-42ad-AB20-4BAF8F15DFAA}
interface DECLSPEC_UUID("D40E20B6-F8F7-42ad-AB20-4BAF8F15DFAA") ID3D10ShaderReflection;
DEFINE_GUID(IID_ID3D10ShaderReflection,
0xd40e20b6, 0xf8f7, 0x42ad, 0xab, 0x20, 0x4b, 0xaf, 0x8f, 0x15, 0xdf, 0xaa);
#undef INTERFACE
#define INTERFACE ID3D10ShaderReflection
DECLARE_INTERFACE_(ID3D10ShaderReflection, IUnknown)
{
STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
STDMETHOD_(ULONG, AddRef)(THIS) PURE;
STDMETHOD_(ULONG, Release)(THIS) PURE;
STDMETHOD(GetDesc)(THIS_ _Out_ D3D10_SHADER_DESC *pDesc) PURE;
STDMETHOD_(ID3D10ShaderReflectionConstantBuffer*, GetConstantBufferByIndex)(THIS_ UINT Index) PURE;
STDMETHOD_(ID3D10ShaderReflectionConstantBuffer*, GetConstantBufferByName)(THIS_ LPCSTR Name) PURE;
STDMETHOD(GetResourceBindingDesc)(THIS_ UINT ResourceIndex, _Out_ D3D10_SHADER_INPUT_BIND_DESC *pDesc) PURE;
STDMETHOD(GetInputParameterDesc)(THIS_ UINT ParameterIndex, _Out_ D3D10_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
STDMETHOD(GetOutputParameterDesc)(THIS_ UINT ParameterIndex, _Out_ D3D10_SIGNATURE_PARAMETER_DESC *pDesc) PURE;
};
//////////////////////////////////////////////////////////////////////////////
// APIs //////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
extern "C" {
#endif //__cplusplus
//----------------------------------------------------------------------------
// D3D10CompileShader:
// ------------------
// Compiles a shader.
//
// Parameters:
// pSrcFile
// Source file name.
// hSrcModule
// Module handle. if NULL, current module will be used.
// pSrcResource
// Resource name in module.
// pSrcData
// Pointer to source code.
// SrcDataSize
// Size of source code, in bytes.
// pDefines
// Optional NULL-terminated array of preprocessor macro definitions.
// pInclude
// Optional interface pointer to use for handling #include directives.
// If this parameter is NULL, #includes will be honored when compiling
// from file, and will error when compiling from resource or memory.
// pFunctionName
// Name of the entrypoint function where execution should begin.
// pProfile
// Instruction set to be used when generating code. The D3D10 entry
// point currently supports only "vs_4_0", "ps_4_0", and "gs_4_0".
// Flags
// See D3D10_SHADER_xxx flags.
// ppShader
// Returns a buffer containing the created shader. This buffer contains
// the compiled shader code, as well as any embedded debug and symbol
// table info. (See D3D10GetShaderConstantTable)
// ppErrorMsgs
// Returns a buffer containing a listing of errors and warnings that were
// encountered during the compile. If you are running in a debugger,
// these are the same messages you will see in your debug output.
//----------------------------------------------------------------------------
HRESULT WINAPI D3D10CompileShader(_In_reads_bytes_(SrcDataSize) LPCSTR pSrcData, SIZE_T SrcDataSize, _In_opt_ LPCSTR pFileName, _In_opt_ CONST D3D10_SHADER_MACRO* pDefines, _In_opt_ LPD3D10INCLUDE pInclude,
LPCSTR pFunctionName, LPCSTR pProfile, UINT Flags, _Out_ ID3D10Blob** ppShader, _Out_opt_ ID3D10Blob** ppErrorMsgs);
//----------------------------------------------------------------------------
// D3D10DisassembleShader:
// ----------------------
// Takes a binary shader, and returns a buffer containing text assembly.
//
// Parameters:
// pShader
// Pointer to the shader byte code.
// BytecodeLength
// Size of the shader byte code in bytes.
// EnableColorCode
// Emit HTML tags for color coding the output?
// pComments
// Pointer to a comment string to include at the top of the shader.
// ppDisassembly
// Returns a buffer containing the disassembled shader.
//----------------------------------------------------------------------------
HRESULT WINAPI D3D10DisassembleShader(_In_reads_bytes_(BytecodeLength) CONST void *pShader, SIZE_T BytecodeLength, BOOL EnableColorCode, _In_opt_ LPCSTR pComments, _Out_ ID3D10Blob** ppDisassembly);
//----------------------------------------------------------------------------
// D3D10GetPixelShaderProfile/D3D10GetVertexShaderProfile/D3D10GetGeometryShaderProfile:
// -----------------------------------------------------
// Returns the name of the HLSL profile best suited to a given device.
//
// Parameters:
// pDevice
// Pointer to the device in question
//----------------------------------------------------------------------------
LPCSTR WINAPI D3D10GetPixelShaderProfile(_In_ ID3D10Device *pDevice);
LPCSTR WINAPI D3D10GetVertexShaderProfile(_In_ ID3D10Device *pDevice);
LPCSTR WINAPI D3D10GetGeometryShaderProfile(_In_ ID3D10Device *pDevice);
//----------------------------------------------------------------------------
// D3D10ReflectShader:
// ------------------
// Creates a shader reflection object that can be used to retrieve information
// about a compiled shader
//
// Parameters:
// pShaderBytecode
// Pointer to a compiled shader (same pointer that is passed into
// ID3D10Device::CreateShader)
// BytecodeLength
// Length of the shader bytecode buffer
// ppReflector
// [out] Returns a ID3D10ShaderReflection object that can be used to
// retrieve shader resource and constant buffer information
//
//----------------------------------------------------------------------------
HRESULT WINAPI D3D10ReflectShader(_In_reads_bytes_(BytecodeLength) CONST void *pShaderBytecode, SIZE_T BytecodeLength, _Out_ ID3D10ShaderReflection **ppReflector);
//----------------------------------------------------------------------------
// D3D10PreprocessShader
// ---------------------
// Creates a shader reflection object that can be used to retrieve information
// about a compiled shader
//
// Parameters:
// pSrcData
// Pointer to source code
// SrcDataSize
// Size of source code, in bytes
// pFileName
// Source file name (used for error output)
// pDefines
// Optional NULL-terminated array of preprocessor macro definitions.
// pInclude
// Optional interface pointer to use for handling #include directives.
// If this parameter is NULL, #includes will be honored when assembling
// from file, and will error when assembling from resource or memory.
// ppShaderText
// Returns a buffer containing a single large string that represents
// the resulting formatted token stream
// ppErrorMsgs
// Returns a buffer containing a listing of errors and warnings that were
// encountered during assembly. If you are running in a debugger,
// these are the same messages you will see in your debug output.
//----------------------------------------------------------------------------
HRESULT WINAPI D3D10PreprocessShader(_In_reads_bytes_(SrcDataSize) LPCSTR pSrcData, SIZE_T SrcDataSize, _In_opt_ LPCSTR pFileName, _In_opt_ CONST D3D10_SHADER_MACRO* pDefines,
_In_opt_ LPD3D10INCLUDE pInclude, _Out_ ID3D10Blob** ppShaderText, _Out_opt_ ID3D10Blob** ppErrorMsgs);
//////////////////////////////////////////////////////////////////////////
//
// Shader blob manipulation routines
// ---------------------------------
//
// void *pShaderBytecode - a buffer containing the result of an HLSL
// compilation. Typically this opaque buffer contains several
// discrete sections including the shader executable code, the input
// signature, and the output signature. This can typically be retrieved
// by calling ID3D10Blob::GetBufferPointer() on the returned blob
// from HLSL's compile APIs.
//
// UINT BytecodeLength - the length of pShaderBytecode. This can
// typically be retrieved by calling ID3D10Blob::GetBufferSize()
// on the returned blob from HLSL's compile APIs.
//
// ID3D10Blob **ppSignatureBlob(s) - a newly created buffer that
// contains only the signature portions of the original bytecode.
// This is a copy; the original bytecode is not modified. You may
// specify NULL for this parameter to have the bytecode validated
// for the presence of the corresponding signatures without actually
// copying them and creating a new blob.
//
// Returns E_INVALIDARG if any required parameters are NULL
// Returns E_FAIL is the bytecode is corrupt or missing signatures
// Returns S_OK on success
//
//////////////////////////////////////////////////////////////////////////
HRESULT WINAPI D3D10GetInputSignatureBlob(_In_reads_bytes_(BytecodeLength) CONST void *pShaderBytecode, SIZE_T BytecodeLength, _Out_ ID3D10Blob **ppSignatureBlob);
HRESULT WINAPI D3D10GetOutputSignatureBlob(_In_reads_bytes_(BytecodeLength) CONST void *pShaderBytecode, SIZE_T BytecodeLength, _Out_ ID3D10Blob **ppSignatureBlob);
HRESULT WINAPI D3D10GetInputAndOutputSignatureBlob(_In_reads_bytes_(BytecodeLength) CONST void *pShaderBytecode, SIZE_T BytecodeLength, _Out_ ID3D10Blob **ppSignatureBlob);
//----------------------------------------------------------------------------
// D3D10GetShaderDebugInfo:
// -----------------------
// Gets shader debug info. Debug info is generated by D3D10CompileShader and is
// embedded in the body of the shader.
//
// Parameters:
// pShaderBytecode
// Pointer to the function bytecode
// BytecodeLength
// Length of the shader bytecode buffer
// ppDebugInfo
// Buffer used to return debug info. For information about the layout
// of this buffer, see definition of D3D10_SHADER_DEBUG_INFO above.
//----------------------------------------------------------------------------
HRESULT WINAPI D3D10GetShaderDebugInfo(_In_reads_bytes_(BytecodeLength) CONST void *pShaderBytecode, SIZE_T BytecodeLength, _Out_ ID3D10Blob** ppDebugInfo);
#ifdef __cplusplus
}
#endif //__cplusplus
#endif //__D3D10SHADER_H__

View File

@ -8,7 +8,7 @@
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 8.00.0613 */
/* File created by MIDL compiler version 8.01.0622 */
/* @@MIDL_FILE_HEADING( ) */
@ -7306,7 +7306,9 @@ enum D3D11_FEATURE
D3D11_FEATURE_D3D9_OPTIONS1 = ( D3D11_FEATURE_MARKER_SUPPORT + 1 ) ,
D3D11_FEATURE_D3D11_OPTIONS2 = ( D3D11_FEATURE_D3D9_OPTIONS1 + 1 ) ,
D3D11_FEATURE_D3D11_OPTIONS3 = ( D3D11_FEATURE_D3D11_OPTIONS2 + 1 ) ,
D3D11_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT = ( D3D11_FEATURE_D3D11_OPTIONS3 + 1 )
D3D11_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT = ( D3D11_FEATURE_D3D11_OPTIONS3 + 1 ) ,
D3D11_FEATURE_D3D11_OPTIONS4 = ( D3D11_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT + 1 ) ,
D3D11_FEATURE_SHADER_CACHE = ( D3D11_FEATURE_D3D11_OPTIONS4 + 1 )
} D3D11_FEATURE;
typedef struct D3D11_FEATURE_DATA_THREADING
@ -7463,6 +7465,19 @@ typedef struct D3D11_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT
UINT MaxGPUVirtualAddressBitsPerProcess;
} D3D11_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT;
typedef
enum D3D11_SHADER_CACHE_SUPPORT_FLAGS
{
D3D11_SHADER_CACHE_SUPPORT_NONE = 0,
D3D11_SHADER_CACHE_SUPPORT_AUTOMATIC_INPROC_CACHE = 0x1,
D3D11_SHADER_CACHE_SUPPORT_AUTOMATIC_DISK_CACHE = 0x2
} D3D11_SHADER_CACHE_SUPPORT_FLAGS;
typedef struct D3D11_FEATURE_DATA_SHADER_CACHE
{
UINT SupportFlags;
} D3D11_FEATURE_DATA_SHADER_CACHE;
extern RPC_IF_HANDLE __MIDL_itf_d3d11_0000_0029_v0_0_c_ifspec;
@ -9661,6 +9676,9 @@ DEFINE_GUID(D3D11_DECODER_PROFILE_MPEG4PT2_VLD_ADVSIMPLE_NOGMC, 0xed418a9f, 0x0
DEFINE_GUID(D3D11_DECODER_PROFILE_MPEG4PT2_VLD_ADVSIMPLE_GMC, 0xab998b5b, 0x4258,0x44a9,0x9f,0xeb,0x94,0xe5,0x97,0xa6,0xba,0xae);
DEFINE_GUID(D3D11_DECODER_PROFILE_HEVC_VLD_MAIN, 0x5b11d51b, 0x2f4c,0x4452,0xbc,0xc3,0x09,0xf2,0xa1,0x16,0x0c,0xc0);
DEFINE_GUID(D3D11_DECODER_PROFILE_HEVC_VLD_MAIN10, 0x107af0e0, 0xef1a,0x4d19,0xab,0xa8,0x67,0xa1,0x63,0x07,0x3d,0x13);
DEFINE_GUID(D3D11_DECODER_PROFILE_VP9_VLD_PROFILE0, 0x463707f8, 0xa1d0, 0x4585, 0x87, 0x6d, 0x83, 0xaa, 0x6d, 0x60, 0xb8, 0x9e);
DEFINE_GUID(D3D11_DECODER_PROFILE_VP9_VLD_10BIT_PROFILE2, 0xa4c749ef, 0x6ecf, 0x48aa, 0x84, 0x48, 0x50, 0xa7, 0xa1, 0x16, 0x5f, 0xf7);
DEFINE_GUID(D3D11_DECODER_PROFILE_VP8_VLD, 0x90b899ea, 0x3a62, 0x4705, 0x88, 0xb3, 0x8d, 0xf0, 0x4b, 0x27, 0x44, 0xe7);
typedef struct D3D11_VIDEO_DECODER_DESC
{
GUID Guid;
@ -9929,7 +9947,8 @@ enum D3D11_VIDEO_PROCESSOR_FEATURE_CAPS
D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_ALPHA_STREAM = 0x80,
D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_PIXEL_ASPECT_RATIO = 0x100,
D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_MIRROR = 0x200,
D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_SHADER_USAGE = 0x400
D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_SHADER_USAGE = 0x400,
D3D11_VIDEO_PROCESSOR_FEATURE_CAPS_METADATA_HDR10 = 0x800
} D3D11_VIDEO_PROCESSOR_FEATURE_CAPS;
typedef
@ -14381,11 +14400,11 @@ enum D3D11_CREATE_DEVICE_FLAG
#if !defined( D3D11_IGNORE_SDK_LAYERS )
#include "d3d11sdklayers.h"
#endif
#include "d3d10_1.h"
#include "d3d10shader.h"
#include "d3d10_1shader.h"
#include "d3d10misc.h"
#include "d3d10effect.h"
// BK - #include "d3d10_1.h"
// BK - #include "d3d10shader.h"
// BK - #include "d3d10_1shader.h"
// BK - #include "d3d10misc.h"
// BK - #include "d3d10effect.h"
///////////////////////////////////////////////////////////////////////////
// D3D11CreateDevice

View File

@ -8,7 +8,7 @@
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 8.00.0613 */
/* File created by MIDL compiler version 8.01.0622 */
/* @@MIDL_FILE_HEADING( ) */

View File

@ -8,7 +8,7 @@
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 8.00.0613 */
/* File created by MIDL compiler version 8.01.0622 */
/* @@MIDL_FILE_HEADING( ) */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 8.00.0613 */
/* File created by MIDL compiler version 8.01.0622 */
/* @@MIDL_FILE_HEADING( ) */
@ -1522,7 +1522,8 @@ enum D3D11_MESSAGE_ID
D3D11_MESSAGE_ID_ENQUEUESETEVENT_OUTOFMEMORY_RETURN = ( D3D11_MESSAGE_ID_ENQUEUESETEVENT_INVALIDARG_RETURN + 1 ) ,
D3D11_MESSAGE_ID_ENQUEUESETEVENT_ACCESSDENIED_RETURN = ( D3D11_MESSAGE_ID_ENQUEUESETEVENT_OUTOFMEMORY_RETURN + 1 ) ,
D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_NUMUAVS_INVALIDRANGE = ( D3D11_MESSAGE_ID_ENQUEUESETEVENT_ACCESSDENIED_RETURN + 1 ) ,
D3D11_MESSAGE_ID_D3D11_MESSAGES_END = ( D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_NUMUAVS_INVALIDRANGE + 1 ) ,
D3D11_MESSAGE_ID_USE_OF_ZERO_REFCOUNT_OBJECT = ( D3D11_MESSAGE_ID_DEVICE_OMSETRENDERTARGETSANDUNORDEREDACCESSVIEWS_NUMUAVS_INVALIDRANGE + 1 ) ,
D3D11_MESSAGE_ID_D3D11_MESSAGES_END = ( D3D11_MESSAGE_ID_USE_OF_ZERO_REFCOUNT_OBJECT + 1 ) ,
D3D11_MESSAGE_ID_D3D11_1_MESSAGES_START = 0x300000,
D3D11_MESSAGE_ID_CREATE_VIDEODECODER = ( D3D11_MESSAGE_ID_D3D11_1_MESSAGES_START + 1 ) ,
D3D11_MESSAGE_ID_CREATE_VIDEOPROCESSORENUM = ( D3D11_MESSAGE_ID_CREATE_VIDEODECODER + 1 ) ,
@ -1911,7 +1912,8 @@ enum D3D11_MESSAGE_ID
D3D11_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_TARGETRECT = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_INVALIDSTREAMCOUNT + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_INVALIDSOURCERECT = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_TARGETRECT + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_INVALIDDESTRECT = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_INVALIDSOURCERECT + 1 ) ,
D3D11_MESSAGE_ID_D3D11_1_MESSAGES_END = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_INVALIDDESTRECT + 1 ) ,
D3D11_MESSAGE_ID_GETCRYPTOSESSIONPRIVATEDATASIZE_INVALID_KEY_EXCHANGE_TYPE = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETBEHAVIORHINTS_INVALIDDESTRECT + 1 ) ,
D3D11_MESSAGE_ID_D3D11_1_MESSAGES_END = ( D3D11_MESSAGE_ID_GETCRYPTOSESSIONPRIVATEDATASIZE_INVALID_KEY_EXCHANGE_TYPE + 1 ) ,
D3D11_MESSAGE_ID_D3D11_2_MESSAGES_START = ( D3D11_MESSAGE_ID_D3D11_1_MESSAGES_END + 1 ) ,
D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDUSAGE = ( D3D11_MESSAGE_ID_D3D11_2_MESSAGES_START + 1 ) ,
D3D11_MESSAGE_ID_CREATETEXTURE1D_INVALIDUSAGE = ( D3D11_MESSAGE_ID_CREATEBUFFER_INVALIDUSAGE + 1 ) ,
@ -2018,7 +2020,35 @@ enum D3D11_MESSAGE_ID
D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_UNSUPPORTEDCONTEXTTTYPEFORQUERY = ( D3D11_MESSAGE_ID_JPEGENCODE_BACKBUFFERNOTSUPPORTED + 1 ) ,
D3D11_MESSAGE_ID_FLUSH1_INVALIDCONTEXTTYPE = ( D3D11_MESSAGE_ID_CREATEQUERYORPREDICATE_UNSUPPORTEDCONTEXTTTYPEFORQUERY + 1 ) ,
D3D11_MESSAGE_ID_DEVICE_SETHARDWAREPROTECTION_INVALIDCONTEXT = ( D3D11_MESSAGE_ID_FLUSH1_INVALIDCONTEXTTYPE + 1 ) ,
D3D11_MESSAGE_ID_D3D11_3_MESSAGES_END = ( D3D11_MESSAGE_ID_DEVICE_SETHARDWAREPROTECTION_INVALIDCONTEXT + 1 )
D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTHDRMETADATA_NULLPARAM = ( D3D11_MESSAGE_ID_DEVICE_SETHARDWAREPROTECTION_INVALIDCONTEXT + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTHDRMETADATA_INVALIDSIZE = ( D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTHDRMETADATA_NULLPARAM + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTHDRMETADATA_NULLPARAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORSETOUTPUTHDRMETADATA_INVALIDSIZE + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTHDRMETADATA_INVALIDSIZE = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTHDRMETADATA_NULLPARAM + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMHDRMETADATA_NULLPARAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETOUTPUTHDRMETADATA_INVALIDSIZE + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMHDRMETADATA_INVALIDSTREAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMHDRMETADATA_NULLPARAM + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMHDRMETADATA_INVALIDSIZE = ( D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMHDRMETADATA_INVALIDSTREAM + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMHDRMETADATA_NULLPARAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORSETSTREAMHDRMETADATA_INVALIDSIZE + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMHDRMETADATA_INVALIDSTREAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMHDRMETADATA_NULLPARAM + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMHDRMETADATA_INVALIDSIZE = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMHDRMETADATA_INVALIDSTREAM + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMFRAMEFORMAT_INVALIDSTREAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMHDRMETADATA_INVALIDSIZE + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMCOLORSPACE_INVALIDSTREAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMFRAMEFORMAT_INVALIDSTREAM + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMOUTPUTRATE_INVALIDSTREAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMCOLORSPACE_INVALIDSTREAM + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMSOURCERECT_INVALIDSTREAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMOUTPUTRATE_INVALIDSTREAM + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMDESTRECT_INVALIDSTREAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMSOURCERECT_INVALIDSTREAM + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMALPHA_INVALIDSTREAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMDESTRECT_INVALIDSTREAM + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMPALETTE_INVALIDSTREAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMALPHA_INVALIDSTREAM + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMPIXELASPECTRATIO_INVALIDSTREAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMPALETTE_INVALIDSTREAM + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMLUMAKEY_INVALIDSTREAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMPIXELASPECTRATIO_INVALIDSTREAM + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMSTEREOFORMAT_INVALIDSTREAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMLUMAKEY_INVALIDSTREAM + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMAUTOPROCESSINGMODE_INVALIDSTREAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMSTEREOFORMAT_INVALIDSTREAM + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMFILTER_INVALIDSTREAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMAUTOPROCESSINGMODE_INVALIDSTREAM + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMROTATION_INVALIDSTREAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMFILTER_INVALIDSTREAM + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMCOLORSPACE1_INVALIDSTREAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMROTATION_INVALIDSTREAM + 1 ) ,
D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMMIRROR_INVALIDSTREAM = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMCOLORSPACE1_INVALIDSTREAM + 1 ) ,
D3D11_MESSAGE_ID_CREATE_FENCE = ( D3D11_MESSAGE_ID_VIDEOPROCESSORGETSTREAMMIRROR_INVALIDSTREAM + 1 ) ,
D3D11_MESSAGE_ID_LIVE_FENCE = ( D3D11_MESSAGE_ID_CREATE_FENCE + 1 ) ,
D3D11_MESSAGE_ID_DESTROY_FENCE = ( D3D11_MESSAGE_ID_LIVE_FENCE + 1 ) ,
D3D11_MESSAGE_ID_D3D11_3_MESSAGES_END = ( D3D11_MESSAGE_ID_DESTROY_FENCE + 1 )
} D3D11_MESSAGE_ID;
typedef struct D3D11_MESSAGE

View File

@ -3,7 +3,7 @@
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 8.00.0613 */
/* File created by MIDL compiler version 8.01.0622 */
/* @@MIDL_FILE_HEADING( ) */

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

@ -10,6 +10,7 @@
#ifndef _d3d9TYPES_H_
#define _d3d9TYPES_H_
#ifndef DIRECT3D_VERSION
#define DIRECT3D_VERSION 0x0900
#endif //DIRECT3D_VERSION
@ -78,6 +79,8 @@ typedef struct _D3DRECT {
#define D3DRECT_DEFINED
#endif
#ifndef D3DMATRIX_DEFINED
typedef struct _D3DMATRIX {
union {
@ -94,6 +97,8 @@ typedef struct _D3DMATRIX {
#define D3DMATRIX_DEFINED
#endif
typedef struct _D3DVIEWPORT9 {
DWORD X;
DWORD Y; /* Viewport Top left */
@ -1166,6 +1171,24 @@ typedef enum _D3DSHADER_PARAM_SRCMOD_TYPE
D3DSPSM_FORCE_DWORD = 0x7fffffff, // force 32-bit size enum
} D3DSHADER_PARAM_SRCMOD_TYPE;
// Source or dest token bits [15:14]:
// destination parameter modifiers
#define D3DSP_MIN_PRECISION_SHIFT 14
#define D3DSP_MIN_PRECISION_MASK 0x0000C000
typedef enum _D3DSHADER_MIN_PRECISION
{
D3DMP_DEFAULT = 0, // Default precision for the shader model
D3DMP_16 = 1, // 16 bit per component
D3DMP_2_8 = 2, // 10 bits (2.8) per component
} D3DSHADER_MIN_PRECISION;
// If the older D3DSPDM_PARTIALPRECISION is set,
// that is equivalent to the whole operation specifying
// D3DMP_16 (on all operands). The two encodings are not
// used together however.
// pixel shader version token
#define D3DPS_VERSION(_Major,_Minor) (0xFFFF0000|((_Major)<<8)|(_Minor))
@ -1641,6 +1664,7 @@ typedef enum _D3DRESOURCETYPE {
/* CubeMap Face identifiers */
typedef enum _D3DCUBEMAP_FACES
{

View File

@ -3,7 +3,7 @@
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 8.00.0613 */
/* File created by MIDL compiler version 8.01.0622 */
/* @@MIDL_FILE_HEADING( ) */
@ -100,6 +100,13 @@ typedef interface ID3D10Blob ID3D10Blob;
#endif /* __ID3D10Blob_FWD_DEFINED__ */
#ifndef __ID3DDestructionNotifier_FWD_DEFINED__
#define __ID3DDestructionNotifier_FWD_DEFINED__
typedef interface ID3DDestructionNotifier ID3DDestructionNotifier;
#endif /* __ID3DDestructionNotifier_FWD_DEFINED__ */
/* header files for imported files */
#include "oaidl.h"
#include "ocidl.h"
@ -496,6 +503,119 @@ typedef ID3D10Blob ID3DBlob;
typedef ID3DBlob* LPD3DBLOB;
#define IID_ID3DBlob IID_ID3D10Blob
typedef void ( __stdcall *PFN_DESTRUCTION_CALLBACK )(
void *pData);
extern RPC_IF_HANDLE __MIDL_itf_d3dcommon_0000_0001_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_d3dcommon_0000_0001_v0_0_s_ifspec;
#ifndef __ID3DDestructionNotifier_INTERFACE_DEFINED__
#define __ID3DDestructionNotifier_INTERFACE_DEFINED__
/* interface ID3DDestructionNotifier */
/* [unique][local][object][uuid] */
EXTERN_C const IID IID_ID3DDestructionNotifier;
#if defined(__cplusplus) && !defined(CINTERFACE)
MIDL_INTERFACE("a06eb39a-50da-425b-8c31-4eecd6c270f3")
ID3DDestructionNotifier : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE RegisterDestructionCallback(
/* [annotation] */
_In_ PFN_DESTRUCTION_CALLBACK callbackFn,
/* [annotation] */
_In_ void *pData,
/* [annotation] */
_Out_ UINT *pCallbackID) = 0;
virtual HRESULT STDMETHODCALLTYPE UnregisterDestructionCallback(
/* [annotation] */
_In_ UINT callbackID) = 0;
};
#else /* C style interface */
typedef struct ID3DDestructionNotifierVtbl
{
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
ID3DDestructionNotifier * This,
/* [in] */ REFIID riid,
/* [annotation][iid_is][out] */
_COM_Outptr_ void **ppvObject);
ULONG ( STDMETHODCALLTYPE *AddRef )(
ID3DDestructionNotifier * This);
ULONG ( STDMETHODCALLTYPE *Release )(
ID3DDestructionNotifier * This);
HRESULT ( STDMETHODCALLTYPE *RegisterDestructionCallback )(
ID3DDestructionNotifier * This,
/* [annotation] */
_In_ PFN_DESTRUCTION_CALLBACK callbackFn,
/* [annotation] */
_In_ void *pData,
/* [annotation] */
_Out_ UINT *pCallbackID);
HRESULT ( STDMETHODCALLTYPE *UnregisterDestructionCallback )(
ID3DDestructionNotifier * This,
/* [annotation] */
_In_ UINT callbackID);
END_INTERFACE
} ID3DDestructionNotifierVtbl;
interface ID3DDestructionNotifier
{
CONST_VTBL struct ID3DDestructionNotifierVtbl *lpVtbl;
};
#ifdef COBJMACROS
#define ID3DDestructionNotifier_QueryInterface(This,riid,ppvObject) \
( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) )
#define ID3DDestructionNotifier_AddRef(This) \
( (This)->lpVtbl -> AddRef(This) )
#define ID3DDestructionNotifier_Release(This) \
( (This)->lpVtbl -> Release(This) )
#define ID3DDestructionNotifier_RegisterDestructionCallback(This,callbackFn,pData,pCallbackID) \
( (This)->lpVtbl -> RegisterDestructionCallback(This,callbackFn,pData,pCallbackID) )
#define ID3DDestructionNotifier_UnregisterDestructionCallback(This,callbackID) \
( (This)->lpVtbl -> UnregisterDestructionCallback(This,callbackID) )
#endif /* COBJMACROS */
#endif /* C style interface */
#endif /* __ID3DDestructionNotifier_INTERFACE_DEFINED__ */
/* interface __MIDL_itf_d3dcommon_0000_0002 */
/* [local] */
typedef
enum _D3D_INCLUDE_TYPE
{
@ -920,8 +1040,8 @@ DEFINE_GUID(WKPDID_CommentStringW,0xd0149dc0,0x90e8,0x4ec8,0x81, 0x44, 0xe9, 0x0
#define D3D_COMPONENT_MASK_W 8
extern RPC_IF_HANDLE __MIDL_itf_d3dcommon_0000_0001_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_d3dcommon_0000_0001_v0_0_s_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_d3dcommon_0000_0002_v0_0_c_ifspec;
extern RPC_IF_HANDLE __MIDL_itf_d3dcommon_0000_0002_v0_0_s_ifspec;
/* Additional Prototypes for ALL interfaces */

View File

@ -10,6 +10,7 @@
#ifndef __D3DCOMPILER_H__
#define __D3DCOMPILER_H__
#include <winapifamily.h>
// Current name of the DLL shipped in the same SDK as this header.
@ -40,6 +41,8 @@ extern "C" {
#endif //__cplusplus
// BK - pragma region Application Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
//----------------------------------------------------------------------------
// D3DReadFileToBlob:
@ -123,6 +126,16 @@ D3DWriteBlobToFile(_In_ ID3DBlob* pBlob,
// 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)
@ -149,6 +162,8 @@ D3DWriteBlobToFile(_In_ ID3DBlob* pBlob,
#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:
@ -173,6 +188,14 @@ D3DWriteBlobToFile(_In_ ID3DBlob* pBlob,
#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:
// ----------
@ -303,9 +326,9 @@ D3DReflect(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
HRESULT WINAPI
D3DReflectLibrary(__in_bcount(SrcDataSize) LPCVOID pSrcData,
SIZE_T SrcDataSize,
REFIID riid,
LPVOID * ppReflector);
__in SIZE_T SrcDataSize,
__in REFIID riid,
__out LPVOID * ppReflector);
//----------------------------------------------------------------------------
// D3DDisassemble:
@ -350,7 +373,7 @@ D3DDisassembleRegion(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
// Shader linking and Function Linking Graph (FLG) APIs
//----------------------------------------------------------------------------
HRESULT WINAPI
D3DCreateLinker(interface ID3D11Linker ** ppLinker);
D3DCreateLinker(__out interface ID3D11Linker ** ppLinker);
HRESULT WINAPI
D3DLoadModule(_In_ LPCVOID pSrcData,
@ -455,6 +478,7 @@ typedef enum D3D_BLOB_PART
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.
@ -532,8 +556,12 @@ D3DDecompressShaders(_In_reads_bytes_(SrcDataSize) LPCVOID pSrcData,
_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:
@ -547,6 +575,8 @@ D3DDisassemble10Effect(_In_ interface ID3D10Effect *pEffect,
_In_ UINT Flags,
_Out_ ID3DBlob** ppDisassembly);
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// BK - pragma endregion
#ifdef __cplusplus

View File

@ -1349,9 +1349,12 @@ namespace MinGW_Workaround
{
inline D3D12_RESOURCE_DESC ID3D12ResourceGetDesc(ID3D12Resource* _resource)
{
typedef void (STDMETHODCALLTYPE ID3D12Resource::*PFN_GET_GET_DESC)(D3D12_RESOURCE_DESC*);
D3D12_RESOURCE_DESC desc;
(_resource->*(PFN_GET_GET_DESC)(&ID3D12Resource::GetDesc))(&desc);
union {
D3D12_RESOURCE_DESC (STDMETHODCALLTYPE ID3D12Resource::*w)();
void (STDMETHODCALLTYPE ID3D12Resource::*f)(D3D12_RESOURCE_DESC *);
} conversion = { &ID3D12Resource::GetDesc };
(_resource->*conversion.f)(&desc);
return desc;
}
}

View File

@ -3,7 +3,7 @@
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 8.00.0613 */
/* File created by MIDL compiler version 8.01.0622 */
/* @@MIDL_FILE_HEADING( ) */
@ -140,8 +140,8 @@ typedef interface IDXGIDevice1 IDXGIDevice1;
/* header files for imported files */
#include "oaidl.h"
#include "ocidl.h"
#include "dxgicommon.h"
#include "dxgitype.h"
#include "d3dcommon.h"
#ifdef __cplusplus
extern "C"{
@ -181,6 +181,8 @@ typedef struct DXGI_MAPPED_RECT
} DXGI_MAPPED_RECT;
#ifdef __midl
#ifndef LUID_DEFINED
#define LUID_DEFINED 1
typedef struct _LUID
{
DWORD LowPart;
@ -189,6 +191,7 @@ typedef struct _LUID
typedef struct _LUID *PLUID;
#endif
#endif
typedef struct DXGI_ADAPTER_DESC
{
@ -273,7 +276,9 @@ enum DXGI_SWAP_CHAIN_FLAG
DXGI_SWAP_CHAIN_FLAG_FOREGROUND_LAYER = 128,
DXGI_SWAP_CHAIN_FLAG_FULLSCREEN_VIDEO = 256,
DXGI_SWAP_CHAIN_FLAG_YUV_VIDEO = 512,
DXGI_SWAP_CHAIN_FLAG_HW_PROTECTED = 1024
DXGI_SWAP_CHAIN_FLAG_HW_PROTECTED = 1024,
DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING = 2048,
DXGI_SWAP_CHAIN_FLAG_RESTRICTED_TO_ALL_HOLOGRAPHIC_DISPLAYS = 4096
} DXGI_SWAP_CHAIN_FLAG;
typedef struct DXGI_SWAP_CHAIN_DESC
@ -319,7 +324,7 @@ EXTERN_C const IID IID_IDXGIObject;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown) = 0;
_In_opt_ const IUnknown *pUnknown) = 0;
virtual HRESULT STDMETHODCALLTYPE GetPrivateData(
/* [annotation][in] */
@ -369,7 +374,7 @@ EXTERN_C const IID IID_IDXGIObject;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIObject * This,
@ -488,7 +493,7 @@ EXTERN_C const IID IID_IDXGIDeviceSubObject;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIDeviceSubObject * This,
@ -626,7 +631,7 @@ EXTERN_C const IID IID_IDXGIResource;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIResource * This,
@ -788,7 +793,7 @@ EXTERN_C const IID IID_IDXGIKeyedMutex;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIKeyedMutex * This,
@ -953,7 +958,7 @@ EXTERN_C const IID IID_IDXGISurface;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGISurface * This,
@ -1110,7 +1115,7 @@ EXTERN_C const IID IID_IDXGISurface1;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGISurface1 * This,
@ -1300,7 +1305,7 @@ EXTERN_C const IID IID_IDXGIAdapter;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIAdapter * This,
@ -1506,7 +1511,7 @@ EXTERN_C const IID IID_IDXGIOutput;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIOutput * This,
@ -1684,6 +1689,7 @@ EXTERN_C const IID IID_IDXGIOutput;
#define DXGI_PRESENT_STEREO_TEMPORARY_MONO 0x00000020UL
#define DXGI_PRESENT_RESTRICT_TO_OUTPUT 0x00000040UL
#define DXGI_PRESENT_USE_DURATION 0x00000100UL
#define DXGI_PRESENT_ALLOW_TEARING 0x00000200UL
extern RPC_IF_HANDLE __MIDL_itf_dxgi_0000_0008_v0_0_c_ifspec;
@ -1787,7 +1793,7 @@ EXTERN_C const IID IID_IDXGISwapChain;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGISwapChain * This,
@ -2039,7 +2045,7 @@ EXTERN_C const IID IID_IDXGIFactory;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIFactory * This,
@ -2237,7 +2243,7 @@ EXTERN_C const IID IID_IDXGIDevice;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIDevice * This,
@ -2444,7 +2450,7 @@ EXTERN_C const IID IID_IDXGIFactory1;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIFactory1 * This,
@ -2624,7 +2630,7 @@ EXTERN_C const IID IID_IDXGIAdapter1;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIAdapter1 * This,
@ -2781,7 +2787,7 @@ EXTERN_C const IID IID_IDXGIDevice1;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIDevice1 * This,

View File

@ -3,7 +3,7 @@
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 8.00.0613 */
/* File created by MIDL compiler version 8.01.0622 */
/* @@MIDL_FILE_HEADING( ) */
@ -113,6 +113,9 @@ extern "C"{
/* interface __MIDL_itf_dxgi1_2_0000_0000 */
/* [local] */
#include <winapifamily.h>
// BK - pragma region Desktop Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
extern RPC_IF_HANDLE __MIDL_itf_dxgi1_2_0000_0000_v0_0_c_ifspec;
@ -357,7 +360,7 @@ EXTERN_C const IID IID_IDXGIOutputDuplication;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIOutputDuplication * This,
@ -503,6 +506,10 @@ EXTERN_C const IID IID_IDXGIOutputDuplication;
/* interface __MIDL_itf_dxgi1_2_0000_0002 */
/* [local] */
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// BK - pragma endregion
// BK - pragma region App Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
typedef
enum DXGI_ALPHA_MODE
{
@ -575,7 +582,7 @@ EXTERN_C const IID IID_IDXGISurface2;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGISurface2 * This,
@ -769,7 +776,7 @@ EXTERN_C const IID IID_IDXGIResource1;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIResource1 * This,
@ -984,7 +991,7 @@ EXTERN_C const IID IID_IDXGIDevice2;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIDevice2 * This,
@ -1202,7 +1209,8 @@ typedef struct DXGI_SWAP_CHAIN_FULLSCREEN_DESC
typedef struct DXGI_PRESENT_PARAMETERS
{
UINT DirtyRectsCount;
RECT *pDirtyRects;
/* [annotation] */
_Field_size_full_opt_(DirtyRectsCount) RECT *pDirtyRects;
RECT *pScrollRect;
POINT *pScrollOffset;
} DXGI_PRESENT_PARAMETERS;
@ -1307,7 +1315,7 @@ EXTERN_C const IID IID_IDXGISwapChain1;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGISwapChain1 * This,
@ -1692,7 +1700,7 @@ EXTERN_C const IID IID_IDXGIFactory2;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIFactory2 * This,
@ -2041,7 +2049,7 @@ EXTERN_C const IID IID_IDXGIAdapter2;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIAdapter2 * This,
@ -2226,7 +2234,7 @@ EXTERN_C const IID IID_IDXGIOutput1;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIOutput1 * This,
@ -2438,6 +2446,8 @@ EXTERN_C const IID IID_IDXGIOutput1;
/* interface __MIDL_itf_dxgi1_2_0000_0009 */
/* [local] */
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */
// BK - pragma endregion
DEFINE_GUID(IID_IDXGIDisplayControl,0xea9dbf1a,0xc88e,0x4486,0x85,0x4a,0x98,0xaa,0x01,0x38,0xf3,0x0c);
DEFINE_GUID(IID_IDXGIOutputDuplication,0x191cfac3,0xa341,0x470d,0xb2,0x6e,0xa8,0x64,0xf4,0x28,0x31,0x9c);
DEFINE_GUID(IID_IDXGISurface2,0xaba496dd,0xb617,0x4cb8,0xa8,0x66,0xbc,0x44,0xd7,0xeb,0x1f,0xa2);

View File

@ -3,7 +3,7 @@
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 8.00.0613 */
/* File created by MIDL compiler version 8.01.0622 */
/* @@MIDL_FILE_HEADING( ) */
@ -106,6 +106,9 @@ extern "C"{
/* interface __MIDL_itf_dxgi1_3_0000_0000 */
/* [local] */
#include <winapifamily.h>
// BK - pragma region App Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
#define DXGI_CREATE_FACTORY_DEBUG 0x1
HRESULT WINAPI CreateDXGIFactory2(UINT Flags, REFIID riid, _COM_Outptr_ void **ppFactory);
HRESULT WINAPI DXGIGetDebugInterface1(UINT Flags, REFIID riid, _COM_Outptr_ void **pDebug);
@ -165,7 +168,7 @@ EXTERN_C const IID IID_IDXGIDevice3;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIDevice3 * This,
@ -427,7 +430,7 @@ EXTERN_C const IID IID_IDXGISwapChain2;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGISwapChain2 * This,
@ -789,7 +792,7 @@ EXTERN_C const IID IID_IDXGIOutput2;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIOutput2 * This,
@ -1056,7 +1059,7 @@ EXTERN_C const IID IID_IDXGIFactory3;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIFactory3 * This,
@ -1318,6 +1321,10 @@ EXTERN_C const IID IID_IDXGIFactory3;
/* interface __MIDL_itf_dxgi1_3_0000_0004 */
/* [local] */
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */
// BK - pragma endregion
// BK - pragma region App Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
typedef struct DXGI_DECODE_SWAP_CHAIN_DESC
{
UINT Flags;
@ -1788,6 +1795,10 @@ enum DXGI_OVERLAY_SUPPORT_FLAG
DXGI_OVERLAY_SUPPORT_FLAG_SCALING = 0x2
} DXGI_OVERLAY_SUPPORT_FLAG;
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
// BK - pragma endregion
// BK - pragma region App Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
extern RPC_IF_HANDLE __MIDL_itf_dxgi1_3_0000_0007_v0_0_c_ifspec;
@ -1850,7 +1861,7 @@ EXTERN_C const IID IID_IDXGIOutput3;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIOutput3 * This,
@ -2082,6 +2093,8 @@ EXTERN_C const IID IID_IDXGIOutput3;
/* interface __MIDL_itf_dxgi1_3_0000_0008 */
/* [local] */
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */
// BK - pragma endregion
DEFINE_GUID(IID_IDXGIDevice3,0x6007896c,0x3244,0x4afd,0xbf,0x18,0xa6,0xd3,0xbe,0xda,0x50,0x23);
DEFINE_GUID(IID_IDXGISwapChain2,0xa8be2ac4,0x199f,0x4946,0xb3,0x31,0x79,0x59,0x9f,0xb9,0x8d,0xe7);
DEFINE_GUID(IID_IDXGIOutput2,0x595e39d1,0x2724,0x4663,0x99,0xb1,0xda,0x96,0x9d,0xe2,0x83,0x64);

View File

@ -3,7 +3,7 @@
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 8.00.0613 */
/* File created by MIDL compiler version 8.01.0622 */
/* @@MIDL_FILE_HEADING( ) */
@ -78,6 +78,9 @@ extern "C"{
/* interface __MIDL_itf_dxgi1_4_0000_0000 */
/* [local] */
#include <winapifamily.h>
// BK - pragma region App Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
typedef
enum DXGI_SWAP_CHAIN_COLOR_SPACE_SUPPORT_FLAG
{
@ -167,7 +170,7 @@ EXTERN_C const IID IID_IDXGISwapChain3;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGISwapChain3 * This,
@ -596,7 +599,7 @@ EXTERN_C const IID IID_IDXGIOutput4;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIOutput4 * This,
@ -903,7 +906,7 @@ EXTERN_C const IID IID_IDXGIFactory4;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIFactory4 * This,
@ -1293,7 +1296,7 @@ EXTERN_C const IID IID_IDXGIAdapter3;
/* [annotation][in] */
_In_ REFGUID Name,
/* [annotation][in] */
_In_ const IUnknown *pUnknown);
_In_opt_ const IUnknown *pUnknown);
HRESULT ( STDMETHODCALLTYPE *GetPrivateData )(
IDXGIAdapter3 * This,
@ -1467,6 +1470,8 @@ EXTERN_C const IID IID_IDXGIAdapter3;
/* interface __MIDL_itf_dxgi1_4_0000_0004 */
/* [local] */
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */
// BK - pragma endregion
DEFINE_GUID(IID_IDXGISwapChain3,0x94d99bdb,0xf1f8,0x4ab0,0xb2,0x36,0x7d,0xa0,0x17,0x0e,0xda,0xb1);
DEFINE_GUID(IID_IDXGIOutput4,0xdc7dca35,0x2196,0x414d,0x9F,0x53,0x61,0x78,0x84,0x03,0x2a,0x60);
DEFINE_GUID(IID_IDXGIFactory4,0x1bc6ea02,0xef36,0x464f,0xbf,0x0c,0x21,0xca,0x39,0xe5,0x16,0x8a);

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,51 @@
//
// 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_CUSTOM = 0xFFFFFFFF
} DXGI_COLOR_SPACE_TYPE;
#endif // __dxgicommon_h__

View File

@ -3,7 +3,7 @@
/* this ALWAYS GENERATED file contains the definitions for the interfaces */
/* File created by MIDL compiler version 8.00.0613 */
/* File created by MIDL compiler version 8.01.0622 */
/* @@MIDL_FILE_HEADING( ) */

View File

@ -4,6 +4,7 @@
#ifndef __dxgitype_h__
#define __dxgitype_h__
#include "dxgicommon.h"
#include "dxgiformat.h"
#define _FACDXGI 0x87a
@ -33,7 +34,8 @@
# define DXGI_ERROR_NOT_CURRENTLY_AVAILABLE MAKE_DXGI_HRESULT(34)
# define DXGI_ERROR_REMOTE_CLIENT_DISCONNECTED MAKE_DXGI_HRESULT(35)
# define DXGI_ERROR_REMOTE_OUTOFMEMORY MAKE_DXGI_HRESULT(36)
#endif // defined(__MINGW32__) || (_WIN32_WINNT < 0x0601)
#endif // for MINGW , winerror.h doesn't define DXGI error.
// DXGI error messages have moved to winerror.h
#define DXGI_CPU_ACCESS_NONE ( 0 )
#define DXGI_CPU_ACCESS_DYNAMIC ( 1 )
@ -78,12 +80,6 @@ typedef struct DXGI_GAMMA_CONTROL_CAPABILITIES
float ControlPointPositions[1025];
} DXGI_GAMMA_CONTROL_CAPABILITIES;
typedef struct DXGI_RATIONAL
{
UINT Numerator;
UINT Denominator;
} DXGI_RATIONAL;
typedef enum DXGI_MODE_SCANLINE_ORDER
{
DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED = 0,
@ -118,33 +114,6 @@ typedef struct DXGI_MODE_DESC
DXGI_MODE_SCALING Scaling;
} DXGI_MODE_DESC;
// 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_CUSTOM = 0xFFFFFFFF
} DXGI_COLOR_SPACE_TYPE;
typedef struct DXGI_JPEG_DC_HUFFMAN_TABLE
{
BYTE CodeCounts[12];

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

@ -35,16 +35,16 @@
#include <stdlib.h>
#include <string.h>
#ifndef toupper
#define toupper(c) ((c) + ('A' - 'a'))
#endif /* no toupper */
#ifndef tolower
#define tolower(c) ((c) + ('a' - 'A'))
#endif /* no tolower */
#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 TRUE
#define TRUE 1
#define FALSE 0
#ifndef FPP_TRUE
#define FPP_TRUE 1
#define FPP_FALSE 0
#endif
#ifndef EOS
/*
@ -52,7 +52,7 @@
*/
#define EOS '\0' /* End of string */
#endif
#define EOF_CHAR 0 /* Returned by get() on eof */
#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() */
@ -139,9 +139,9 @@
/*
* These bits are set in ifstack[]
*/
#define WAS_COMPILING 1 /* TRUE if compile set at entry */
#define ELSE_SEEN 2 /* TRUE when #else processed */
#define TRUE_SEEN 4 /* TRUE when #if TRUE processed */
#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

View File

@ -34,14 +34,15 @@ void __stdargs _XCEXIT(long a) { return; }
#endif
#endif
FILE_LOCAL ReturnCode output(struct Global *, int); /* Output one character */
FILE_LOCAL void sharp(struct Global *);
INLINE FILE_LOCAL ReturnCode cppmain(struct Global *);
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));
@ -55,17 +56,17 @@ int fppPreProcess(struct fppTag *tags)
global->wrongline=0;
global->errors=0;
global->recursion=0;
global->rec_recover=TRUE;
global->instring=FALSE;
global->inmacro=FALSE;
global->rec_recover=FPP_TRUE;
global->instring=FPP_FALSE;
global->inmacro=FPP_FALSE;
global->workp=NULL;
global->keepcomments = FALSE; /* Write out comments flag */
global->cflag = FALSE; /* -C option (keep comments) */
global->eflag = FALSE; /* -E option (never fail) */
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 = FALSE; /* -W option (write #defines) */
global->wflag = FPP_FALSE; /* -W option (write #defines) */
global->ifstack[0]=TRUE; /* #if information */
global->ifstack[0]=FPP_TRUE; /* #if information */
global->ifptr = global->ifstack;
global->incend = global->incdir;
@ -106,52 +107,59 @@ int fppPreProcess(struct fppTag *tags)
global->first_file=NULL;
global->userdata=NULL;
global->linelines=TRUE;
global->warnillegalcpp = FALSE;
global->outputLINE = TRUE;
global->warnnoinclude = TRUE;
global->showversion = TRUE;
global->showincluded = FALSE;
global->showspace = FALSE;
global->nestcomments = FALSE;
global->warnnestcomments = FALSE;
global->outputfile = TRUE;
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 = FALSE;
global->rightconcat = FALSE;
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=initdefines(global); /* O.S. specific def's */
ret=fpp_initdefines(global); /* O.S. specific def's */
if(ret)
return(ret);
dooptions(global, tags); /* Command line -flags */
ret=addfile(global, stdin, global->work); /* "open" main input file */
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=cppmain(global); /* Process main file */
ret=fpp_cppmain(global); /* Process main file */
if ((i = (global->ifptr - global->ifstack)) != 0) {
#if OLD_PREPROCESSOR
cwarn(global, ERROR_IFDEF_DEPTH, i);
fpp_cwarn(global, ERROR_IFDEF_DEPTH, i);
#else
cerror(global, ERROR_IFDEF_DEPTH, i);
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)
return(IO_ERROR);
return(IO_NORMAL); /* No errors or -E option set */
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 cppmain(struct Global *global)
ReturnCode fpp_cppmain(struct Global *global)
{
/*
* Main process for cpp -- copies tokens from the current input
@ -175,7 +183,7 @@ ReturnCode cppmain(struct Global *global)
char define = 0; /* probability of a function define phase in the program */
char prev = 0; /* previous type */
char go = 0;
char include = 0;
unsigned include = 0;
char initfunc = 0;
/* Initialize for reading tokens */
@ -196,7 +204,7 @@ ReturnCode cppmain(struct Global *global)
}
if(global->showversion)
Error(global, VERSION_TEXT);
fpp_Error(global, VERSION_TEXT);
/*
* Explicitly output a #line at the start of cpp output so
@ -205,10 +213,10 @@ ReturnCode cppmain(struct Global *global)
* the name of the first #include file instead.
*/
if(global->linelines) /* if #line lines are wanted! */
sharp(global);
fpp_sharp(global);
/*
* This loop is started "from the top" at the beginning of each line
* wrongline is set TRUE in many places if it is necessary to write
* 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
@ -224,15 +232,15 @@ ReturnCode cppmain(struct Global *global)
include = global->included;
while(include--) {
openinclude(global, global->include[(unsigned)include], TRUE);
fpp_openinclude(global, global->include[(unsigned)include], FPP_TRUE);
}
for (;;) {
counter = 0; /* Count empty lines */
for (;;) { /* For each line, ... */
global->comment = FALSE; /* No comment yet! */
global->comment = FPP_FALSE; /* No comment yet! */
global->chpos = 0; /* Count whitespaces */
while (type[(c = get(global))] == SPA) /* Skip leading blanks */
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! */
@ -241,14 +249,14 @@ ReturnCode cppmain(struct Global *global)
if (c == '\n') { /* If line's all blank, */
if(global->comment) {
/* A comment was output! */
Putchar(global, '\n');
fpp_Putchar(global, '\n');
}
else
++counter; /* Do nothing now */
}
else if (c == '#') { /* Is 1st non-space '#' */
global->keepcomments = FALSE; /* Don't pass comments */
ret = control(global, &counter); /* Yes, do a #command */
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);
@ -256,7 +264,7 @@ ReturnCode cppmain(struct Global *global)
else if (c == EOF_CHAR) /* At end of file? */
break;
else if (!compiling) { /* #ifdef false? */
skipnl(global); /* Skip to newline */
fpp_skipnl(global); /* Skip to newline */
counter++; /* Count it, too. */
} else {
break; /* Actual token */
@ -271,25 +279,25 @@ ReturnCode cppmain(struct Global *global)
*/
if(global->linelines) { /* if #line lines are wanted! */
if ((global->wrongline && global->infile->fp != NULL) || counter > 4)
sharp(global); /* Output # line number */
fpp_sharp(global); /* Output # line number */
else { /* If just a few, stuff */
while (--counter >= 0) /* them out ourselves */
Putchar(global, (int)'\n');
fpp_Putchar(global, (int)'\n');
}
}
if(global->showspace) {
/* Show all whitespaces! */
global->spacebuf[global->chpos] = '\0';
Putstring(global, global->spacebuf);
fpp_Putstring(global, global->spacebuf);
}
/*
* Process each token on this line.
*/
unget(global); /* Reread the char. */
fpp_unget(global); /* Reread the char. */
for (;;) { /* For the whole line, */
do { /* Token concat. loop */
for (global->chpos = counter = 0; type[(c = get(global))] == SPA;) {
for (global->chpos = counter = 0; (type[(c = fpp_get(global))] == SPA);) {
#if COMMENT_INVISIBLE
if (c != COM_SEP)
counter++;
@ -304,15 +312,15 @@ ReturnCode cppmain(struct Global *global)
break; /* Exit line loop */
else if (counter > 0) { /* If we got any spaces */
if(!global->showspace) /* We don't output all spaces */
Putchar(global, (int)' ');/* Output one space */
fpp_Putchar(global, (int)' ');/* Output one space */
else {
global->spacebuf[global->chpos] = '\0';
Putstring(global, global->spacebuf); /* Output all whitespaces */
fpp_Putstring(global, global->spacebuf); /* Output all whitespaces */
}
}
if((ret=macroid(global, &c))) /* Grab the token */
if((ret=fpp_macroid(global, &c))) /* Grab the token */
return(ret);
} while (type[c] == LET && catenate(global, &ret) && !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);
@ -323,7 +331,7 @@ ReturnCode cppmain(struct Global *global)
case LET:
go =0;
/* Quite ordinary token */
Putstring(global, global->tokenbuf);
fpp_Putstring(global, global->tokenbuf);
if(!define) {
/* Copy the name */
@ -335,7 +343,10 @@ ReturnCode cppmain(struct Global *global)
case DIG: /* Output a number */
case DOT: /* Dot may begin floats */
go = 0;
ret=scannumber(global, c, (ReturnCode(*)(struct Global *, int))output);
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;
@ -343,8 +354,8 @@ ReturnCode cppmain(struct Global *global)
go = 0;
/* Copy it to output */
if(!global->webmode) {
ret=scanstring(global, c,
(ReturnCode(*)(struct Global *, int))output);
ret=fpp_scanstring(global, c,
(ReturnCode(*)(struct Global *, int))fpp_output);
if(ret)
return(ret);
break;
@ -368,7 +379,7 @@ ReturnCode cppmain(struct Global *global)
/*
* Output the discovered function name to stderr!
*/
Error(global, "#> Function defined at line %d: %s <#\n",
fpp_Error(global, "#> Function defined at line %d: %s <#\n",
global->line,
global->functionname);
}
@ -382,9 +393,9 @@ ReturnCode cppmain(struct Global *global)
break;
}
if(a==global->excluded) {
expstuff(global, "__brace__", "{");
expstuff(global, "__init_func__", global->initialfunc);
initfunc = TRUE;
fpp_expstuff(global, "__brace__", "{");
fpp_expstuff(global, "__init_func__", global->initialfunc);
initfunc = FPP_TRUE;
}
}
@ -400,7 +411,7 @@ ReturnCode cppmain(struct Global *global)
define = 1;
if(initfunc) {
Putchar(global, '}');
fpp_Putchar(global, '}');
bracelevel--;
initfunc=0;
}
@ -462,57 +473,57 @@ ReturnCode cppmain(struct Global *global)
}
define--; /* decrease function probability */
Putchar(global, c); /* Just output it */
fpp_Putchar(global, c); /* Just output it */
break;
} /* Switch ends */
prev = type[c];
} /* Line for loop */
if (c == '\n') { /* Compiling at EOL? */
Putchar(global, '\n'); /* Output newline, if */
fpp_Putchar(global, '\n'); /* Output newline, if */
if (global->infile->fp == NULL) /* Expanding a macro, */
global->wrongline = TRUE; /* Output # line later */
global->wrongline = FPP_TRUE; /* Output # line later */
}
} /* Continue until EOF */
if(global->showbalance) {
if(bracketlevel) {
cwarn(global, WARN_BRACKET_DEPTH, bracketlevel);
fpp_cwarn(global, WARN_BRACKET_DEPTH, bracketlevel);
}
if(parenlevel) {
cwarn(global, WARN_PAREN_DEPTH, parenlevel);
fpp_cwarn(global, WARN_PAREN_DEPTH, parenlevel);
}
if(bracelevel) {
cwarn(global, WARN_BRACE_DEPTH, bracelevel);
fpp_cwarn(global, WARN_BRACE_DEPTH, bracelevel);
}
}
if (global->wflag) {
global->out = TRUE; /* enable output */
outdefines(global); /* Write out #defines */
global->out = FPP_TRUE; /* enable fpp_output */
fpp_outdefines(global); /* Write out #defines */
}
return(FPP_OK);
}
FILE_LOCAL
ReturnCode output(struct Global *global, int c)
ReturnCode fpp_output(struct Global *global, int c)
{
/*
* Output one character to stdout -- output() is passed as an
* argument to scanstring()
* 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
Putchar(global, c);
fpp_Putchar(global, c);
return(FPP_OK);
}
void Putchar(struct Global *global, int c)
void fpp_Putchar(struct Global *global, int c)
{
/*
* Output one character to stdout or to output function!
* Output one character to stdout or to fpp_output function!
*/
if(!global->out)
return;
@ -526,20 +537,20 @@ void Putchar(struct Global *global, int c)
#endif
}
void Putstring(struct Global *global, char *string)
void fpp_Putstring(struct Global *global, char *string)
{
/*
* Output a string! One letter at a time to the Putchar routine!
* Output a string! One letter at a time to the fpp_Putchar routine!
*/
if(!string)
return;
while(*string)
Putchar(global, *string++);
fpp_Putchar(global, *string++);
}
void Putint(struct Global *global, int number)
void fpp_Putint(struct Global *global, int number)
{
/*
* Output the number as a string.
@ -551,12 +562,12 @@ void Putint(struct Global *global, int number)
sprintf(buffer, "%d", number);
while(*point)
Putchar(global, *point++);
fpp_Putchar(global, *point++);
}
FILE_LOCAL
void sharp(struct Global *global)
void fpp_sharp(struct Global *global)
{
/*
* Output a line number line.
@ -564,14 +575,14 @@ void sharp(struct Global *global)
char *name;
if (global->keepcomments) /* Make sure # comes on */
Putchar(global, '\n'); /* a fresh, new line. */
fpp_Putchar(global, '\n'); /* a fresh, new line. */
/* printf("#%s %d", LINE_PREFIX, global->line); */
Putchar(global, '#');
fpp_Putchar(global, '#');
if(global->outputLINE)
Putstring(global, LINE_PREFIX);
Putchar(global, ' ');
Putint(global, global->line);
fpp_Putstring(global, LINE_PREFIX);
fpp_Putchar(global, ' ');
fpp_Putint(global, global->line);
if (global->infile->fp != NULL) {
name = (global->infile->progname != NULL)
@ -580,14 +591,14 @@ void sharp(struct Global *global)
|| (global->sharpfilename != NULL && !streq(name, global->sharpfilename))) {
if (global->sharpfilename != NULL)
free(global->sharpfilename);
global->sharpfilename = savestring(global, name);
global->sharpfilename = fpp_savestring(global, name);
/* printf(" \"%s\"", name); */
Putstring(global, " \"");
Putstring(global, name);
Putchar(global, '\"');
fpp_Putstring(global, " \"");
fpp_Putstring(global, name);
fpp_Putchar(global, '\"');
}
}
Putchar(global, '\n');
global->wrongline = FALSE;
fpp_Putchar(global, '\n');
global->wrongline = FPP_FALSE;
return;
}

View File

@ -28,10 +28,10 @@ SOFTWARE.
#include <proto/dos.h>
#endif
FILE_LOCAL void dump_line(struct Global *, int *);
FILE_LOCAL ReturnCode doif(struct Global *, int);
INLINE FILE_LOCAL ReturnCode doinclude(struct Global *);
INLINE FILE_LOCAL int hasdirectory(char *, char *);
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 *);
/*
@ -55,7 +55,7 @@ INLINE FILE_LOCAL int hasdirectory(char *, char *);
#define L_pragma ('p' + ('a' << 1))
#define L_undef ('u' + ('d' << 1))
ReturnCode control( struct Global *global,
ReturnCode fpp_control( struct Global *global,
int *counter ) /* Pending newline counter */
{
/*
@ -73,7 +73,7 @@ ReturnCode control( struct Global *global,
char *ep;
ReturnCode ret;
c = skipws( global );
c = fpp_skipws( global );
if( c == '\n' || c == EOF_CHAR )
{
@ -83,10 +83,10 @@ ReturnCode control( struct Global *global,
}
if( !isdigit(c) )
scanid( global, c ); /* Get #word to tokenbuf */
fpp_scanid( global, c ); /* Get #word to tokenbuf */
else
{
unget( global ); /* Hack -- allow #123 as a */
fpp_unget( global ); /* Hack -- allow #123 as a */
strcpy( global->tokenbuf, "line" ); /* synonym for #line 123 */
}
@ -149,7 +149,7 @@ ReturnCode control( struct Global *global,
* control keyword (or L_nogood if we think it's nonsense).
*/
if( global->infile->fp == NULL )
cwarn( global, WARN_CONTROL_LINE_IN_MACRO, global->tokenbuf );
fpp_cwarn( global, WARN_CONTROL_LINE_IN_MACRO, global->tokenbuf );
if( !compiling )
{ /* Not compiling now */
@ -160,7 +160,7 @@ ReturnCode control( struct Global *global,
case L_ifndef: /* we must nest #if's */
if( ++global->ifptr >= &global->ifstack[BLK_NEST] )
{
cfatal( global, FATAL_TOO_MANY_NESTINGS, global->tokenbuf );
fpp_cfatal( global, FATAL_TOO_MANY_NESTINGS, global->tokenbuf );
return( FPP_TOO_MANY_NESTED_STATEMENTS );
}
@ -177,7 +177,7 @@ ReturnCode control( struct Global *global,
case L_undef: /* aren't */
case L_assert: /* compiling. */
case L_error:
dump_line( global, counter ); /* Ignore rest of line */
fpp_dump_line( global, counter ); /* Ignore rest of line */
return(FPP_OK);
}
}
@ -186,7 +186,7 @@ ReturnCode control( struct Global *global,
*/
if( *counter > 0 && (hash == L_line || hash == L_pragma) )
{
Putchar( global, '\n' );
fpp_Putchar( global, '\n' );
(*counter)--;
}
@ -199,21 +199,21 @@ ReturnCode control( struct Global *global,
* field and line number for the next input line.
* Set wrongline to force it out later.
*/
c = skipws( global );
c = fpp_skipws( global );
global->workp = global->work; /* Save name in work */
while( c != '\n' && c != EOF_CHAR )
{
if( (ret = save( global, c )) )
if( (ret = fpp_save( global, c )) )
return(ret);
c = get( global );
c = fpp_get( global );
}
unget( global );
fpp_unget( global );
if( (ret = save( global, EOS )) )
if( (ret = fpp_save( global, EOS )) )
return(ret);
/*
@ -240,42 +240,42 @@ ReturnCode control( struct Global *global,
/* Give up the old name if it's allocated. */
free( global->infile->progname );
global->infile->progname = savestring( global, tp );
global->infile->progname = fpp_savestring( global, tp );
}
global->wrongline = TRUE; /* Force output later */
global->wrongline = FPP_TRUE; /* Force output later */
break;
case L_include:
ret = doinclude( global );
ret = fpp_doinclude( global );
if( ret )
return(ret);
break;
case L_define:
ret = dodefine( global );
ret = fpp_dodefine( global );
if( ret )
return(ret);
break;
case L_undef:
doundef( global );
fpp_doundef( global );
break;
case L_else:
if( global->ifptr == &global->ifstack[0] )
{
cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf );
fpp_cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf );
dump_line( global, counter );
fpp_dump_line( global, counter );
return( FPP_OK );
}
else if( (*global->ifptr & ELSE_SEEN) != 0 )
{
cerror( global, ERROR_STRING_MAY_NOT_FOLLOW_ELSE, global->tokenbuf );
fpp_cerror( global, ERROR_STRING_MAY_NOT_FOLLOW_ELSE, global->tokenbuf );
dump_line( global, counter );
fpp_dump_line( global, counter );
return( FPP_OK );
}
@ -284,11 +284,11 @@ ReturnCode control( struct Global *global,
if( (*global->ifptr & WAS_COMPILING) != 0 )
{
if( compiling || (*global->ifptr & TRUE_SEEN) != 0 )
compiling = FALSE;
if( compiling || (*global->ifptr & FPP_TRUE_SEEN) != 0 )
compiling = FPP_FALSE;
else
{
compiling = TRUE;
compiling = FPP_TRUE;
}
}
break;
@ -296,31 +296,31 @@ ReturnCode control( struct Global *global,
case L_elif:
if( global->ifptr == &global->ifstack[0] )
{
cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf );
fpp_cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf );
dump_line( global, counter );
fpp_dump_line( global, counter );
return( FPP_OK );
}
else if( (*global->ifptr & ELSE_SEEN) != 0 )
{
cerror( global, ERROR_STRING_MAY_NOT_FOLLOW_ELSE, global->tokenbuf );
fpp_cerror( global, ERROR_STRING_MAY_NOT_FOLLOW_ELSE, global->tokenbuf );
dump_line( global, counter );
fpp_dump_line( global, counter );
return( FPP_OK );
}
if( (*global->ifptr & (WAS_COMPILING | TRUE_SEEN)) != WAS_COMPILING )
if( (*global->ifptr & (WAS_COMPILING | FPP_TRUE_SEEN)) != WAS_COMPILING )
{
compiling = FALSE; /* Done compiling stuff */
compiling = FPP_FALSE; /* Done compiling stuff */
dump_line( global, counter ); /* Skip this clause */
fpp_dump_line( global, counter ); /* Skip this clause */
return( FPP_OK );
}
ret = doif( global, L_if );
ret = fpp_doif( global, L_if );
if( ret )
return(ret);
@ -328,7 +328,7 @@ ReturnCode control( struct Global *global,
break;
case L_error:
cerror(global, ERROR_ERROR);
fpp_cerror(global, ERROR_ERROR);
break;
case L_if:
@ -338,7 +338,7 @@ ReturnCode control( struct Global *global,
{
*global->ifptr = WAS_COMPILING;
ret = doif( global, hash );
ret = fpp_doif( global, hash );
if( ret )
return(ret);
@ -346,22 +346,22 @@ ReturnCode control( struct Global *global,
break;
}
cfatal( global, FATAL_TOO_MANY_NESTINGS, global->tokenbuf );
fpp_cfatal( global, FATAL_TOO_MANY_NESTINGS, global->tokenbuf );
return( FPP_TOO_MANY_NESTED_STATEMENTS );
case L_endif:
if( global->ifptr == &global->ifstack[0] )
{
cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf );
fpp_cerror( global, ERROR_STRING_MUST_BE_IF, global->tokenbuf );
dump_line( global, counter );
fpp_dump_line( global, counter );
return(FPP_OK);
}
if( !compiling && (*global->ifptr & WAS_COMPILING) != 0 )
global->wrongline = TRUE;
global->wrongline = FPP_TRUE;
compiling = ((*global->ifptr & WAS_COMPILING) != 0);
@ -373,13 +373,13 @@ ReturnCode control( struct Global *global,
{
int result;
ret = eval( global, &result );
ret = fpp_eval( global, &result );
if(ret)
return(ret);
if( result == 0 )
cerror( global, ERROR_PREPROC_FAILURE );
fpp_cerror( global, ERROR_PREPROC_FAILURE );
}
break;
@ -388,14 +388,14 @@ ReturnCode control( struct Global *global,
* #pragma is provided to pass "options" to later
* passes of the compiler. cpp doesn't have any yet.
*/
Putstring( global, "#pragma " );
fpp_Putstring( global, "#pragma " );
while( (c = get( global ) ) != '\n' && c != EOF_CHAR )
Putchar( global, c );
while( (c = fpp_get( global ) ) != '\n' && c != EOF_CHAR )
fpp_Putchar( global, c );
unget( global );
fpp_unget( global );
Putchar( global, '\n' );
fpp_Putchar( global, '\n' );
break;
@ -407,18 +407,18 @@ ReturnCode control( struct Global *global,
* This would allow #asm or similar extensions.
*/
if( global->warnillegalcpp )
cwarn( global, WARN_ILLEGAL_COMMAND, global->tokenbuf );
fpp_cwarn( global, WARN_ILLEGAL_COMMAND, global->tokenbuf );
Putchar( global, '#' );
Putstring( global, global->tokenbuf );
Putchar( global, ' ' );
fpp_Putchar( global, '#' );
fpp_Putstring( global, global->tokenbuf );
fpp_Putchar( global, ' ' );
while( (c = get( global ) ) != '\n' && c != EOF_CHAR )
Putchar( global, c );
while( (c = fpp_get( global ) ) != '\n' && c != EOF_CHAR )
fpp_Putchar( global, c );
unget( global );
fpp_unget( global );
Putchar( global, '\n' );
fpp_Putchar( global, '\n' );
break;
}
@ -431,15 +431,15 @@ ReturnCode control( struct Global *global,
* #if foo
* #endif foo
*/
dump_line( global, counter ); /* Take common exit */
fpp_dump_line( global, counter ); /* Take common exit */
return( FPP_OK );
#else
if( skipws( global ) != '\n' )
if( fpp_skipws( global ) != '\n' )
{
cwarn( global, WARN_UNEXPECTED_TEXT_IGNORED );
fpp_cwarn( global, WARN_UNEXPECTED_TEXT_IGNORED );
skipnl( global );
fpp_skipnl( global );
}
#endif
}
@ -450,21 +450,21 @@ ReturnCode control( struct Global *global,
}
FILE_LOCAL
void dump_line(struct Global *global, int *counter)
void fpp_dump_line(struct Global *global, int *counter)
{
skipnl( global ); /* Ignore rest of line */
fpp_skipnl( global ); /* Ignore rest of line */
(*counter)++;
}
FILE_LOCAL
ReturnCode doif(struct Global *global, int hash)
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.
*
* doif() is called only if compiling is TRUE. If false, compilation
* 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.
*/
@ -473,16 +473,16 @@ ReturnCode doif(struct Global *global, int hash)
int found;
ReturnCode ret;
if( (c = skipws( global ) ) == '\n' || c == EOF_CHAR )
if( (c = fpp_skipws( global ) ) == '\n' || c == EOF_CHAR )
{
unget( global );
fpp_unget( global );
cerror( global, ERROR_MISSING_ARGUMENT );
fpp_cerror( global, ERROR_MISSING_ARGUMENT );
#if !OLD_PREPROCESSOR
skipnl( global ); /* Prevent an extra */
fpp_skipnl( global ); /* Prevent an extra */
unget( global ); /* Error message */
fpp_unget( global ); /* Error message */
#endif
return(FPP_OK);
@ -490,14 +490,14 @@ ReturnCode doif(struct Global *global, int hash)
if( hash == L_if )
{
unget( global );
fpp_unget( global );
ret = eval( global, &found );
ret = fpp_eval( global, &found );
if( ret )
return( ret );
found = (found != 0); /* Evaluate expr, != 0 is TRUE */
found = (found != 0); /* Evaluate expr, != 0 is FPP_TRUE */
hash = L_ifdef; /* #if is now like #ifdef */
}
@ -506,34 +506,34 @@ ReturnCode doif(struct Global *global, int hash)
if( type[c] != LET )
{ /* Next non-blank isn't letter */
/* ... is an error */
cerror( global, ERROR_MISSING_ARGUMENT );
fpp_cerror( global, ERROR_MISSING_ARGUMENT );
#if !OLD_PREPROCESSOR
skipnl( global ); /* Prevent an extra */
fpp_skipnl( global ); /* Prevent an extra */
unget( global ); /* Error message */
fpp_unget( global ); /* Error message */
#endif
return(FPP_OK);
}
found = ( lookid( global, c ) != NULL ); /* Look for it in symbol table */
found = ( fpp_lookid( global, c ) != NULL ); /* Look for it in symbol table */
}
if( found == (hash == L_ifdef) )
{
compiling = TRUE;
compiling = FPP_TRUE;
*global->ifptr |= TRUE_SEEN;
*global->ifptr |= FPP_TRUE_SEEN;
}
else
compiling = FALSE;
compiling = FPP_FALSE;
return(FPP_OK);
}
INLINE FILE_LOCAL
ReturnCode doinclude( struct Global *global )
ReturnCode fpp_doinclude( struct Global *global )
{
/*
* Process the #include control line.
@ -557,14 +557,14 @@ ReturnCode doinclude( struct Global *global )
int delim;
ReturnCode ret;
delim = skipws( global );
delim = fpp_skipws( global );
if( (ret = macroid( global, &delim )) )
if( (ret = fpp_macroid( global, &delim )) )
return(ret);
if( delim != '<' && delim != '"' )
{
cerror( global, ERROR_INCLUDE_SYNTAX );
fpp_cerror( global, ERROR_INCLUDE_SYNTAX );
return( FPP_OK );
}
@ -574,11 +574,11 @@ ReturnCode doinclude( struct Global *global )
global->workp = global->work;
while( (c = get(global)) != '\n' && c != EOF_CHAR )
if( (ret = save( global, c )) ) /* Put it away. */
while( (c = fpp_get(global)) != '\n' && c != EOF_CHAR )
if( (ret = fpp_save( global, c )) ) /* Put it away. */
return( ret );
unget( global ); /* Force nl after include */
fpp_unget( global ); /* Force nl after include */
/*
* The draft is unclear if the following should be done.
@ -589,21 +589,21 @@ ReturnCode doinclude( struct Global *global )
if( *global->workp != delim )
{
cerror( global, ERROR_INCLUDE_SYNTAX );
fpp_cerror( global, ERROR_INCLUDE_SYNTAX );
return(FPP_OK);
}
*global->workp = EOS; /* Terminate filename */
ret = openinclude( global, global->work, (delim == '"') );
ret = fpp_openinclude( global, global->work, (delim == '"') );
if( ret && global->warnnoinclude )
{
/*
* Warn if #include file isn't there.
*/
cwarn( global, WARN_CANNOT_OPEN_INCLUDE, global->work );
fpp_cwarn( global, WARN_CANNOT_OPEN_INCLUDE, global->work );
}
return( FPP_OK );
@ -613,13 +613,13 @@ ReturnCode doinclude( struct Global *global )
ReturnCode MultiAssignLoad( struct Global *global, char *incptr, char *filename, char *tmpname );
#endif
ReturnCode openinclude( struct Global *global,
ReturnCode fpp_openinclude( struct Global *global,
char *filename, /* Input file name */
int searchlocal ) /* TRUE if #include "file" */
int searchlocal ) /* FPP_TRUE if #include "file" */
{
/*
* Actually open an include file. This routine is only called from
* doinclude() above, but was written as a separate subroutine for
* 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.
@ -631,11 +631,11 @@ ReturnCode openinclude( struct Global *global,
if( filename[0] == '/' )
{
if( ! openfile( global, filename ) )
if( ! fpp_openfile( global, filename ) )
return(FPP_OK);
}
if( searchlocal )
if( searchlocal && global->allowincludelocal )
{
/*
* Look in local directory first.
@ -645,12 +645,12 @@ ReturnCode openinclude( struct Global *global,
* discarding the last pathname component of the source file
* name then tacking on the #include argument.
*/
if( hasdirectory( global->infile->filename, tmpname ) )
if( fpp_hasdirectory( global->infile->filename, tmpname ) )
strcat( tmpname, filename );
else
strcpy( tmpname, filename );
if( ! openfile( global, tmpname ) )
if( ! fpp_openfile( global, tmpname ) )
return(FPP_OK);
}
@ -664,7 +664,7 @@ ReturnCode openinclude( struct Global *global,
if( len + strlen(filename) >= sizeof(tmpname) )
{
cfatal( global, FATAL_FILENAME_BUFFER_OVERFLOW );
fpp_cfatal( global, FATAL_FILENAME_BUFFER_OVERFLOW );
return( FPP_FILENAME_BUFFER_OVERFLOW );
}
@ -675,7 +675,7 @@ ReturnCode openinclude( struct Global *global,
else
sprintf( tmpname, "%s%s", *incptr, filename );
if( !openfile( global, tmpname ) )
if( !fpp_openfile( global, tmpname ) )
return(FPP_OK);
}
}
@ -684,25 +684,25 @@ ReturnCode openinclude( struct Global *global,
}
INLINE FILE_LOCAL
int hasdirectory( char *source, /* Directory to examine */
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
* hasdirectory returns TRUE. Else, nothing is copied and it returns FALSE.
* fpp_hasdirectory returns FPP_TRUE. Else, nothing is copied and it returns FPP_FALSE.
*/
char *tp2;
if( (tp2 = strrchr( source, '/' ) ) == NULL )
return(FALSE);
return(FPP_FALSE);
strncpy( result, source, tp2 - source + 1 );
result[tp2 - source + 1] = EOS;
return( TRUE );
return( FPP_TRUE );
}
#ifdef _AMIGA
@ -742,7 +742,7 @@ ReturnCode MultiAssignLoad( struct Global *global, char *incptr, char *filename,
// 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 openfile() function, we
// satisfy the exisiting fpp_openfile() function, we
// bite the bullet and build the complete pathspec
// rather than add the standard Load() routine.
//
@ -750,7 +750,7 @@ ReturnCode MultiAssignLoad( struct Global *global, char *incptr, char *filename,
{
AddPart( tmpname, filename, NWORK );
RtnCode = openfile( global, tmpname );
RtnCode = fpp_openfile( global, tmpname );
if( ! RtnCode )
break;

View File

@ -25,20 +25,25 @@ SOFTWARE.
#include "cppdef.h"
#include "cpp.h"
ReturnCode openfile(struct Global *global, char *filename)
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 openfile() in cpp2.c.
* This is called only from fpp_openfile() in cpp2.c.
*/
FILE *fp;
ReturnCode ret;
if ((fp = fopen(filename, "r")) == NULL)
if (global->openfile)
fp = global->openfile(filename, "r", global->userdata);
else
fp = fopen(filename, "r");
if (fp == NULL)
ret=FPP_OPEN_ERROR;
else
ret=addfile(global, fp, filename);
ret=fpp_addfile(global, fp, filename);
if(!ret && global->depends) {
global->depends(filename, global->userdata);
@ -46,51 +51,51 @@ ReturnCode openfile(struct Global *global, char *filename)
if(!ret && global->showincluded) {
/* no error occured! */
Error(global, "cpp: included \"");
Error(global, filename);
Error(global, "\"\n");
fpp_Error(global, "cpp: included \"");
fpp_Error(global, filename);
fpp_Error(global, "\"\n");
}
return(ret);
}
ReturnCode addfile(struct Global *global,
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 openfile()
* 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, getfile() to build the FILEINFO
* structure which is used to read characters. (getfile() is also called
* 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 = getfile(global, NBUFF, filename, &file);
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 = TRUE; /* Force out initial #line */
global->wrongline = FPP_TRUE; /* Force out initial #line */
return(FPP_OK);
}
int dooptions(struct Global *global, struct fppTag *tags)
int fpp_dooptions(struct Global *global, struct fppTag *tags)
{
/*
* dooptions is called to process command line arguments (-Detc).
* fpp_dooptions is called to process command line arguments (-Detc).
* It is called only at cpp startup.
*/
DEFBUF *dp;
char end=FALSE; /* end of taglist */
char end=FPP_FALSE; /* end of taglist */
while(tags && !end) {
switch(tags->tag) {
case FPPTAG_END:
end=TRUE;
end=FPP_TRUE;
break;
case FPPTAG_INITFUNC:
global->initialfunc = (char *) tags->data;
@ -122,7 +127,7 @@ int dooptions(struct Global *global, struct fppTag *tags)
case FPPTAG_OUTPUTINCLUDES:
global->showincluded = tags->data?1:0;
break;
case FPPTAG_IGNOREVERSION:
case FPPTAG_SHOWVERSION:
global->showversion = tags->data?1:0;
break;
case FPPTAG_WARNILLEGALCPP:
@ -133,8 +138,8 @@ int dooptions(struct Global *global, struct fppTag *tags)
break;
case FPPTAG_KEEPCOMMENTS:
if(tags->data) {
global->cflag = TRUE;
global->keepcomments = TRUE;
global->cflag = FPP_TRUE;
global->keepcomments = FPP_TRUE;
}
break;
case FPPTAG_DEFINE:
@ -153,19 +158,19 @@ int dooptions(struct Global *global, struct fppTag *tags)
/*
* Now, save the word and its definition.
*/
dp = defendel(global, symbol, FALSE);
dp = fpp_defendel(global, symbol, FPP_FALSE);
if(!dp)
return(FPP_OUT_OF_MEMORY);
dp->repl = savestring(global, text);
dp->repl = fpp_savestring(global, text);
dp->nargs = DEF_NOARGS;
}
break;
case FPPTAG_IGNORE_NONFATAL:
global->eflag = TRUE;
global->eflag = FPP_TRUE;
break;
case FPPTAG_INCLUDE_DIR:
if (global->incend >= &global->incdir[NINCLUDE]) {
cfatal(global, FATAL_TOO_MANY_INCLUDE_DIRS);
fpp_cfatal(global, FATAL_TOO_MANY_INCLUDE_DIRS);
return(FPP_TOO_MANY_INCLUDE_DIRS);
}
*global->incend++ = (char *)tags->data;
@ -173,7 +178,7 @@ int dooptions(struct Global *global, struct fppTag *tags)
case FPPTAG_INCLUDE_FILE:
case FPPTAG_INCLUDE_MACRO_FILE:
if (global->included >= NINCLUDE) {
cfatal(global, FATAL_TOO_MANY_INCLUDE_FILES);
fpp_cfatal(global, FATAL_TOO_MANY_INCLUDE_FILES);
return(FPP_TOO_MANY_INCLUDE_FILES);
}
global->include[(unsigned)global->included] = (char *)tags->data;
@ -196,7 +201,7 @@ int dooptions(struct Global *global, struct fppTag *tags)
{
SIZES *sizp; /* For -S */
int size; /* For -S */
int isdatum; /* FALSE for -S* */
int isdatum; /* FPP_FALSE for -S* */
int endtest; /* For -S */
char *text=(char *)tags->data;
@ -225,14 +230,14 @@ int dooptions(struct Global *global, struct fppTag *tags)
sizp++;
}
if (sizp->bits != endtest)
cwarn(global, WARN_TOO_FEW_VALUES_TO_SIZEOF, NULL);
fpp_cwarn(global, WARN_TOO_FEW_VALUES_TO_SIZEOF, NULL);
else if (*text != EOS)
cwarn(global, WARN_TOO_MANY_VALUES_TO_SIZEOF, NULL);
fpp_cwarn(global, WARN_TOO_MANY_VALUES_TO_SIZEOF, NULL);
}
break;
case FPPTAG_UNDEFINE:
if (defendel(global, (char *)tags->data, TRUE) == NULL)
cwarn(global, WARN_NOT_DEFINED, tags->data);
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++;
@ -265,8 +270,14 @@ int dooptions(struct Global *global, struct fppTag *tags)
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 *))tags->data;
break;
default:
cwarn(global, WARN_INTERNAL_ERROR, NULL);
fpp_cwarn(global, WARN_INTERNAL_ERROR, NULL);
break;
}
tags++;
@ -274,7 +285,7 @@ int dooptions(struct Global *global, struct fppTag *tags)
return(0);
}
ReturnCode initdefines(struct Global *global)
ReturnCode fpp_initdefines(struct Global *global)
{
/*
* Initialize the built-in #define's. There are two flavors:
@ -307,23 +318,23 @@ ReturnCode initdefines(struct Global *global)
if (!(global->nflag & NFLAG_BUILTIN)) {
for (pp = global->preset; *pp != NULL; pp++) {
if (*pp[0] != EOS) {
dp = defendel(global, *pp, FALSE);
dp = fpp_defendel(global, *pp, FPP_FALSE);
if(!dp)
return(FPP_OUT_OF_MEMORY);
dp->repl = savestring(global, "1");
dp->repl = fpp_savestring(global, "1");
dp->nargs = DEF_NOARGS;
}
}
}
/*
* The magic pre-defines (__FILE__ and __LINE__ are
* initialized with negative argument counts. expand()
* 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 = defendel(global, *pp, FALSE);
dp = fpp_defendel(global, *pp, FPP_FALSE);
if(!dp)
return(FPP_OUT_OF_MEMORY);
dp->nargs = --i;
@ -332,7 +343,7 @@ ReturnCode initdefines(struct Global *global)
/*
* Define __DATE__ as today's date.
*/
dp = defendel(global, "__DATE__", FALSE);
dp = fpp_defendel(global, "__DATE__", FPP_FALSE);
tp = malloc(14);
if(!tp || !dp)
return(FPP_OUT_OF_MEMORY);
@ -348,7 +359,7 @@ ReturnCode initdefines(struct Global *global)
/*
* Define __TIME__ as this moment's time.
*/
dp = defendel(global, "__TIME__", FALSE);
dp = fpp_defendel(global, "__TIME__", FPP_FALSE);
tp = malloc(11);
if(!tp || !dp)
return(FPP_OUT_OF_MEMORY);
@ -363,7 +374,7 @@ ReturnCode initdefines(struct Global *global)
return(FPP_OK);
}
void deldefines(struct Global *global)
void fpp_delbuiltindefines(struct Global *global)
{
/*
* Delete the built-in #define's.
@ -376,25 +387,25 @@ void deldefines(struct Global *global)
*/
if (global->wflag < 2) {
for (pp = global->preset; *pp != NULL; pp++) {
defendel(global, *pp, TRUE);
fpp_defendel(global, *pp, FPP_TRUE);
}
}
/*
* The magic pre-defines __FILE__ and __LINE__
*/
for (pp = global->magic; *pp != NULL; pp++) {
defendel(global, *pp, TRUE);
fpp_defendel(global, *pp, FPP_TRUE);
}
#if OK_DATE
/*
* Undefine __DATE__.
*/
defendel(global, "__DATE__", TRUE);
fpp_defendel(global, "__DATE__", FPP_TRUE);
/*
* Undefine __TIME__.
*/
defendel(global, "__TIME__", TRUE);
fpp_defendel(global, "__TIME__", FPP_TRUE);
#endif
return;
}

View File

@ -24,15 +24,15 @@ SOFTWARE.
#include "cppdef.h"
#include "cpp.h"
INLINE FILE_LOCAL ReturnCode checkparm(struct Global *, int, DEFBUF *, int);
INLINE FILE_LOCAL ReturnCode stparmscan(struct Global *, int);
INLINE FILE_LOCAL ReturnCode textput(struct Global *, char *);
FILE_LOCAL ReturnCode charput(struct Global *, int);
INLINE FILE_LOCAL ReturnCode expcollect(struct Global *);
INLINE FILE_LOCAL char *doquoting(char *, char *);
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 dodefine(struct Global *global)
ReturnCode fpp_dodefine(struct Global *global)
{
/*
* Called from control when a #define is scanned. This module
@ -61,63 +61,63 @@ ReturnCode dodefine(struct Global *global)
* is not.
*
* The following subroutines are called from define():
* checkparm called when a token is scanned. It checks through the
* 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.
* textput puts a string in the macro work area (parm[]), updating
* fpp_textput puts a string in the macro work area (parm[]), updating
* parmp to point to the first free byte in parm[].
* textput() tests for work buffer overflow.
* charput puts a single character in the macro work area (parm[])
* in a manner analogous to textput().
* 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; /* TRUE if redefined */
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 = skipws(global))] != LET) {
cerror(global, ERROR_DEFINE_SYNTAX);
global->inmacro = FALSE; /* Stop <newline> hack */
if (type[(c = fpp_skipws(global))] != LET) {
fpp_cerror(global, ERROR_DEFINE_SYNTAX);
global->inmacro = FPP_FALSE; /* Stop <newline> hack */
return(FPP_OK);
}
isredefine = FALSE; /* Set if redefining */
if ((dp = lookid(global, c)) == NULL) { /* If not known now */
dp = defendel(global, global->tokenbuf, FALSE); /* Save the name */
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 = TRUE; /* Remember this fact */
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 = get(global)) == '(') { /* With arguments? */
if ((c = fpp_get(global)) == '(') { /* With arguments? */
global->nargs = 0; /* Init formals counter */
do { /* Collect formal parms */
if (global->nargs >= LASTPARM) {
cfatal(global, FATAL_TOO_MANY_ARGUMENTS_MACRO);
fpp_cfatal(global, FATAL_TOO_MANY_ARGUMENTS_MACRO);
return(FPP_TOO_MANY_ARGUMENTS);
} else if ((c = skipws(global)) == ')')
} else if ((c = fpp_skipws(global)) == ')')
break; /* Got them all */
else if (type[c] != LET) { /* Bad formal syntax */
cerror(global, ERROR_DEFINE_SYNTAX);
global->inmacro = FALSE; /* Stop <newline> hack */
fpp_cerror(global, ERROR_DEFINE_SYNTAX);
global->inmacro = FPP_FALSE; /* Stop <newline> hack */
return(FPP_OK);
}
scanid(global, c); /* Get the formal param */
fpp_scanid(global, c); /* Get the formal param */
global->parlist[global->nargs++] = global->parmp; /* Save its start */
ret=textput(global, global->tokenbuf); /* Save text in parm[] */
ret=fpp_textput(global, global->tokenbuf); /* Save text in parm[] */
if(ret)
return(ret);
} while ((c = skipws(global)) == ','); /* Get another argument */
} while ((c = fpp_skipws(global)) == ','); /* Get another argument */
if (c != ')') { /* Must end at ) */
cerror(global, ERROR_DEFINE_SYNTAX);
global->inmacro = FALSE; /* Stop <newline> hack */
fpp_cerror(global, ERROR_DEFINE_SYNTAX);
global->inmacro = FPP_FALSE; /* Stop <newline> hack */
return(FPP_OK);
}
c = ' '; /* Will skip to body */
@ -130,14 +130,14 @@ ReturnCode dodefine(struct Global *global)
global->nargs = DEF_NOARGS; /* No () parameters */
}
if (type[c] == SPA) /* At whitespace? */
c = skipws(global); /* Not any more. */
c = fpp_skipws(global); /* Not any more. */
global->workp = global->work; /* Replacement put here */
global->inmacro = TRUE; /* Keep \<newline> now */
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 = get(global)) != '#') { /* No, not really */
if ((c = fpp_get(global)) != '#') { /* No, not really */
quoting = 1; /* Maybe quoting op. */
continue;
}
@ -145,16 +145,16 @@ ReturnCode dodefine(struct Global *global)
--global->workp; /* Erase leading spaces */
// if ((ret=save(global, TOK_SEP))) /* Stuff a delimiter */
// return(ret);
c = skipws(global); /* Eat whitespace */
c = fpp_skipws(global); /* Eat whitespace */
continue;
}
#endif
switch (type[c]) {
case LET:
#if OK_CONCAT
ret=checkparm(global, c, dp, quoting); /* Might be a formal */
ret=fpp_checkparm(global, c, dp, quoting); /* Might be a formal */
#else
ret=checkparm(c, dp); /* Might be a formal */
ret=fpp_checkparm(c, dp); /* Might be a formal */
#endif
if(ret)
return(ret);
@ -162,24 +162,24 @@ ReturnCode dodefine(struct Global *global)
case DIG: /* Number in mac. body */
case DOT: /* Maybe a float number */
ret=scannumber(global, c, save); /* Scan it off */
ret=fpp_scannumber(global, c, fpp_save); /* Scan it off */
if(ret)
return(ret);
break;
case QUO: /* String in mac. body */
ret=stparmscan(global, c);
ret=fpp_stparmscan(global, c);
if(ret)
return(ret);
break;
case BSH: /* Backslash */
ret=save(global, '\\');
ret=fpp_save(global, '\\');
if(ret)
return(ret);
if ((c = get(global)) == '\n')
global->wrongline = TRUE;
ret=save(global, c);
if ((c = fpp_get(global)) == '\n')
global->wrongline = FPP_TRUE;
ret=fpp_save(global, c);
if(ret)
return(ret);
break;
@ -195,27 +195,27 @@ ReturnCode dodefine(struct Global *global)
c = ' '; /* Normalize tabs */
/* Fall through to store character */
default: /* Other character */
ret=save(global, c);
ret=fpp_save(global, c);
if(ret)
return(ret);
break;
}
c = get(global);
c = fpp_get(global);
quoting = 0; /* Only when immediately*/
/* preceding a formal */
}
global->inmacro = FALSE; /* Stop newline hack */
unget(global); /* For control check */
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 = savestring(global, global->work); /* Save the string */
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)) {
cerror(global, ERROR_REDEFINE, dp->name);
fpp_cerror(global, ERROR_REDEFINE, dp->name);
}
if (old != NULL) /* We don't need the */
free(old); /* old definition now. */
@ -224,7 +224,7 @@ ReturnCode dodefine(struct Global *global)
}
INLINE FILE_LOCAL
ReturnCode checkparm(struct Global *global,
ReturnCode fpp_checkparm(struct Global *global,
int c,
DEFBUF *dp,
int quoting) /* Preceded by a # ? */
@ -233,7 +233,7 @@ ReturnCode checkparm(struct Global *global,
* 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 output routine. This prevents the macro expander from
* the fpp_output routine. This prevents the macro expander from
* looping if someone writes "#define foo foo".
*/
@ -241,29 +241,29 @@ ReturnCode checkparm(struct Global *global,
char *cp;
ReturnCode ret=FPP_OK;
scanid(global, c); /* Get parm to tokenbuf */
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=save(global, QUOTE_PARM); /* #formal inside defn */
ret=fpp_save(global, QUOTE_PARM); /* #formal inside defn */
if(ret)
return(ret);
}
#endif
ret=save(global, i + MAC_PARM); /* Save a magic cookie */
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=save(global, DEF_MAGIC); /* Save magic marker */
for (cp = global->tokenbuf; *cp != EOS;) /* And save */
ret=save(global, *cp++); /* The token itself */
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 stparmscan(struct Global *global, int delim)
ReturnCode fpp_stparmscan(struct Global *global, int delim)
{
/*
* Normal string parameter scan.
@ -274,9 +274,9 @@ ReturnCode stparmscan(struct Global *global, int delim)
ReturnCode ret;
wp = (unsigned char *)global->workp; /* Here's where it starts */
ret=scanstring(global, delim, save);
ret=fpp_scanstring(global, delim, fpp_save);
if(ret)
return(ret); /* Exit on scanstring error */
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++) {
@ -292,23 +292,23 @@ ReturnCode stparmscan(struct Global *global, int delim)
return(FPP_OK);
}
void doundef(struct Global *global)
void fpp_doundef(struct Global *global)
/*
* Remove the symbol from the defined list.
* Called from the #control processor.
*/
{
int c;
if (type[(c = skipws(global))] != LET)
cerror(global, ERROR_ILLEGAL_UNDEF);
if (type[(c = fpp_skipws(global))] != LET)
fpp_cerror(global, ERROR_ILLEGAL_UNDEF);
else {
scanid(global, c); /* Get name to tokenbuf */
(void) defendel(global, global->tokenbuf, TRUE);
fpp_scanid(global, c); /* Get name to tokenbuf */
(void) fpp_defendel(global, global->tokenbuf, FPP_TRUE);
}
}
INLINE FILE_LOCAL
ReturnCode textput(struct Global *global, char *text)
ReturnCode fpp_textput(struct Global *global, char *text)
{
/*
* Put the string in the parm[] buffer.
@ -318,7 +318,7 @@ ReturnCode textput(struct Global *global, char *text)
size = strlen(text) + 1;
if ((global->parmp + size) >= &global->parm[NPARMWORK]) {
cfatal(global, FATAL_MACRO_AREA_OVERFLOW);
fpp_cfatal(global, FATAL_MACRO_AREA_OVERFLOW);
return(FPP_WORK_AREA_OVERFLOW);
} else {
strcpy(global->parmp, text);
@ -328,14 +328,14 @@ ReturnCode textput(struct Global *global, char *text)
}
FILE_LOCAL
ReturnCode charput(struct Global *global, int c)
ReturnCode fpp_charput(struct Global *global, int c)
{
/*
* Put the byte in the parm[] buffer.
*/
if (global->parmp >= &global->parm[NPARMWORK]) {
cfatal(global, FATAL_MACRO_AREA_OVERFLOW);
fpp_cfatal(global, FATAL_MACRO_AREA_OVERFLOW);
return(FPP_WORK_AREA_OVERFLOW);
}
*global->parmp++ = c;
@ -346,15 +346,15 @@ ReturnCode charput(struct Global *global, int c)
* M a c r o E x p a n s i o n
*/
ReturnCode expand(struct Global *global, DEFBUF *tokenp)
ReturnCode fpp_expand(struct Global *global, DEFBUF *tokenp)
{
/*
* Expand a macro. Called from the cpp mainline routine (via subroutine
* macroid()) when a token is found in the symbol table. It calls
* expcollect() to parse actual parameters, checking for the correct number.
* 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 get() routine runs
* "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;
@ -368,12 +368,12 @@ ReturnCode expand(struct Global *global, DEFBUF *tokenp)
if (global->recursion++ == 0)
global->macro = tokenp;
else if (global->recursion == RECURSION_LIMIT) {
cerror(global, ERROR_RECURSIVE_MACRO, tokenp->name, global->macro->name);
fpp_cerror(global, ERROR_RECURSIVE_MACRO, tokenp->name, global->macro->name);
if (global->rec_recover) {
do {
c = get(global);
c = fpp_get(global);
} while (global->infile != NULL && global->infile->fp == NULL);
unget(global);
fpp_unget(global);
global->recursion = 0;
return(FPP_OK);
}
@ -396,7 +396,7 @@ ReturnCode expand(struct Global *global, DEFBUF *tokenp)
break;
}
}
ret=ungetstring(global, global->work);
ret=fpp_ungetstring(global, global->work);
if(ret)
return(ret);
break;
@ -406,7 +406,7 @@ ReturnCode expand(struct Global *global, DEFBUF *tokenp)
if (file->fp != NULL) {
sprintf(global->work, "\"%s\"", (file->progname != NULL)
? file->progname : file->filename);
ret=ungetstring(global, global->work);
ret=fpp_ungetstring(global, global->work);
if(ret)
return(ret);
break;
@ -417,14 +417,14 @@ ReturnCode expand(struct Global *global, DEFBUF *tokenp)
case (-4): /* __FUNC__ */
sprintf(global->work, "\"%s\"", global->functionname[0]?
global->functionname : "<unknown function>");
ret=ungetstring(global, global->work);
ret=fpp_ungetstring(global, global->work);
if(ret)
return(ret);
break;
case (-5): /* __FUNC_LINE__ */
sprintf(global->work, "%d", global->funcline);
ret=ungetstring(global, global->work);
ret=fpp_ungetstring(global, global->work);
if(ret)
return(ret);
break;
@ -434,11 +434,11 @@ ReturnCode expand(struct Global *global, DEFBUF *tokenp)
* Nothing funny about this macro.
*/
if (tokenp->nargs < 0) {
cfatal(global, FATAL_ILLEGAL_MACRO, tokenp->name);
fpp_cfatal(global, FATAL_ILLEGAL_MACRO, tokenp->name);
return(FPP_ILLEGAL_MACRO);
}
while ((c = skipws(global)) == '\n') /* Look for (, skipping */
global->wrongline = TRUE; /* spaces and newlines */
while ((c = fpp_skipws(global)) == '\n') /* Look for (, skipping */
global->wrongline = FPP_TRUE; /* spaces and newlines */
if (c != '(') {
/*
* If the programmer writes
@ -447,27 +447,27 @@ ReturnCode expand(struct Global *global, DEFBUF *tokenp)
* foo [no ()]
* just write foo to the output stream.
*/
unget(global);
cwarn(global, WARN_MACRO_NEEDS_ARGUMENTS, tokenp->name);
fpp_unget(global);
fpp_cwarn(global, WARN_MACRO_NEEDS_ARGUMENTS, tokenp->name);
/* fputs(tokenp->name, stdout); */
Putstring(global, tokenp->name);
fpp_Putstring(global, tokenp->name);
return(FPP_OK);
} else if (!(ret=expcollect(global))) { /* Collect arguments */
} else if (!(ret=fpp_expcollect(global))) { /* Collect arguments */
if (tokenp->nargs != global->nargs) { /* Should be an error? */
cwarn(global, WARN_WRONG_NUMBER_ARGUMENTS, tokenp->name);
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=expstuff(global, tokenp->name, tokenp->repl); /* expand macro */
ret=fpp_expstuff(global, tokenp->name, tokenp->repl); /* expand macro */
} /* nargs switch */
return(ret);
}
INLINE FILE_LOCAL
ReturnCode expcollect(struct Global *global)
ReturnCode fpp_expcollect(struct Global *global)
{
/*
* Collect the actual parameters for this macro.
@ -479,8 +479,8 @@ ReturnCode expcollect(struct Global *global)
for (;;) {
paren = 0; /* Collect next arg. */
while ((c = skipws(global)) == '\n')/* Skip over whitespace */
global->wrongline = TRUE; /* and newlines. */
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[]
@ -490,22 +490,22 @@ ReturnCode expcollect(struct Global *global)
break; /* Exit collection loop */
}
else if (global->nargs >= LASTPARM) {
cfatal(global, FATAL_TOO_MANY_ARGUMENTS_EXPANSION);
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 = cget(global)) { /* Collect arg's bytes */
for (;; c = fpp_cget(global)) { /* Collect arg's bytes */
if (c == EOF_CHAR) {
cerror(global, ERROR_EOF_IN_ARGUMENT);
fpp_cerror(global, ERROR_EOF_IN_ARGUMENT);
return(FPP_EOF_IN_MACRO); /* Sorry. */
}
else if (c == '\\') { /* Quote next character */
charput(global, c); /* Save the \ for later */
charput(global, cget(global)); /* Save the next char. */
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=scanstring(global, c, (ReturnCode (*)(struct Global *, int))charput); /* Scan it off */
ret=fpp_scanstring(global, c, (ReturnCode (*)(struct Global *, int))fpp_charput); /* Scan it off */
if(ret)
return(ret);
continue; /* Go get next char */
@ -514,7 +514,7 @@ ReturnCode expcollect(struct Global *global)
paren++; /* To know about commas */
else if (c == ')') { /* Other side too */
if (paren == 0) { /* At the end? */
unget(global); /* Look at it later */
fpp_unget(global); /* Look at it later */
break; /* Exit arg getter. */
}
paren--; /* More to come. */
@ -522,10 +522,10 @@ ReturnCode expcollect(struct Global *global)
else if (c == ',' && paren == 0) /* Comma delimits args */
break;
else if (c == '\n') /* Newline inside arg? */
global->wrongline = TRUE; /* We'll need a #line */
charput(global, c); /* Store this one */
global->wrongline = FPP_TRUE; /* We'll need a #line */
fpp_charput(global, c); /* Store this one */
} /* Collect an argument */
charput(global, EOS); /* Terminate argument */
fpp_charput(global, EOS); /* Terminate argument */
} /* Collect all args. */
return(FPP_OK); /* Normal return */
}
@ -534,7 +534,7 @@ ReturnCode expcollect(struct Global *global)
#if OK_CONCAT
INLINE FILE_LOCAL
char *doquoting(char *to, char *from)
char *fpp_doquoting(char *to, char *from)
{
*to++ = '"';
while (*from) {
@ -549,7 +549,7 @@ char *doquoting(char *to, char *from)
#endif
ReturnCode expstuff(struct Global *global,
ReturnCode fpp_expstuff(struct Global *global,
char *MacroName,
char *MacroReplace)
{
@ -568,7 +568,7 @@ ReturnCode expstuff(struct Global *global,
char quoting; /* Quote macro argument */
#endif
ret = getfile(global, NBUFF, MacroName, &file);
ret = fpp_getfile(global, NBUFF, MacroName, &file);
if(ret)
return(ret);
inp = MacroReplace; /* -> macro replacement */
@ -599,7 +599,7 @@ ReturnCode expstuff(struct Global *global,
}
#endif
if ((defp + size) >= defend) {
cfatal(global, FATAL_OUT_OF_SPACE_IN_ARGUMENT, MacroName);
fpp_cfatal(global, FATAL_OUT_OF_SPACE_IN_ARGUMENT, MacroName);
return(FPP_OUT_OF_SPACE_IN_MACRO_EXPANSION);
}
/*
@ -611,7 +611,7 @@ ReturnCode expstuff(struct Global *global,
}
#if OK_CONCAT
else if (quoting)
defp = doquoting(defp, global->parlist[c]);
defp = fpp_doquoting(defp, global->parlist[c]);
#endif
else {
strcpy(defp, global->parlist[c]);
@ -620,7 +620,7 @@ else {
}
}
else if (defp >= defend) {
cfatal(global, FATAL_OUT_OF_SPACE_IN_ARGUMENT, MacroName);
fpp_cfatal(global, FATAL_OUT_OF_SPACE_IN_ARGUMENT, MacroName);
return(FPP_OUT_OF_SPACE_IN_MACRO_EXPANSION);
} else
*defp++ = c;

View File

@ -24,12 +24,12 @@ SOFTWARE.
#include "cppdef.h"
#include "cpp.h"
INLINE FILE_LOCAL ReturnCode evallex(struct Global *, int, int *);
INLINE FILE_LOCAL ReturnCode dosizeof(struct Global *, int *);
INLINE FILE_LOCAL int bittest(int);
INLINE FILE_LOCAL int evalnum(struct Global *, int);
INLINE FILE_LOCAL int evalchar(struct Global *, int);
INLINE FILE_LOCAL int *evaleval(struct Global *, int *, int, int);
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.
@ -92,7 +92,7 @@ static char opdope[OP_MAX] = {
typedef struct optab {
char op; /* Operator */
char prec; /* Its precedence */
char skip; /* Short-circuit: TRUE to skip */
char skip; /* Short-circuit: FPP_TRUE to skip */
} OPTAB;
#ifdef nomacargs
@ -216,18 +216,18 @@ SIZES size_table[] = {
#endif /* OK_SIZEOF */
ReturnCode eval(struct Global *global, int *eval)
ReturnCode fpp_eval(struct Global *global, int *eval)
{
/*
* Evaluate an expression. Straight-forward operator precedence.
* This is called from control() on encountering an #if statement.
* This is called from fpp_control() on encountering an #if statement.
* It calls the following routines:
* evallex Lexical analyser -- returns the type and value of
* fpp_evallex Lexical analyser -- returns the type and value of
* the next input token.
* evaleval Evaluate the current operator, given the values on
* 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 (TRUE)
* For compatiblity with older cpp's, this return returns 1 (FPP_TRUE)
* if a syntax error is detected.
*/
int op; /* Current operator */
@ -240,7 +240,7 @@ ReturnCode eval(struct Global *global, int *eval)
int value[NEXP]; /* Value stack */
OPTAB opstack[NEXP]; /* Operand stack */
ReturnCode ret;
char again=TRUE;
char again=FPP_TRUE;
valp = value;
opp = opstack;
@ -250,7 +250,7 @@ ReturnCode eval(struct Global *global, int *eval)
binop = 0;
while(again) {
ret=evallex(global, opp->skip, &op);
ret=fpp_evallex(global, opp->skip, &op);
if(ret)
return(ret);
if (op == OP_SUB && binop == 0)
@ -263,27 +263,27 @@ ReturnCode eval(struct Global *global, int *eval)
}
if (op == DIG) { /* Value? */
if (binop != 0) {
cerror(global, ERROR_MISPLACED_CONSTANT);
fpp_cerror(global, ERROR_MISPLACED_CONSTANT);
*eval=1;
return(FPP_OK);
} else if (valp >= &value[NEXP-1]) {
cerror(global, ERROR_IF_OVERFLOW);
fpp_cerror(global, ERROR_IF_OVERFLOW);
*eval=1;
return(FPP_OK);
} else {
*valp++ = global->evalue;
binop = 1;
}
again=TRUE;
again=FPP_TRUE;
continue;
} else if (op > OP_END) {
cerror(global, ERROR_ILLEGAL_IF_LINE);
fpp_cerror(global, ERROR_ILLEGAL_IF_LINE);
*eval=1;
return(FPP_OK);
}
prec = opdope[op];
if (binop != (prec & 1)) {
cerror(global, ERROR_OPERATOR, opname[op]);
fpp_cerror(global, ERROR_OPERATOR, opname[op]);
*eval=1;
return(FPP_OK);
}
@ -300,7 +300,7 @@ ReturnCode eval(struct Global *global, int *eval)
*/
opp++;
if (opp >= &opstack[NEXP]) {
cerror(global, ERROR_EXPR_OVERFLOW, opname[op]);
fpp_cerror(global, ERROR_EXPR_OVERFLOW, opname[op]);
*eval=1;
return(FPP_OK);
}
@ -323,7 +323,7 @@ ReturnCode eval(struct Global *global, int *eval)
else { /* Other ops leave */
opp->skip = op1; /* skipping unchanged. */
}
again=TRUE;
again=FPP_TRUE;
continue;
}
/*
@ -338,11 +338,11 @@ ReturnCode eval(struct Global *global, int *eval)
return(FPP_OK);
}
/* Read another op. */
again=TRUE;
again=FPP_TRUE;
continue;
case OP_LPA: /* ( on stack */
if (op != OP_RPA) { /* Matches ) on input */
cerror(global, ERROR_UNBALANCED_PARENS, opname[op]);
fpp_cerror(global, ERROR_UNBALANCED_PARENS, opname[op]);
*eval=1;
return(FPP_OK);
}
@ -350,12 +350,12 @@ ReturnCode eval(struct Global *global, int *eval)
/* -- Fall through */
case OP_QUE:
/* Evaluate true expr. */
again=TRUE;
again=FPP_TRUE;
continue;
case OP_COL: /* : on stack. */
opp--; /* Unstack : */
if (opp->op != OP_QUE) { /* Matches ? on stack? */
cerror(global, ERROR_MISPLACED, opname[(unsigned)opp->op]);
fpp_cerror(global, ERROR_MISPLACED, opname[(unsigned)opp->op]);
*eval=1;
return(FPP_OK);
}
@ -364,8 +364,8 @@ ReturnCode eval(struct Global *global, int *eval)
*/
default: /* Others: */
opp--; /* Unstack the operator */
valp = evaleval(global, valp, op1, skip);
again=FALSE;
valp = fpp_evaleval(global, valp, op1, skip);
again=FPP_FALSE;
} /* op1 switch end */
} while (!again); /* Stack unwind loop */
}
@ -373,16 +373,16 @@ ReturnCode eval(struct Global *global, int *eval)
}
INLINE FILE_LOCAL
ReturnCode evallex(struct Global *global,
int skip, /* TRUE if short-circuit evaluation */
ReturnCode fpp_evallex(struct Global *global,
int skip, /* FPP_TRUE if short-circuit evaluation */
int *op)
{
/*
* Set *op to next eval operator or value. Called from eval(). It
* 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:
* evalchar called to evaluate 'x'
* evalnum called to evaluate numbers.
* fpp_evalchar called to evaluate 'x'
* fpp_evalnum called to evaluate numbers.
*/
int c, c1, t;
@ -391,55 +391,55 @@ ReturnCode evallex(struct Global *global,
do { /* while(loop); */
/* again: */
loop=FALSE;
loop=FPP_FALSE;
do { /* Collect the token */
c = skipws(global);
if((ret=macroid(global, &c)))
c = fpp_skipws(global);
if((ret=fpp_macroid(global, &c)))
return(ret);
if (c == EOF_CHAR || c == '\n') {
unget(global);
fpp_unget(global);
*op=OP_EOE; /* End of expression */
return(FPP_OK);
}
} while ((t = type[c]) == LET && catenate(global, &ret) && !ret);
} 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))
cerror(global, ERROR_ILLEGAL_CHARACTER, c);
fpp_cerror(global, ERROR_ILLEGAL_CHARACTER, c);
else
cerror(global, ERROR_ILLEGAL_CHARACTER2, c);
fpp_cerror(global, ERROR_ILLEGAL_CHARACTER2, c);
}
return(FPP_ILLEGAL_CHARACTER);
} else if (t == QUO) { /* ' or " */
if (c == '\'') { /* Character constant */
global->evalue = evalchar(global, skip); /* Somewhat messy */
global->evalue = fpp_evalchar(global, skip); /* Somewhat messy */
*op=DIG; /* Return a value */
return(FPP_OK);
}
cerror(global, ERROR_STRING_IN_IF);
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 = skipws(global);
c1 = c = fpp_skipws(global);
if (c == '(') /* Allow defined(name) */
c = skipws(global);
c = fpp_skipws(global);
if (type[c] == LET) {
global->evalue = (lookid(global, c) != NULL);
global->evalue = (fpp_lookid(global, c) != NULL);
if (c1 != '(' /* Need to balance */
|| skipws(global) == ')') { /* Did we balance? */
|| fpp_skipws(global) == ')') { /* Did we balance? */
*op=DIG;
return(FPP_OK); /* Parsed ok */
}
}
cerror(global, ERROR_DEFINED_SYNTAX);
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=dosizeof(global, op); /* Gets own routine */
ret=fpp_dosizeof(global, op); /* Gets own routine */
return(ret);
}
#endif
@ -448,13 +448,13 @@ else if (streq(global->tokenbuf, "sizeof")) { /* New sizeof hackery */
return(FPP_OK);
}
else if (t == DIG) { /* Numbers are harder */
global->evalue = evalnum(global, c);
global->evalue = fpp_evalnum(global, c);
}
else if (strchr("!=<>&|\\", c) != NULL) {
/*
* Process a possible multi-byte lexeme.
*/
c1 = cget(global); /* Peek at next char */
c1 = fpp_cget(global); /* Peek at next char */
switch (c) {
case '!':
if (c1 == '=') {
@ -465,8 +465,8 @@ else if (streq(global->tokenbuf, "sizeof")) { /* New sizeof hackery */
case '=':
if (c1 != '=') { /* Can't say a=b in #if */
unget(global);
cerror(global, ERROR_ILLEGAL_ASSIGN);
fpp_unget(global);
fpp_cerror(global, ERROR_ILLEGAL_ASSIGN);
return (FPP_IF_ERROR);
}
*op=OP_EQ;
@ -493,14 +493,14 @@ else if (streq(global->tokenbuf, "sizeof")) { /* New sizeof hackery */
case '\\':
if (c1 == '\n') { /* Multi-line if */
loop=TRUE;
loop=FPP_TRUE;
break;
}
cerror(global, ERROR_ILLEGAL_BACKSLASH);
fpp_cerror(global, ERROR_ILLEGAL_BACKSLASH);
return(FPP_IF_ERROR);
}
if(!loop)
unget(global);
fpp_unget(global);
}
} while(loop);
*op=t;
@ -510,7 +510,7 @@ else if (streq(global->tokenbuf, "sizeof")) { /* New sizeof hackery */
#if OK_SIZEOF
INLINE FILE_LOCAL
ReturnCode dosizeof(struct Global *global, int *result)
ReturnCode fpp_dosizeof(struct Global *global, int *result)
{
/*
* Process the sizeof (basic type) operation in an #if string.
@ -525,44 +525,44 @@ ReturnCode dosizeof(struct Global *global, int *result)
short typecode;
ReturnCode ret;
if ((c = skipws(global)) != '(') {
unget(global);
cerror(global, ERROR_SIZEOF_SYNTAX);
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 = skipws(global))) {
if((ret=macroid(global, &c)))
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 */
unget(global);
cerror(global, ERROR_SIZEOF_SYNTAX);
fpp_unget(global);
fpp_cerror(global, ERROR_SIZEOF_SYNTAX);
return(FPP_SIZEOF_ERROR);
} else if (c == '(') { /* thing (*)() func ptr */
if (skipws(global) == '*'
&& skipws(global) == ')') { /* We found (*) */
if (skipws(global) != '(') /* Let () be optional */
unget(global);
else if (skipws(global) != ')') {
unget(global);
cerror(global, ERROR_SIZEOF_SYNTAX);
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 */
unget(global);
cerror(global, ERROR_SIZEOF_SYNTAX);
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 (!catenate(global, &ret) && !ret) { /* Maybe combine tokens */
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"
@ -574,7 +574,7 @@ ReturnCode dosizeof(struct Global *global, int *result)
break;
}
if (tp->name == NULLST) {
cerror(global, ERROR_SIZEOF_UNKNOWN, global->tokenbuf);
fpp_cerror(global, ERROR_SIZEOF_UNKNOWN, global->tokenbuf);
return(FPP_SIZEOF_ERROR);
}
typecode |= tp->type; /* Or in the type bit */
@ -586,12 +586,12 @@ ReturnCode dosizeof(struct Global *global, int *result)
*/
if (c == '*') {
typecode |= T_PTR;
c = skipws(global);
c = fpp_skipws(global);
}
if (c == ')') { /* Last syntax check */
for (testp = test_table; *testp != 0; testp++) {
if (!bittest(typecode & *testp)) {
cerror(global, ERROR_SIZEOF_ILLEGAL_TYPE);
if (!fpp_bittest(typecode & *testp)) {
fpp_cerror(global, ERROR_SIZEOF_ILLEGAL_TYPE);
return(FPP_SIZEOF_ERROR);
}
}
@ -609,7 +609,7 @@ ReturnCode dosizeof(struct Global *global, int *result)
typecode &= ~T_INT;
}
if ((typecode & ~T_PTR) == 0) {
cerror(global, ERROR_SIZEOF_NO_TYPE);
fpp_cerror(global, ERROR_SIZEOF_NO_TYPE);
return(FPP_SIZEOF_ERROR);
}
/*
@ -623,19 +623,19 @@ ReturnCode dosizeof(struct Global *global, int *result)
return(FPP_OK);
}
} /* We shouldn't fail */
cerror(global, ERROR_SIZEOF_BUG, typecode);
fpp_cerror(global, ERROR_SIZEOF_BUG, typecode);
return(FPP_SIZEOF_ERROR);
}
unget(global);
cerror(global, ERROR_SIZEOF_SYNTAX);
fpp_unget(global);
fpp_cerror(global, ERROR_SIZEOF_SYNTAX);
return(FPP_SIZEOF_ERROR);
}
INLINE FILE_LOCAL
int bittest(int value)
int fpp_bittest(int value)
{
/*
* TRUE if value is zero or exactly one bit is set in value.
* FPP_TRUE if value is zero or exactly one bit is set in value.
*/
#if (4096 & ~(-4096)) == 0
@ -651,10 +651,10 @@ int bittest(int value)
#endif /* OK_SIZEOF */
INLINE FILE_LOCAL
int evalnum(struct Global *global, int c)
int fpp_evalnum(struct Global *global, int c)
{
/*
* Expand number for #if lexical analysis. Note: evalnum recognizes
* Expand number for #if lexical analysis. Note: fpp_evalnum recognizes
* the unsigned suffix, but only returns a signed int value.
*/
@ -664,16 +664,16 @@ int evalnum(struct Global *global, int c)
if (c != '0')
base = 10;
else if ((c = cget(global)) == 'x' || c == 'X') {
else if ((c = fpp_cget(global)) == 'x' || c == 'X') {
base = 16;
c = cget(global);
c = fpp_cget(global);
}
else base = 8;
value = 0;
for (;;) {
c1 = c;
if (isascii(c) && isupper(c1))
c1 = tolower(c1);
c1 = fpp_tolower(c1);
if (c1 >= 'a')
c1 -= ('a' - 10);
else c1 -= '0';
@ -681,17 +681,17 @@ int evalnum(struct Global *global, int c)
break;
value *= base;
value += c1;
c = cget(global);
c = fpp_cget(global);
}
if (c == 'u' || c == 'U') /* Unsigned nonsense */
c = cget(global);
unget(global);
c = fpp_cget(global);
fpp_unget(global);
return (value);
}
INLINE FILE_LOCAL
int evalchar(struct Global *global,
int skip) /* TRUE if short-circuit evaluation */
int fpp_evalchar(struct Global *global,
int skip) /* FPP_TRUE if short-circuit evaluation */
/*
* Get a character constant
*/
@ -700,9 +700,9 @@ int evalchar(struct Global *global,
int value;
int count;
global->instring = TRUE;
if ((c = cget(global)) == '\\') {
switch ((c = cget(global))) {
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 */
@ -742,14 +742,14 @@ int evalchar(struct Global *global,
case 'x': /* '\xFF' */
count = 3;
value = 0;
while ((((c = get(global)) >= '0' && c <= '9')
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);
}
unget(global);
fpp_unget(global);
break;
default:
@ -759,9 +759,9 @@ int evalchar(struct Global *global,
while (c >= '0' && c <= '7' && --count >= 0) {
value *= 8;
value += (c - '0');
c = get(global);
c = fpp_get(global);
}
unget(global);
fpp_unget(global);
} else
value = c;
break;
@ -776,9 +776,9 @@ int evalchar(struct Global *global,
#if BIG_ENDIAN
count = 0;
#endif
while ((c = get(global)) != '\'' && c != EOF_CHAR && c != '\n') {
while ((c = fpp_get(global)) != '\'' && c != EOF_CHAR && c != '\n') {
if (!skip)
cwarn(global, WARN_MULTIBYTE_NOT_PORTABLE, c);
fpp_cwarn(global, WARN_MULTIBYTE_NOT_PORTABLE, c);
#if BIG_ENDIAN
count += BITS_CHAR;
value += (c << count);
@ -787,15 +787,15 @@ int evalchar(struct Global *global,
value += c;
#endif
}
global->instring = FALSE;
global->instring = FPP_FALSE;
return (value);
}
INLINE FILE_LOCAL
int *evaleval(struct Global *global,
int *fpp_evaleval(struct Global *global,
int *valp,
int op,
int skip) /* TRUE if short-circuit evaluation */
int skip) /* FPP_TRUE if short-circuit evaluation */
{
/*
* Apply the argument operator to the data on the value stack.
@ -804,7 +804,7 @@ int *evaleval(struct Global *global,
*
* OP_COL is a special case.
*
* evaleval() returns the new pointer to the top of the value stack.
* fpp_evaleval() returns the new pointer to the top of the value stack.
*/
int v1, v2 = 0;
@ -827,7 +827,7 @@ int *evaleval(struct Global *global,
case OP_MOD:
if (v2 == 0) {
if (!skip) {
cwarn(global, WARN_DIVISION_BY_ZERO,
fpp_cwarn(global, WARN_DIVISION_BY_ZERO,
(op == OP_DIV) ? "divide" : "mod");
}
v1 = 0;
@ -895,7 +895,7 @@ int *evaleval(struct Global *global,
v1 = !v1;
break;
default:
cerror(global, ERROR_IF_OPERAND, op);
fpp_cerror(global, ERROR_IF_OPERAND, op);
v1 = 0;
}
*valp++ = v1;

View File

@ -24,52 +24,52 @@ SOFTWARE.
#include "cppdef.h"
#include "cpp.h"
INLINE FILE_LOCAL void outadefine(struct Global *, DEFBUF *);
INLINE FILE_LOCAL void domsg(struct Global *, ErrorCode, va_list);
INLINE FILE_LOCAL void fpp_outadefine(struct Global *, DEFBUF *);
INLINE FILE_LOCAL void fpp_domsg(struct Global *, ErrorCode, va_list);
/*
* skipnl() skips over input text to the end of the line.
* skipws() skips over "whitespace" (spaces or tabs), but
* fpp_skipnl() skips over input text to the end of the line.
* fpp_skipws() skips over "whitespace" (spaces or tabs), but
* not skip over the end of the line. It skips over
* TOK_SEP, however (though that shouldn't happen).
* scanid() reads the next token (C identifier) into tokenbuf.
* fpp_scanid() reads the next token (C identifier) into tokenbuf.
* The caller has already read the first character of
* the identifier. Unlike macroid(), the token is
* the identifier. Unlike fpp_macroid(), the token is
* never expanded.
* macroid() reads the next token (C identifier) into tokenbuf.
* fpp_macroid() reads the next token (C identifier) into tokenbuf.
* If it is a #defined macro, it is expanded, and
* macroid() returns TRUE, otherwise, FALSE.
* catenate() Does the dirty work of token concatenation, TRUE if it did.
* scanstring() Reads a string from the input stream, calling
* fpp_macroid() returns FPP_TRUE, otherwise, FPP_FALSE.
* fpp_catenate() Does the dirty work of token concatenation, FPP_TRUE if it did.
* fpp_scanstring() Reads a string from the input stream, calling
* a user-supplied function for each character.
* This function may be output() to write the
* string to the output file, or save() to save
* This function may be fpp_output() to write the
* string to the output file, or fpp_save() to fpp_save
* the string in the work buffer.
* scannumber() Reads a C numeric constant from the input stream,
* fpp_scannumber() Reads a C numeric constant from the input stream,
* calling the user-supplied function for each
* character. (output() or save() as noted above.)
* save() Save one character in the work[] buffer.
* savestring() Saves a string in malloc() memory.
* getfile() Initialize a new FILEINFO structure, called when
* character. (fpp_output() or fpp_save() as noted above.)
* fpp_save() Save one character in the work[] buffer.
* fpp_savestring() Saves a string in malloc() memory.
* fpp_getfile() Initialize a new FILEINFO structure, called when
* #include opens a new file, or a macro is to be
* expanded.
* Getmem() Get a specified number of bytes from malloc memory.
* output() Write one character to stdout (calling Putchar) --
* fpp_Getmem() Get a specified number of bytes from malloc memory.
* fpp_output() Write one character to stdout (calling fpp_Putchar) --
* implemented as a function so its address may be
* passed to scanstring() and scannumber().
* lookid() Scans the next token (identifier) from the input
* passed to fpp_scanstring() and fpp_scannumber().
* fpp_lookid() Scans the next token (identifier) from the input
* stream. Looks for it in the #defined symbol table.
* Returns a pointer to the definition, if found, or NULL
* if not present. The identifier is stored in tokenbuf.
* defnedel() Define enter/delete subroutine. Updates the
* fpp_defendel() Define enter/delete subroutine. Updates the
* symbol table.
* get() Read the next byte from the current input stream,
* fpp_get() Read the next byte from the current input stream,
* handling end of (macro/file) input and embedded
* comments appropriately. Note that the global
* instring is -- essentially -- a parameter to get().
* cget() Like get(), but skip over TOK_SEP.
* unget() Push last gotten character back on the input stream.
* cerror() This routine format an print messages to the user.
* instring is -- essentially -- a parameter to fpp_get().
* fpp_cget() Like fpp_get(), but skip over TOK_SEP.
* fpp_unget() Push last gotten character back on the input stream.
* fpp_cerror() This routine format an print messages to the user.
*/
/*
@ -121,7 +121,7 @@ char type[256] = { /* Character type codes Hex */
000, 000, 000, 000, 000, 000, 000, 000, /* 80 .. FF */
};
void skipnl(struct Global *global)
void fpp_skipnl(struct Global *global)
{
/*
* Skip to the end of the current input line.
@ -129,12 +129,12 @@ void skipnl(struct Global *global)
int c;
do { /* Skip to newline */
c = get(global);
c = fpp_get(global);
} while (c != '\n' && c != EOF_CHAR);
return;
}
int skipws(struct Global *global)
int fpp_skipws(struct Global *global)
{
/*
* Skip over whitespace
@ -142,7 +142,7 @@ int skipws(struct Global *global)
int c;
do { /* Skip whitespace */
c = get(global);
c = fpp_get(global);
#if COMMENT_INVISIBLE
} while (type[c] == SPA || c == COM_SEP);
#else
@ -151,19 +151,19 @@ int skipws(struct Global *global)
return(c);
}
void scanid(struct Global *global,
void fpp_scanid(struct Global *global,
int c) /* First char of id */
{
/*
* Get the next token (an id) into the token buffer.
* Note: this code is duplicated in lookid().
* Note: this code is duplicated in fpp_lookid().
* Change one, change both.
*/
int ct;
if (c == DEF_MAGIC) /* Eat the magic token */
c = get(global); /* undefiner. */
c = fpp_get(global); /* undefiner. */
ct = 0;
do
{
@ -171,14 +171,14 @@ void scanid(struct Global *global,
global->tokenbuf = realloc(global->tokenbuf, 1 +
(global->tokenbsize *= 2));
global->tokenbuf[ct++] = c;
c = get(global);
c = fpp_get(global);
}
while (type[c] == LET || type[c] == DIG);
unget(global);
fpp_unget(global);
global->tokenbuf[ct] = EOS;
}
ReturnCode macroid(struct Global *global, int *c)
ReturnCode fpp_macroid(struct Global *global, int *c)
{
/*
* If c is a letter, scan the id. if it's #defined, expand it and scan
@ -191,51 +191,53 @@ ReturnCode macroid(struct Global *global, int *c)
if (global->infile != NULL && global->infile->fp != NULL)
global->recursion = 0;
while (type[*c] == LET && (dp = lookid(global, *c)) != NULL) {
if((ret=expand(global, dp)))
while (type[*c] == LET && (dp = fpp_lookid(global, *c)) != NULL) {
if((ret=fpp_expand(global, dp)))
return(ret);
*c = get(global);
*c = fpp_get(global);
}
return(FPP_OK);
}
int catenate(struct Global *global, ReturnCode *ret)
int fpp_catenate(struct Global *global, int lhs_number, ReturnCode *ret)
{
/*
* A token was just read (via macroid).
* A token was just read (via fpp_macroid).
* If the next character is TOK_SEP, concatenate the next token
* return TRUE -- which should recall macroid after refreshing
* macroid's argument. If it is not TOK_SEP, unget() the character
* and return FALSE.
* return FPP_TRUE -- which should recall fpp_macroid after refreshing
* fpp_macroid's argument. If it is not TOK_SEP, fpp_unget() the character
* and return FPP_FALSE.
*/
#if OK_CONCAT
int c;
char *token1;
char *token1 = "";
#endif
#if OK_CONCAT
if (get(global) != TOK_SEP) { /* Token concatenation */
unget(global);
return (FALSE);
if (fpp_get(global) != TOK_SEP) { /* Token concatenation */
fpp_unget(global);
return (FPP_FALSE);
}
else {
token1 = savestring(global, global->tokenbuf); /* Save first token */
c=get(global);
if (lhs_number == 0) { /* The lhs number has already been emit */
token1 = fpp_savestring(global, global->tokenbuf); /* Save first token */
}
c= fpp_get(global);
if(global->rightconcat) {
*ret=macroid(global, &c); /* Scan next token */
*ret=fpp_macroid(global, &c); /* Scan next token */
if(*ret)
return(FALSE);
return(FPP_FALSE);
} /* BK - BUG? Parses token into global->tokenbuf but never uses it.
else
lookid(global, c);
fpp_lookid(global, c);
*/
switch(type[c]) { /* What was it? */
case LET: /* An identifier, ... */
if ((int)strlen(token1) + (int)strlen(global->tokenbuf) >= NWORK) {
cfatal(global, FATAL_WORK_AREA_OVERFLOW, token1);
fpp_cfatal(global, FATAL_WORK_AREA_OVERFLOW, token1);
*ret=FPP_WORK_AREA_OVERFLOW;
return(FALSE);
return(FPP_FALSE);
}
sprintf(global->work, "%s%s", token1, global->tokenbuf);
break;
@ -243,20 +245,20 @@ int catenate(struct Global *global, ReturnCode *ret)
case DOT: /* Or maybe a float */
strcpy(global->work, token1);
global->workp = global->work + strlen(global->work);
*ret=scannumber(global, c, save);
*ret=fpp_scannumber(global, c, fpp_save);
if(*ret)
return(FALSE);
*ret=save(global, EOS);
return(FPP_FALSE);
*ret=fpp_save(global, EOS);
if(*ret)
return(FALSE);
return(FPP_FALSE);
break;
default: /* An error, ... */
if (isprint(c))
cerror(global, ERROR_STRANG_CHARACTER, c);
fpp_cerror(global, ERROR_STRANG_CHARACTER, c);
else
cerror(global, ERROR_STRANG_CHARACTER2, c);
fpp_cerror(global, ERROR_STRANG_CHARACTER2, c);
strcpy(global->work, token1);
unget(global);
fpp_unget(global);
break;
}
/*
@ -265,18 +267,20 @@ int catenate(struct Global *global, ReturnCode *ret)
* new (concatenated) token after freeing token1.
* Finally, setup to read the new token.
*/
free(token1); /* Free up memory */
*ret=ungetstring(global, global->work); /* Unget the new thing, */
if (lhs_number == 0) {
free(token1); /* Free up memory */
}
*ret=fpp_ungetstring(global, global->work); /* Unget the new thing, */
if(*ret)
return(FALSE);
return(TRUE);
return(FPP_FALSE);
return(FPP_TRUE);
}
#else
return(FALSE); /* Not supported */
return(FPP_FALSE); /* Not supported */
#endif
}
ReturnCode scanstring(struct Global *global,
ReturnCode fpp_scanstring(struct Global *global,
int delim, /* ' or " */
/* Output function: */
ReturnCode (*outfun)(struct Global *, int))
@ -284,40 +288,40 @@ ReturnCode scanstring(struct Global *global,
/*
* Scan off a string. Warning if terminated by newline or EOF.
* outfun() outputs the character -- to a buffer if in a macro.
* TRUE if ok, FALSE if error.
* FPP_TRUE if ok, FPP_FALSE if error.
*/
int c;
ReturnCode ret;
global->instring = TRUE; /* Don't strip comments */
global->instring = FPP_TRUE; /* Don't strip comments */
ret=(*outfun)(global, delim);
if(ret)
return(ret);
while ((c = get(global)) != delim
while ((c = fpp_get(global)) != delim
&& c != '\n'
&& c != EOF_CHAR) {
ret=(*outfun)(global, c);
if(ret)
return(ret);
if (c == '\\') {
ret=(*outfun)(global, get(global));
ret=(*outfun)(global, fpp_get(global));
if(ret)
return(ret);
}
}
global->instring = FALSE;
global->instring = FPP_FALSE;
if (c == delim) {
ret=(*outfun)(global, c);
return(ret);
} else {
cerror(global, ERROR_UNTERMINATED_STRING);
unget(global);
fpp_cerror(global, ERROR_UNTERMINATED_STRING);
fpp_unget(global);
return(FPP_UNTERMINATED_STRING);
}
}
ReturnCode scannumber(struct Global *global,
ReturnCode fpp_scannumber(struct Global *global,
int c, /* First char of number */
/* Output/store func: */
ReturnCode (*outfun)(struct Global *, int))
@ -331,20 +335,20 @@ ReturnCode scannumber(struct Global *global,
int expseen; /* 'e' seen in floater */
int signseen; /* '+' or '-' seen */
int octal89; /* For bad octal test */
int dotflag; /* TRUE if '.' was seen */
int dotflag; /* FPP_TRUE if '.' was seen */
ReturnCode ret;
char done=FALSE;
char done=FPP_FALSE;
expseen = FALSE; /* No exponent seen yet */
signseen = TRUE; /* No +/- allowed yet */
octal89 = FALSE; /* No bad octal yet */
expseen = FPP_FALSE; /* No exponent seen yet */
signseen = FPP_TRUE; /* No +/- allowed yet */
octal89 = FPP_FALSE; /* No bad octal yet */
radix = 10; /* Assume decimal */
if ((dotflag = (c == '.')) != FALSE) {/* . something? */
if ((dotflag = (c == '.')) != FPP_FALSE) {/* . something? */
ret=(*outfun)(global, '.'); /* Always out the dot */
if(ret)
return(ret);
if (type[(c = get(global))] != DIG) { /* If not a float numb, */
unget(global); /* Rescan strange char */
if (type[(c = fpp_get(global))] != DIG) { /* If not a float numb, */
fpp_unget(global); /* Rescan strange char */
return(FPP_OK); /* All done for now */
}
} /* End of float test */
@ -353,13 +357,13 @@ ReturnCode scannumber(struct Global *global,
if(ret)
return(ret);
radix = 8; /* Assume it's octal */
c = get(global); /* Look for an 'x' */
if (c == 'x' || c == 'X') { /* Did we get one? */
c = fpp_get(global); /* Look for an 'x' */
if (c == 'x' || c == 'X') { /* Did we fpp_get one? */
radix = 16; /* Remember new radix */
ret=(*outfun)(global, c); /* Stuff the 'x' */
if(ret)
return(ret);
c = get(global); /* Get next character */
c = fpp_get(global); /* Get next character */
}
}
while (!done) { /* Process curr. char. */
@ -370,24 +374,24 @@ ReturnCode scannumber(struct Global *global,
if (radix != 16 && (c == 'e' || c == 'E')) {
if (expseen) /* Already saw 'E'? */
break; /* Exit loop, bad nbr. */
expseen = TRUE; /* Set exponent seen */
signseen = FALSE; /* We can read '+' now */
expseen = FPP_TRUE; /* Set exponent seen */
signseen = FPP_FALSE; /* We can read '+' now */
radix = 10; /* Decimal exponent */
}
else if (radix != 16 && c == '.') {
if (dotflag) /* Saw dot already? */
break; /* Exit loop, two dots */
dotflag = TRUE; /* Remember the dot */
dotflag = FPP_TRUE; /* Remember the dot */
radix = 10; /* Decimal fraction */
}
else if (c == '+' || c == '-') { /* 1.0e+10 */
if (signseen) /* Sign in wrong place? */
break; /* Exit loop, not nbr. */
/* signseen = TRUE; */ /* Remember we saw it */
/* signseen = FPP_TRUE; */ /* Remember we saw it */
} else { /* Check the digit */
switch (c) {
case '8': case '9': /* Sometimes wrong */
octal89 = TRUE; /* Do check later */
octal89 = FPP_TRUE; /* Do check later */
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
break; /* Always ok */
@ -397,15 +401,15 @@ ReturnCode scannumber(struct Global *global,
if (radix == 16) /* Alpha's are ok only */
break; /* if reading hex. */
default: /* At number end */
done=TRUE; /* Break from for loop */
done=FPP_TRUE; /* Break from for loop */
continue;
} /* End of switch */
} /* End general case */
ret=(*outfun)(global, c); /* Accept the character */
if(ret)
return(ret);
signseen = TRUE; /* Don't read sign now */
c = get(global); /* Read another char */
signseen = FPP_TRUE; /* Don't read sign now */
c = fpp_get(global); /* Read another char */
} /* End of scan loop */
/*
* When we break out of the scan loop, c contains the first
@ -421,7 +425,7 @@ ReturnCode scannumber(struct Global *global,
ret=(*outfun)(global, c);
if(ret)
return(ret);
c = get(global); /* Ungotten later */
c = fpp_get(global); /* Ungotten later */
}
} else { /* Else it's an integer */
/*
@ -429,54 +433,54 @@ ReturnCode scannumber(struct Global *global,
* dotflag signals "saw 'L'", and
* expseen signals "saw 'U'".
*/
done=TRUE;
done=FPP_TRUE;
while(done) {
switch (c) {
case 'l':
case 'L':
if (dotflag) {
done=FALSE;
done=FPP_FALSE;
continue;
}
dotflag = TRUE;
dotflag = FPP_TRUE;
break;
case 'u':
case 'U':
if (expseen) {
done=FALSE;
done=FPP_FALSE;
continue;
}
expseen = TRUE;
expseen = FPP_TRUE;
break;
default:
done=FALSE;
done=FPP_FALSE;
continue;
}
ret=(*outfun)(global, c); /* Got 'L' or 'U'. */
if(ret)
return(ret);
c = get(global); /* Look at next, too. */
c = fpp_get(global); /* Look at next, too. */
}
}
unget(global); /* Not part of a number */
fpp_unget(global); /* Not part of a number */
if(!(global->webmode)) {
if (octal89 && radix == 8)
cwarn(global, WARN_ILLEGAL_OCTAL);
fpp_cwarn(global, WARN_ILLEGAL_OCTAL);
}
return(FPP_OK);
}
ReturnCode save(struct Global *global, int c)
ReturnCode fpp_save(struct Global *global, int c)
{
if (global->workp >= &global->work[NWORK]) {
cfatal(global, FATAL_WORK_BUFFER_OVERFLOW);
fpp_cfatal(global, FATAL_WORK_BUFFER_OVERFLOW);
return(FPP_WORK_AREA_OVERFLOW);
} else
*global->workp++ = c;
return(FPP_OK);
}
char *savestring(struct Global *global, char *text)
char *fpp_savestring(struct Global *global, char *text)
{
/*
* Store a string into free memory.
@ -488,7 +492,7 @@ char *savestring(struct Global *global, char *text)
return (result);
}
ReturnCode getfile(struct Global *global,
ReturnCode fpp_getfile(struct Global *global,
size_t bufsize, /* Line or define buffer size */
char *name,
FILEINFO **file) /* File or macro name string */
@ -511,7 +515,7 @@ ReturnCode getfile(struct Global *global,
return(FPP_OUT_OF_MEMORY);
(*file)->parent = global->infile; /* Chain files together */
(*file)->fp = NULL; /* No file yet */
(*file)->filename = savestring(global, name); /* Save file/macro name */
(*file)->filename = fpp_savestring(global, name); /* Save file/macro name */
(*file)->progname = NULL; /* No #line seen yet */
(*file)->unrecur = 0; /* No macro fixup */
(*file)->bptr = (*file)->buffer; /* Initialize line ptr */
@ -528,7 +532,7 @@ ReturnCode getfile(struct Global *global,
* C P P S y m b o l T a b l e s
*/
DEFBUF *lookid(struct Global *global,
DEFBUF *fpp_lookid(struct Global *global,
int c) /* First character of token */
{
/*
@ -544,16 +548,16 @@ DEFBUF *lookid(struct Global *global,
nhash = 0;
if ((isrecurse = (c == DEF_MAGIC))) /* If recursive macro */
c = get(global); /* hack, skip DEF_MAGIC */
c = fpp_get(global); /* hack, skip DEF_MAGIC */
ct = 0;
do {
if (ct == global->tokenbsize)
global->tokenbuf = realloc(global->tokenbuf, 1 + (global->tokenbsize *= 2));
global->tokenbuf[ct++] = c; /* Store token byte */
nhash += c; /* Update hash value */
c = get(global);
c = fpp_get(global);
} while (type[c] == LET || type[c] == DIG);
unget(global); /* Rescan terminator */
fpp_unget(global); /* Rescan terminator */
global->tokenbuf[ct] = EOS; /* Terminate token */
if (isrecurse) /* Recursive definition */
return(NULL); /* undefined just now */
@ -568,15 +572,15 @@ DEFBUF *lookid(struct Global *global,
return((temp == 0) ? dp : NULL);
}
DEFBUF *defendel(struct Global *global,
DEFBUF *fpp_defendel(struct Global *global,
char *name,
int delete) /* TRUE to delete a symbol */
int delete) /* FPP_TRUE to delete a symbol */
{
/*
* Enter this name in the lookup table (delete = FALSE)
* or delete this name (delete = TRUE).
* Returns a pointer to the define block (delete = FALSE)
* Returns NULL if the symbol wasn't defined (delete = TRUE).
* Enter this name in the lookup table (delete = FPP_FALSE)
* or delete this name (delete = FPP_TRUE).
* Returns a pointer to the define block (delete = FPP_FALSE)
* Returns NULL if the symbol wasn't defined (delete = FPP_TRUE).
*/
DEFBUF *dp;
@ -618,93 +622,115 @@ DEFBUF *defendel(struct Global *global,
return(dp);
}
void fpp_delalldefines(struct Global *global)
{
/*
* Delete all the defines in the tables and free memory
*/
void outdefines(struct Global *global)
DEFBUF *dp;
DEFBUF *prevp;
int i;
for (i = 0; i < SBSIZE; ++i)
{
prevp = global->symtab[i];
while ((dp = prevp) != (DEFBUF *)NULL) {
prevp = dp->link;
free(dp->repl); /* Free the replacement */
free((char *)dp); /* Free the symbol */
}
global->symtab[i] = NULL;
}
}
void fpp_outdefines(struct Global *global)
{
DEFBUF *dp;
DEFBUF **syp;
deldefines(global); /* Delete built-in #defines */
fpp_delbuiltindefines(global); /* Delete built-in #defines */
for (syp = global->symtab; syp < &global->symtab[SBSIZE]; syp++) {
if ((dp = *syp) != (DEFBUF *) NULL) {
do {
outadefine(global, dp);
fpp_outadefine(global, dp);
} while ((dp = dp->link) != (DEFBUF *) NULL);
}
}
}
INLINE FILE_LOCAL
void outadefine(struct Global *global, DEFBUF *dp)
void fpp_outadefine(struct Global *global, DEFBUF *dp)
{
char *cp;
int c;
/* printf("#define %s", dp->name); */
Putstring(global, "#define ");
Putstring(global, dp->name);
fpp_Putstring(global, "#define ");
fpp_Putstring(global, dp->name);
if (dp->nargs > 0) {
int i;
Putchar(global, '(');
fpp_Putchar(global, '(');
for (i = 1; i < dp->nargs; i++) {
/* printf("__%d,", i); */
Putstring(global, "__");
Putint(global, i);
Putchar(global, ',');
fpp_Putstring(global, "__");
fpp_Putint(global, i);
fpp_Putchar(global, ',');
}
/* printf("__%d)", i); */
Putstring(global, "__");
Putint(global, i);
Putchar(global, ')');
fpp_Putstring(global, "__");
fpp_Putint(global, i);
fpp_Putchar(global, ')');
} else if (dp->nargs == 0) {
Putstring(global, "()");
fpp_Putstring(global, "()");
}
if (dp->repl != NULL) {
Putchar(global, '\t');
fpp_Putchar(global, '\t');
for (cp = dp->repl; (c = *cp++ & 0xFF) != EOS;) {
if (c >= MAC_PARM && c < (MAC_PARM + PAR_MAC)) {
/* printf("__%d", c - MAC_PARM + 1); */
Putstring(global, "__");
Putint(global, c - MAC_PARM + 1);
fpp_Putstring(global, "__");
fpp_Putint(global, c - MAC_PARM + 1);
} else if (isprint(c) || c == '\t' || c == '\n')
Putchar(global, c);
fpp_Putchar(global, c);
else switch (c) {
case QUOTE_PARM:
Putchar(global, '#');
fpp_Putchar(global, '#');
break;
case DEF_MAGIC: /* Special anti-recursion */
case MAC_PARM + PAR_MAC: /* Special "arg" marker */
break;
case COM_SEP:
#if COMMENT_INVISIBLE
Putstring(global, "/**/");
fpp_Putstring(global, "/**/");
#else
Putchar(global, ' ');
fpp_Putchar(global, ' ');
#endif
break;
case TOK_SEP:
Putstring(global, "##");
fpp_Putstring(global, "##");
break;
default:
{
/* Octal output! */
char buffer[32];
sprintf(buffer, "\\0%o", c);
Putstring(global, buffer);
fpp_Putstring(global, buffer);
}
}
}
}
Putchar(global, '\n');
fpp_Putchar(global, '\n');
}
/*
* G E T
*/
int get(struct Global *global)
int fpp_get(struct Global *global)
{
/*
* Return the next character from a macro or the current file.
@ -760,12 +786,12 @@ int get(struct Global *global)
if ((global->infile = file->parent) != NULL) {
/*
* There is an "ungotten" newline in the current
* infile buffer (set there by doinclude() in
* infile buffer (set there by fpp_doinclude() in
* cpp1.c). Thus, we know that the mainline code
* is skipping over blank lines and will do a
* #line at its convenience.
*/
global->wrongline = TRUE; /* Need a #line now */
global->wrongline = FPP_TRUE; /* Need a #line now */
}
}
}
@ -802,13 +828,13 @@ int get(struct Global *global)
if (global->instring) /* Strings just return */
return (c); /* the character. */
else if (c == '/') { /* Comment? */
global->instring = TRUE; /* So get() won't loop */
global->instring = FPP_TRUE; /* So fpp_get() won't loop */
/* Check next byte for '*' and if(cplusplus) also '/' */
if ( (c = get(global)) != '*' )
if ( (c = fpp_get(global)) != '*' )
if(!global->cplusplus || (global->cplusplus && c!='/')) {
global->instring = FALSE; /* Nope, no comment */
unget(global); /* Push the char. back */
global->instring = FPP_FALSE; /* Nope, no comment */
fpp_unget(global); /* Push the char. back */
return ('/'); /* Return the slash */
}
@ -816,49 +842,49 @@ int get(struct Global *global)
if (global->keepcomments) { /* If writing comments */
global->comment = TRUE; /* information that a comment has been output */
global->comment = FPP_TRUE; /* information that a comment has been output */
if(global->showspace) {
/* Show all whitespaces! */
global->spacebuf[global->chpos] = '\0';
Putstring(global, global->spacebuf);
fpp_Putstring(global, global->spacebuf);
}
if(c=='*') {
Putchar(global, '/'); /* Write out the */
Putchar(global, '*'); /* initializer */
fpp_Putchar(global, '/'); /* Write out the */
fpp_Putchar(global, '*'); /* initializer */
} else {
/* C++ style comment */
Putchar(global, '/'); /* Write out the */
Putchar(global, '/'); /* initializer */
fpp_Putchar(global, '/'); /* Write out the */
fpp_Putchar(global, '/'); /* initializer */
}
}
if(global->cplusplus && c=='/') { /* Eat C++ comment! */
do {
c=get(global);
c=fpp_get(global);
if(global->keepcomments)
Putchar(global, c);
fpp_Putchar(global, c);
} while(c!='\n' && c!=EOF_CHAR); /* eat all to EOL or EOF */
global->instring = FALSE; /* End of comment */
global->instring = FPP_FALSE; /* End of comment */
return(c); /* Return the end char */
}
for (;;) { /* Eat a comment */
c = get(global);
c = fpp_get(global);
test:
if (global->keepcomments && c != EOF_CHAR)
Putchar(global, c);
fpp_Putchar(global, c);
switch (c) {
case EOF_CHAR:
cerror(global, ERROR_EOF_IN_COMMENT);
fpp_cerror(global, ERROR_EOF_IN_COMMENT);
return (EOF_CHAR);
case '/':
if(global->nestcomments || global->warnnestcomments) {
if((c = get(global)) != '*')
if((c = fpp_get(global)) != '*')
goto test;
if(global->warnnestcomments) {
cwarn(global, WARN_NESTED_COMMENT);
fpp_cwarn(global, WARN_NESTED_COMMENT);
}
if(global->nestcomments)
comments++;
@ -866,16 +892,16 @@ int get(struct Global *global)
break;
case '*':
if ((c = get(global)) != '/') /* If comment doesn't */
if ((c = fpp_get(global)) != '/') /* If comment doesn't */
goto test; /* end, look at next */
if (global->keepcomments) { /* Put out the comment */
Putchar(global, c); /* terminator, too */
fpp_Putchar(global, c); /* terminator, too */
}
if(--comments)
/* nested comment, continue! */
break;
global->instring = FALSE; /* End of comment, */
global->instring = FPP_FALSE; /* End of comment, */
/*
* A comment is syntactically "whitespace" --
* however, there are certain strange sequences
@ -905,18 +931,18 @@ int get(struct Global *global)
case '\n': /* we'll need a #line */
if (!global->keepcomments)
global->wrongline = TRUE; /* later... */
global->wrongline = FPP_TRUE; /* later... */
default: /* Anything else is */
break; /* Just a character */
} /* End switch */
} /* End comment loop */
} /* End if in comment */
else if (!global->inmacro && c == '\\') { /* If backslash, peek */
if ((c = get(global)) == '\n') { /* for a <nl>. If so, */
global->wrongline = TRUE;
if ((c = fpp_get(global)) == '\n') { /* for a <nl>. If so, */
global->wrongline = FPP_TRUE;
goto newline;
} else { /* Backslash anything */
unget(global); /* Get it later */
fpp_unget(global); /* Get it later */
return ('\\'); /* Return the backslash */
}
} else if (c == '\f' || c == VT) /* Form Feed, Vertical */
@ -924,20 +950,20 @@ int get(struct Global *global)
return (c); /* Just return the char */
}
void unget(struct Global *global)
void fpp_unget(struct Global *global)
{
/*
* Backup the pointer to reread the last character. Fatal error
* (code bug) if we backup too far. unget() may be called,
* (code bug) if we backup too far. fpp_unget() may be called,
* without problems, at end of file. Only one character may
* be ungotten. If you need to unget more, call ungetstring().
* be ungotten. If you need to unget more, call fpp_ungetstring().
*/
FILEINFO *file;
if ((file = global->infile) == NULL)
return; /* Unget after EOF */
if (--file->bptr < file->buffer) {
cfatal(global, FATAL_TOO_MUCH_PUSHBACK);
fpp_cfatal(global, FATAL_TOO_MUCH_PUSHBACK);
/* This happens only if used the wrong way! */
return;
}
@ -945,7 +971,7 @@ void unget(struct Global *global)
--global->line; /* Unget the line number, too */
}
ReturnCode ungetstring(struct Global *global, char *text)
ReturnCode fpp_ungetstring(struct Global *global, char *text)
{
/*
* Push a string back on the input stream. This is done by treating
@ -955,13 +981,13 @@ ReturnCode ungetstring(struct Global *global, char *text)
FILEINFO *file;
ReturnCode ret;
ret = getfile(global, strlen(text) + 1, "", &file);
ret = fpp_getfile(global, strlen(text) + 1, "", &file);
if(!ret)
strcpy(file->buffer, text);
return(ret);
}
int cget(struct Global *global)
int fpp_cget(struct Global *global)
{
/*
* Get one character, absorb "funny space" after comments or
@ -970,7 +996,7 @@ int cget(struct Global *global)
int c;
do {
c = get(global);
c = fpp_get(global);
#if COMMENT_INVISIBLE
} while (c == TOK_SEP || c == COM_SEP);
#else
@ -984,7 +1010,7 @@ int cget(struct Global *global)
*/
INLINE FILE_LOCAL
void domsg(struct Global *global,
void fpp_domsg(struct Global *global,
ErrorCode error, /* error message number */
va_list arg) /* Something for the message */
{
@ -1083,8 +1109,8 @@ void domsg(struct Global *global,
for (file = global->infile; file && !file->fp; file = file->parent)
;
tp = file ? file->filename : 0;
Error(global, "%s\"%s\", line %d: %s: ",
MSG_PREFIX, tp, global->infile?global->line:(file?file->line:0), severity);
fpp_Error(global, "%s\"%s\", line %d: %s: ",
MSG_PREFIX, tp, global->infile?(global->infile->fp?global->line:file->line):0, severity);
if(global->error)
global->error(global->userdata, ErrorMessage[error], arg);
#if defined(UNIX)
@ -1094,15 +1120,15 @@ void domsg(struct Global *global,
else
return;
#endif
Error(global, "\n");
fpp_Error(global, "\n");
if (file) /*OIS*0.92*/
while ((file = file->parent) != NULL) { /* Print #includes, too */
tp = file->parent ? "," : ".";
if (file->fp == NULL)
Error(global, " from macro %s%s\n", file->filename, tp);
fpp_Error(global, " from macro %s%s\n", file->filename, tp);
else
Error(global, " from file %s, line %d%s\n",
fpp_Error(global, " from file %s, line %d%s\n",
(file->progname != NULL) ? file->progname : file->filename,
file->line, tp);
}
@ -1112,7 +1138,7 @@ void domsg(struct Global *global,
global->errors++;
}
void cerror(struct Global *global,
void fpp_cerror(struct Global *global,
ErrorCode message,
...) /* arguments */
{
@ -1121,10 +1147,10 @@ void cerror(struct Global *global,
*/
va_list arg;
va_start(arg, message);
domsg(global, message, arg);
fpp_domsg(global, message, arg);
}
void Error(struct Global *global, char *format, ...)
void fpp_Error(struct Global *global, char *format, ...)
{
/*
* Just get the arguments and send a decent string to the user error

View File

@ -67,7 +67,7 @@ struct Global {
int errors; /* cpp error counter */
FILEINFO *infile; /* Current input file */
#if DEBUG
int debug; /* TRUE if debugging now */
int debug; /* FPP_TRUE if debugging now */
#endif
/*
* This counter is incremented when a macro expansion is initiated.
@ -83,7 +83,7 @@ struct Global {
int rec_recover; /* Unwind recursive macros */
/*
* instring is set TRUE when a string is scanned. It modifies the
* instring is set FPP_TRUE when a string is scanned. It modifies the
* behavior of the "get next character" routine, causing all characters
* to be passed to the caller (except <DEF_MAGIC>). Note especially that
* comments and \<newline> are not removed from the source. (This
@ -95,17 +95,17 @@ struct Global {
* shouldn't delimit tokens, but we'll worry about that some other
* time -- it is more important to prevent infinitly long output lines.
*
* instring and inmarcor are parameters to the get() routine which
* instring and inmarcor are parameters to the fpp_get() routine which
* were made global for speed.
*/
int instring; /* TRUE if scanning string */
int inmacro; /* TRUE if #defining a macro */
int instring; /* FPP_TRUE if scanning string */
int inmacro; /* FPP_TRUE if #defining a macro */
/*
* work[] and workp are used to store one piece of text in a temporay
* buffer. To initialize storage, set workp = work. To store one
* character, call save(c); (This will fatally exit if there isn't
* room.) To terminate the string, call save(EOS). Note that
* character, call fpp_save(c); (This will fatally exit if there isn't
* room.) To terminate the string, call fpp_save(EOS). Note that
* the work buffer is used by several subroutines -- be sure your
* data won't be overwritten. The extra byte in the allocation is
* needed for string formal replacement.
@ -114,7 +114,7 @@ struct Global {
char *workp; /* Work buffer pointer */
/*
* keepcomments is set TRUE by the -C option. If TRUE, comments
* keepcomments is set FPP_TRUE by the -C option. If FPP_TRUE, comments
* are written directly to the output stream. This is needed if
* the output from cpp is to be passed to lint (which uses commands
* embedded in comments). cflag contains the permanent state of the
@ -138,10 +138,10 @@ struct Global {
* ifstack[] holds information about nested #if's. It is always
* accessed via *ifptr. The information is as follows:
* WAS_COMPILING state of compiling flag at outer level.
* ELSE_SEEN set TRUE when #else seen to prevent 2nd #else.
* TRUE_SEEN set TRUE when #if or #elif succeeds
* ifstack[0] holds the compiling flag. It is TRUE if compilation
* is currently enabled. Note that this must be initialized TRUE.
* ELSE_SEEN set FPP_TRUE when #else seen to prevent 2nd #else.
* FPP_TRUE_SEEN set FPP_TRUE when #if or #elif succeeds
* ifstack[0] holds the compiling flag. It is FPP_TRUE if compilation
* is currently enabled. Note that this must be initialized FPP_TRUE.
*/
char ifstack[BLK_NEST]; /* #if information */
char *ifptr; /* -> current ifstack[] */
@ -158,7 +158,7 @@ struct Global {
*/
char *include[NINCLUDE];
char includeshow[NINCLUDE]; /* show it or not! */
char included;
unsigned included;
/*
* This is the table used to predefine target machine and operating
@ -176,7 +176,7 @@ struct Global {
/*
* This is the variable saying if Cpp should remove C++ style comments from
* the output. Default is... TRUE, yes, pronto, do it!!!
* the output. Default is... FPP_TRUE, yes, pronto, do it!!!
*/
char cplusplus;
@ -197,7 +197,7 @@ struct Global {
DEFBUF *symtab[SBSIZE]; /* Symbol table queue headers */
int evalue; /* Current value from evallex() */
int evalue; /* Current value from fpp_evallex() */
void (*depends)(char *filename, void *); /* depends function */
@ -225,7 +225,7 @@ struct Global {
char showspace; /* display all whitespaces as they are */
char comment; /* TRUE if a comment just has been written to output */
char comment; /* FPP_TRUE if a comment just has been written to output */
char *spacebuf; /* Buffer to store whitespaces in if -H */
@ -242,7 +242,7 @@ struct Global {
char out; /* should we output anything now? */
char rightconcat; /* should the right part of a concatenation be avaluated
before the concat (TRUE) or after (FALSE) */
before the concat (FPP_TRUE) or after (FPP_FALSE) */
char *initialfunc; /* file to include first in all functions */
char *excludedinit[20]; /* functions (names) excluded from the initfunc */
@ -251,6 +251,10 @@ struct Global {
char outputfunctions; /* output all discovered functions to stderr! */
char webmode; /* WWW process mode */
char allowincludelocal;
FILE* (*openfile)(char *,char *, void *);
};
typedef enum {
@ -359,55 +363,56 @@ typedef enum {
} ReturnCode;
/* Nasty defines to make them appear as three different functions! */
#define cwarn cerror
#define cfatal cerror
#define fpp_cwarn fpp_cerror
#define fpp_cfatal fpp_cerror
/**********************************************************************
* PROTOTYPES:
*********************************************************************/
int PREFIX fppPreProcess(REG(a0) struct fppTag *);
void Freemem(void *);
void Error(struct Global *, char *, ...);
void Putchar(struct Global *, int);
void Putstring(struct Global *, char *);
void Putint(struct Global *, int);
char *savestring(struct Global *, char *);
ReturnCode addfile(struct Global *, FILE *, char *);
int catenate(struct Global *, ReturnCode *);
void cerror(struct Global *, ErrorCode, ...);
ReturnCode control(struct Global *, int *);
ReturnCode dodefine(struct Global *);
int dooptions(struct Global *, struct fppTag *);
void doundef(struct Global *);
void dumpparm(char *);
ReturnCode expand(struct Global *, DEFBUF *);
int get(struct Global *);
ReturnCode initdefines(struct Global *);
void outdefines(struct Global *);
ReturnCode save(struct Global *, int);
void scanid(struct Global *, int);
ReturnCode scannumber(struct Global *, int, ReturnCode(*)(struct Global *, int));
ReturnCode scanstring(struct Global *, int, ReturnCode(*)(struct Global *, int));
void unget(struct Global *);
ReturnCode ungetstring(struct Global *, char *);
ReturnCode eval(struct Global *, int *);
void fpp_Freemem(void *);
void fpp_Error(struct Global *, char *, ...);
void fpp_Putchar(struct Global *, int);
void fpp_Putstring(struct Global *, char *);
void fpp_Putint(struct Global *, int);
char *fpp_savestring(struct Global *, char *);
ReturnCode fpp_addfile(struct Global *, FILE *, char *);
int fpp_catenate(struct Global *, int lhs_number, ReturnCode *);
void fpp_cerror(struct Global *, ErrorCode, ...);
ReturnCode fpp_control(struct Global *, int *);
ReturnCode fpp_dodefine(struct Global *);
int fpp_dooptions(struct Global *, struct fppTag *);
void fpp_doundef(struct Global *);
void fpp_dumpparm(char *);
ReturnCode fpp_expand(struct Global *, DEFBUF *);
int fpp_get(struct Global *);
ReturnCode fpp_initdefines(struct Global *);
void fpp_outdefines(struct Global *);
ReturnCode fpp_save(struct Global *, int);
void fpp_scanid(struct Global *, int);
ReturnCode fpp_scannumber(struct Global *, int, ReturnCode(*)(struct Global *, int));
ReturnCode fpp_scanstring(struct Global *, int, ReturnCode(*)(struct Global *, int));
void fpp_unget(struct Global *);
ReturnCode fpp_ungetstring(struct Global *, char *);
ReturnCode fpp_eval(struct Global *, int *);
#ifdef DEBUG_EVAL
void dumpstack(OPTAB[NEXP], register OPTAB *, int [NEXP], register int *);
void fpp_dumpstack(OPTAB[NEXP], register OPTAB *, int [NEXP], register int *);
#endif
void skipnl(struct Global *);
int skipws(struct Global *);
ReturnCode macroid(struct Global *, int *);
ReturnCode getfile(struct Global *, size_t, char *, FILEINFO **);
DEFBUF *lookid(struct Global *, int );
DEFBUF *defendel(struct Global *, char *, int);
void fpp_skipnl(struct Global *);
int fpp_skipws(struct Global *);
ReturnCode fpp_macroid(struct Global *, int *);
ReturnCode fpp_getfile(struct Global *, size_t, char *, FILEINFO **);
DEFBUF *fpp_lookid(struct Global *, int );
DEFBUF *fpp_defendel(struct Global *, char *, int);
#if DEBUG
void dumpdef(char *);
void dumpadef(char *, register DEFBUF *);
void fpp_dumpdef(char *);
void fpp_dumpadef(char *, register DEFBUF *);
#endif
ReturnCode openfile(struct Global *,char *);
int cget(struct Global *);
void deldefines(struct Global *);
char *Getmem(struct Global *, int);
ReturnCode openinclude(struct Global *, char *, int);
ReturnCode expstuff(struct Global *, char *, char *);
ReturnCode fpp_openfile(struct Global *,char *);
int fpp_cget(struct Global *);
void fpp_delbuiltindefines(struct Global *);
void fpp_delalldefines(struct Global *);
char *fpp_Getmem(struct Global *, int);
ReturnCode fpp_openinclude(struct Global *, char *, int);
ReturnCode fpp_expstuff(struct Global *, char *, char *);

View File

@ -35,9 +35,9 @@
/* Convert Emacs's conventions for BIG_ENDIAN to cpp's convention. */
#ifdef BIG_ENDIAN
#undef BIG_ENDIAN
#define BIG_ENDIAN TRUE
#define BIG_ENDIAN FPP_TRUE
#else /* not BIG_ENDIAN */
#define BIG_ENDIAN FALSE
#define BIG_ENDIAN FPP_FALSE
#endif /* BIG_ENDIAN */
/* Emacs uses the names index and rindex and defines them as str(r)chr if nec;
@ -73,12 +73,12 @@
*/
/*
* This redundant definition of TRUE and FALSE works around
* This redundant definition of FPP_TRUE and FPP_FALSE works around
* a limitation of Decus C.
*/
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#ifndef FPP_TRUE
#define FPP_TRUE 1
#define FPP_FALSE 0
#endif
/*
@ -134,27 +134,27 @@
* to be marked "static" even though they are referenced
* by "extern" statements elsewhere.
*
* OK_DOLLAR Should be set TRUE if $ is a valid alphabetic character
* OK_DOLLAR Should be set FPP_TRUE if $ is a valid alphabetic character
* in identifiers (default), or zero if $ is invalid.
* Default is TRUE.
* Default is FPP_TRUE.
*
* OK_CONCAT Should be set TRUE if # may be used to concatenate
* OK_CONCAT Should be set FPP_TRUE if # may be used to concatenate
* tokens in macros (per the Ansi Draft Standard) or
* FALSE for old-style # processing (needed if cpp is
* FPP_FALSE for old-style # processing (needed if cpp is
* to process assembler source code).
*/
#define OK_CONCAT TRUE
#define OK_CONCAT FPP_TRUE
/*
* OK_DATE Predefines the compilation date if set TRUE.
* OK_DATE Predefines the compilation date if set FPP_TRUE.
* Not permitted by the Nov. 12, 1984 Draft Standard.
*/
#define OK_DATE TRUE
#define OK_DATE FPP_TRUE
/*
*
* OK_SIZEOF Permits sizeof in #if preprocessor expressions.
* According to K&R V2 (page 232), this is not allowed.
*/
#define OK_SIZEOF TRUE
#define OK_SIZEOF FPP_TRUE
/*
* S_CHAR etc. Define the sizeof the basic TARGET machine word types.
* By default, sizes are set to the values for the HOST
@ -188,9 +188,9 @@
*/
#if OLD_PREPROCESSOR
#define OK_DOLLAR FALSE
#define OK_CONCAT FALSE
#define COMMENT_INVISIBLE TRUE
#define OK_DOLLAR FPP_FALSE
#define OK_CONCAT FPP_FALSE
#define COMMENT_INVISIBLE FPP_TRUE
#endif
/*
@ -209,15 +209,15 @@
#endif
/*
* BIG_ENDIAN is set TRUE on machines (such as the IBM 360 series)
* BIG_ENDIAN is set FPP_TRUE on machines (such as the IBM 360 series)
* where 'ab' stores 'a' in the high-bits and 'b' in the low-bits.
* It is set FALSE on machines (such as the PDP-11 and Vax-11)
* It is set FPP_FALSE on machines (such as the PDP-11 and Vax-11)
* where 'ab' stores 'a' in the low-bits and 'b' in the high-bits.
* (Or is it the other way around?) -- Warning: BIG_ENDIAN code is untested.
* [I *seems* to be the other way around, according to the code /OIS]
*/
#ifndef BIG_ENDIAN
#define BIG_ENDIAN FALSE
#define BIG_ENDIAN FPP_FALSE
#endif
/*
@ -227,27 +227,27 @@
* expansions. This was removed from the Draft Ansi Standard.
*/
#ifndef COMMENT_INVISIBLE
#define COMMENT_INVISIBLE FALSE
#define COMMENT_INVISIBLE FPP_FALSE
#endif
/*
* OK_DOLLAR enables use of $ as a valid "letter" in identifiers.
* This is a permitted extension to the Ansi Standard and is required
* for e.g., VMS, RSX-11M, etc. It should be set FALSE if cpp is
* for e.g., VMS, RSX-11M, etc. It should be set FPP_FALSE if cpp is
* used to preprocess assembler source on Unix systems. OLD_PREPROCESSOR
* sets OK_DOLLAR FALSE for that reason.
* sets OK_DOLLAR FPP_FALSE for that reason.
*/
#ifndef OK_DOLLAR
#define OK_DOLLAR TRUE
#define OK_DOLLAR FPP_TRUE
#endif
/*
* OK_CONCAT enables (one possible implementation of) token concatenation.
* If cpp is used to preprocess Unix assembler source, this should be
* set FALSE as the concatenation character, #, is used by the assembler.
* set FPP_FALSE as the concatenation character, #, is used by the assembler.
*/
#ifndef OK_CONCAT
#define OK_CONCAT TRUE
#define OK_CONCAT FPP_TRUE
#endif
/*
@ -256,7 +256,7 @@
* by the Draft Ansi Standard.
*/
#ifndef OK_DATE
#define OK_DATE TRUE
#define OK_DATE FPP_TRUE
#endif
/*
@ -267,7 +267,7 @@
* This option was added in the PDC process, under no. *OIS*0.92*.
*/
#ifndef OK_SIZEOF
#define OK_SIZEOF FALSE
#define OK_SIZEOF FPP_FALSE
#endif
/*
@ -275,7 +275,7 @@
*/
#ifndef DEBUG
#define DEBUG FALSE
#define DEBUG FPP_FALSE
#endif
/*

View File

@ -35,18 +35,21 @@
*
*/
#ifdef __cplusplus
extern "C" {
#endif
struct fppTag {
int tag;
void *data;
};
#ifndef TRUE
#define TRUE 1
#ifndef FPP_TRUE
#define FPP_TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#ifndef FPP_FALSE
#define FPP_FALSE 0
#endif
#define NFLAG_BUILTIN 1
@ -56,26 +59,26 @@ struct fppTag {
#define FPPTAG_END 0
/* To make the preprocessed output keep the comments: */
#define FPPTAG_KEEPCOMMENTS 1 /* data is TRUE or FALSE */
#define FPPTAG_KEEPCOMMENTS 1 /* data is FPP_TRUE or FPP_FALSE */
/* To define symbols to the preprocessor: */
#define FPPTAG_DEFINE 2 /* data is the string "symbol" or "symbol=<value>" */
/* To make the preprocessor ignore all non-fatal errors: */
#define FPPTAG_IGNORE_NONFATAL 3 /* data is TRUE or FALSE */
#define FPPTAG_IGNORE_NONFATAL 3 /* data is FPP_TRUE or FPP_FALSE */
/* To add an include directory to the include directory list: */
#define FPPTAG_INCLUDE_DIR 4 /* data is directory name ending with a '/' (on
amiga a ':' is also valid) */
/* To define all machine specific built-in #defines, default is TRUE: */
#define FPPTAG_BUILTINS 5 /* data is TRUE or FALSE */
/* To define all machine specific built-in #defines, default is FPP_TRUE: */
#define FPPTAG_BUILTINS 5 /* data is FPP_TRUE or FPP_FALSE */
/* To define predefines like __LINE__, __DATE__, etc. default is TRUE: */
#define FPPTAG_PREDEFINES 6 /* data is TRUE or FALSE */
/* To define predefines like __LINE__, __DATE__, etc. default is FPP_TRUE: */
#define FPPTAG_PREDEFINES 6 /* data is FPP_TRUE or FPP_FALSE */
/* To make fpp leave C++ comments in the output: */
#define FPPTAG_IGNORE_CPLUSPLUS 7 /* data is TRUE or FALSE */
#define FPPTAG_IGNORE_CPLUSPLUS 7 /* data is FPP_TRUE or FPP_FALSE */
/* To define new sizes to #if sizeof: */
#define FPPTAG_SIZEOF_TABLE 8 /* data is sizeof table string */
@ -84,7 +87,7 @@ struct fppTag {
#define FPPTAG_UNDEFINE 9 /* data is symbol name */
/* Output all #defines: */
#define FPPTAG_OUTPUT_DEFINES 10 /* data is TRUE or FALSE */
#define FPPTAG_OUTPUT_DEFINES 10 /* data is FPP_TRUE or FPP_FALSE */
/* Initial input file name: */
#define FPPTAG_INPUT_NAME 11 /* data is string */
@ -98,42 +101,42 @@ struct fppTag {
/* User data, sent in the last argument to the input function: */
#define FPPTAG_USERDATA 14 /* data is user data */
/* Whether to exclude #line instructions in the output, default is FALSE */
#define FPPTAG_LINE 15 /* data is TRUE or FALSE */
/* Whether to exclude #line instructions in the output, default is FPP_FALSE */
#define FPPTAG_LINE 15 /* data is FPP_TRUE or FPP_FALSE */
/* Error function. This is called when FPP finds any warning/error/fatal: */
#define FPPTAG_ERROR 16 /* data is function pointer to a
"void (*)(void *, char *, va_list)" */
/* Whether to warn for illegal cpp instructions */
#define FPPTAG_WARNILLEGALCPP 17 /* data is boolean, default is FALSE */
#define FPPTAG_WARNILLEGALCPP 17 /* data is boolean, default is FPP_FALSE */
/* Output the 'line' keyword on #line-lines? */
#define FPPTAG_OUTPUTLINE 18 /* data is boolean, default is TRUE */
#define FPPTAG_OUTPUTLINE 18 /* data is boolean, default is FPP_TRUE */
/* Do not output the version information string */
#define FPPTAG_IGNOREVERSION 19 /* data is boolean, default is FALSE */
/* Output the version information string */
#define FPPTAG_SHOWVERSION 19 /* data is boolean, default is FPP_TRUE */
/* Output all included file names to stderr */
#define FPPTAG_OUTPUTINCLUDES 20 /* data is boolean, default is FALSE */
#define FPPTAG_OUTPUTINCLUDES 20 /* data is boolean, default is FPP_FALSE */
/* Display warning if there is any brace, bracket or parentheses unbalance */
#define FPPTAG_OUTPUTBALANCE 21 /* data is boolean, default is FALSE */
#define FPPTAG_OUTPUTBALANCE 21 /* data is boolean, default is FPP_FALSE */
/* Display all whitespaces in the source */
#define FPPTAG_OUTPUTSPACE 22 /* data is boolean, default is FALSE */
#define FPPTAG_OUTPUTSPACE 22 /* data is boolean, default is FPP_FALSE */
/* Allow nested comments */
#define FPPTAG_NESTED_COMMENTS 23 /* data is boolean, default is FALSE */
#define FPPTAG_NESTED_COMMENTS 23 /* data is boolean, default is FPP_FALSE */
/* Enable warnings at nested comments */
#define FPPTAG_WARN_NESTED_COMMENTS 24 /* data is boolean, default is FALSE */
#define FPPTAG_WARN_NESTED_COMMENTS 24 /* data is boolean, default is FPP_FALSE */
/* Enable warnings at missing includes */
#define FPPTAG_WARNMISSINCLUDE 25 /* data is boolean, default is TRUE */
#define FPPTAG_WARNMISSINCLUDE 25 /* data is boolean, default is FPP_TRUE */
/* Output the main file */
#define FPPTAG_OUTPUTMAIN 26 /* data is boolean, default is TRUE */
#define FPPTAG_OUTPUTMAIN 26 /* data is boolean, default is FPP_TRUE */
/* Include file */
#define FPPTAG_INCLUDE_FILE 27 /* data is char pointer */
@ -142,7 +145,7 @@ struct fppTag {
#define FPPTAG_INCLUDE_MACRO_FILE 28 /* data is char pointer */
/* Evaluate the right part of a concatenate before the concat */
#define FPPTAG_RIGHTCONCAT 29 /* data is boolean, default is FALSE */
#define FPPTAG_RIGHTCONCAT 29 /* data is boolean, default is FPP_FALSE */
/* Include the specified file at the beginning of each function */
#define FPPTAG_INITFUNC 30 /* data is char pointer or NULL */
@ -159,4 +162,15 @@ struct fppTag {
/* Depends function: */
#define FPPTAG_DEPENDS 34 /* data is an depends funtion */
/* Allow include "X" (rather than <X>) to search local files, default is FPP_TRUE */
#define FPPTAG_ALLOW_INCLUDE_LOCAL 35
/* Fileopen function. If set, this is called when FPP tries to open a file: */
#define FPPTAG_FILEOPENFUNC 36 /* data is function pointer to a
"FILE* (*)(char * filename, char * mode, void * userdata)", default is NULL */
int fppPreProcess(struct fppTag *);
#ifdef __cplusplus
} // extern "C"
#endif

View File

@ -128,8 +128,8 @@ FILE_LOCAL char DoString(struct fppTag **, char *);
extern long __stack=8000;
#endif
FILE_LOCAL char ignore=FALSE; /* if we should ignore strange flags! */
FILE_LOCAL char display=FALSE; /* display all options in use! */
FILE_LOCAL char ignore=FPP_FALSE; /* if we should ignore strange flags! */
FILE_LOCAL char display=FPP_FALSE; /* display all options in use! */
FILE_LOCAL char dontreadprefs; /* set if only the command line is valid */
@ -369,37 +369,37 @@ int SetOptions(int argc, char **argv, struct fppTag **tagptr)
case 'H': /* display all whitespaces */
(*tagptr)->tag = FPPTAG_OUTPUTSPACE;
(*tagptr)->data= (void *)TRUE;
(*tagptr)->data= (void *)FPP_TRUE;
(*tagptr)++;
break;
case 'b': /* display unbalance */
(*tagptr)->tag = FPPTAG_OUTPUTBALANCE;
(*tagptr)->data= (void *)TRUE;
(*tagptr)->data= (void *)FPP_TRUE;
(*tagptr)++;
break;
case 'f': /* output all defined functions! */
(*tagptr)->tag = FPPTAG_DISPLAYFUNCTIONS;
(*tagptr)->data= (void *)TRUE;
(*tagptr)->data= (void *)FPP_TRUE;
(*tagptr)++;
break;
case 'F': /* output all included files! */
(*tagptr)->tag = FPPTAG_OUTPUTINCLUDES;
(*tagptr)->data= (void *)TRUE;
(*tagptr)->data= (void *)FPP_TRUE;
(*tagptr)++;
break;
case 'V': /* do not output version */
(*tagptr)->tag = FPPTAG_IGNOREVERSION;
(*tagptr)->data= (void *)FALSE;
(*tagptr)->tag = FPPTAG_SHOWVERSION;
(*tagptr)->data= (void *)FPP_FALSE;
(*tagptr)++;
break;
case 'C': /* Keep comments */
(*tagptr)->tag = FPPTAG_KEEPCOMMENTS;
(*tagptr)->data= (void *)TRUE;
(*tagptr)->data= (void *)FPP_TRUE;
(*tagptr)++;
break;
@ -411,12 +411,12 @@ int SetOptions(int argc, char **argv, struct fppTag **tagptr)
case 'd': /* Display all options */
fprintf(stderr, "FOUND -d flag!\n");
display = TRUE;
display = FPP_TRUE;
break;
case 'E': /* Ignore non-fatal errors */
(*tagptr)->tag=FPPTAG_IGNORE_NONFATAL;
(*tagptr)->data=(void *)TRUE;
(*tagptr)->data=(void *)FPP_TRUE;
(*tagptr)++;
break;
@ -445,13 +445,13 @@ int SetOptions(int argc, char **argv, struct fppTag **tagptr)
/* Do not output the 'line' keyword */
(*tagptr)->tag=FPPTAG_OUTPUTLINE;
}
(*tagptr)->data=(void *)FALSE;
(*tagptr)->data=(void *)FPP_FALSE;
(*tagptr)++;
break;
case 'M': /* Do not warn at missing includes */
(*tagptr)->tag=FPPTAG_WARNMISSINCLUDE;
(*tagptr)->data=(void *)FALSE;
(*tagptr)->data=(void *)FPP_FALSE;
(*tagptr)++;
break;
@ -466,31 +466,31 @@ int SetOptions(int argc, char **argv, struct fppTag **tagptr)
case 'N': /* No machine specific built-ins */
(*tagptr)->tag=FPPTAG_BUILTINS;
(*tagptr)->data=(void *)FALSE;
(*tagptr)->data=(void *)FPP_FALSE;
(*tagptr)++;
break;
case 'B': /* No predefines like __LINE__, etc. */
(*tagptr)->tag=FPPTAG_PREDEFINES;
(*tagptr)->data=(void *)FALSE;
(*tagptr)->data=(void *)FPP_FALSE;
(*tagptr)++;
break;
case 'P': /* No C++ comments */
(*tagptr)->tag=FPPTAG_IGNORE_CPLUSPLUS;
(*tagptr)->data=(void *)TRUE;
(*tagptr)->data=(void *)FPP_TRUE;
(*tagptr)++;
break;
case 'p': /* warn about illegal # - instructions */
(*tagptr)->tag = FPPTAG_WARNILLEGALCPP;
(*tagptr)->data= (void *)TRUE;
(*tagptr)->data= (void *)FPP_TRUE;
(*tagptr)++;
break;
case 'R':
(*tagptr)->tag = FPPTAG_RIGHTCONCAT;
(*tagptr)->data= (void *)TRUE;
(*tagptr)->data= (void *)FPP_TRUE;
(*tagptr)++;
break;
@ -521,18 +521,18 @@ int SetOptions(int argc, char **argv, struct fppTag **tagptr)
case 'w': /* Output all #defines but not the
main file */
(*tagptr)->tag=FPPTAG_OUTPUTMAIN;
(*tagptr)->data=(void *)FALSE;
(*tagptr)->data=(void *)FPP_FALSE;
(*tagptr)++;
case 'W': /* Output all #defines */
if(!strncmp(ap, "WW", 2)) {
(*tagptr)->tag=FPPTAG_WEBMODE;
(*tagptr)->data=(void *)TRUE;
(*tagptr)->data=(void *)FPP_TRUE;
(*tagptr)++;
}
else {
(*tagptr)->tag=FPPTAG_OUTPUT_DEFINES;
(*tagptr)->data=(void *)TRUE;
(*tagptr)->data=(void *)FPP_TRUE;
(*tagptr)++;
}
break;

View File

@ -14,18 +14,14 @@
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include <stdint.h>
#include <assert.h>
#include <math.h>
#include <vector>
#include <limits>
#include <algorithm>
namespace Forsyth
{
typedef unsigned int uint;
typedef unsigned short uint16;
typedef unsigned char byte;
//-----------------------------------------------------------------------------
// OptimizeFaces
//-----------------------------------------------------------------------------
@ -36,13 +32,27 @@ namespace Forsyth
// the number of indices in the list
// vertexCount
// the largest index value in indexList
// vertexBaseIndex
// starting vertex index subtracted from each index in indexList to
// allow safe operation on multiple objects in a single index buffer
// newIndexList
// a pointer to a preallocated buffer the same size as indexList to
// hold the optimized index list
// lruCacheSize
// the size of the simulated post-transform cache (max:64)
//-----------------------------------------------------------------------------
void OptimizeFaces(const uint16* indexList, uint indexCount, uint vertexCount, uint16* newIndexList, uint16 lruCacheSize);
template<class IndexT>
void OptimizeFacesImpl(const IndexT* indexList, uint32_t indexCount, uint32_t vertexCount, IndexT vertexBaseIndex, IndexT* newIndexList, uint16_t lruCacheSize);
void OptimizeFaces(const uint16_t* indexList, uint32_t indexCount, uint32_t vertexCount, uint16_t vertexBaseIndex, uint16_t* newIndexList, uint16_t lruCacheSize)
{
OptimizeFacesImpl<uint16_t>( indexList, indexCount, vertexCount, vertexBaseIndex, newIndexList, lruCacheSize );
}
void OptimizeFaces(const uint32_t* indexList, uint32_t indexCount, uint32_t vertexCount, uint32_t vertexBaseIndex, uint32_t* newIndexList, uint16_t lruCacheSize)
{
OptimizeFacesImpl<uint32_t>( indexList, indexCount, vertexCount, vertexBaseIndex, newIndexList, lruCacheSize );
}
namespace
{
@ -82,7 +92,7 @@ namespace Forsyth
return score;
}
float ComputeVertexValenceScore(uint numActiveFaces)
float ComputeVertexValenceScore(uint32_t numActiveFaces)
{
const float FindVertexScore_ValenceBoostScale = 2.0f;
const float FindVertexScore_ValenceBoostPower = 0.5f;
@ -100,7 +110,7 @@ namespace Forsyth
const int kMaxVertexCacheSize = 64;
const uint kMaxPrecomputedVertexValenceScores = 64;
const uint32_t kMaxPrecomputedVertexValenceScores = 64;
float s_vertexCacheScores[kMaxVertexCacheSize+1][kMaxVertexCacheSize];
float s_vertexValenceScores[kMaxPrecomputedVertexValenceScores];
@ -114,7 +124,7 @@ namespace Forsyth
}
}
for (uint valence=0; valence<kMaxPrecomputedVertexValenceScores; ++valence)
for (uint32_t valence=0; valence<kMaxPrecomputedVertexValenceScores; ++valence)
{
s_vertexValenceScores[valence] = ComputeVertexValenceScore(valence);
}
@ -133,7 +143,7 @@ namespace Forsyth
// return s_vertexValenceScores[numActiveTris];
// }
float FindVertexScore(uint numActiveFaces, uint cachePosition, uint vertexCacheSize)
float FindVertexScore(uint32_t numActiveFaces, uint32_t cachePosition, uint32_t vertexCacheSize)
{
assert(s_vertexScoresComputed); (void)s_vertexScoresComputed;
@ -163,37 +173,38 @@ namespace Forsyth
struct OptimizeVertexData
{
float score;
uint activeFaceListStart;
uint activeFaceListSize;
uint16 cachePos0;
uint16 cachePos1;
float score;
uint32_t activeFaceListStart;
uint32_t activeFaceListSize;
uint16_t cachePos0;
uint16_t cachePos1;
OptimizeVertexData() : score(0.f), activeFaceListStart(0), activeFaceListSize(0), cachePos0(0), cachePos1(0) { }
};
}
void OptimizeFaces(const uint16* indexList, uint indexCount, uint vertexCount, uint16* newIndexList, uint16 lruCacheSize)
template<class IndexT>
void OptimizeFacesImpl(const IndexT* indexList, uint32_t indexCount, uint32_t vertexCount, IndexT vertexBaseIndex, IndexT* newIndexList, uint16_t lruCacheSize)
{
std::vector<OptimizeVertexData> vertexDataList;
std::vector< OptimizeVertexData > vertexDataList;
vertexDataList.resize(vertexCount);
// compute face count per vertex
for (uint i=0; i<indexCount; ++i)
for (uint32_t i=0; i<indexCount; ++i)
{
uint16 index = indexList[i];
assert(index < vertexCount);
IndexT index = indexList[i] - vertexBaseIndex;
assert((index >= 0) && (index < vertexCount));
OptimizeVertexData& vertexData = vertexDataList[index];
vertexData.activeFaceListSize++;
}
std::vector<uint> activeFaceList;
std::vector<uint32_t> activeFaceList;
const uint16 kEvictedCacheIndex = std::numeric_limits<uint16>::max();
const IndexT kEvictedCacheIndex = std::numeric_limits<uint16_t>::max();
{
// allocate face list per vertex
uint curActiveFaceListPos = 0;
for (uint i=0; i<vertexCount; ++i)
uint32_t curActiveFaceListPos = 0;
for (uint32_t i=0; i<vertexCount; ++i)
{
OptimizeVertexData& vertexData = vertexDataList[i];
vertexData.cachePos0 = kEvictedCacheIndex;
@ -207,45 +218,45 @@ namespace Forsyth
}
// fill out face list per vertex
for (uint i=0; i<indexCount; i+=3)
for (uint32_t i=0; i<indexCount; i+=3)
{
for (uint j=0; j<3; ++j)
for (uint32_t j=0; j<3; ++j)
{
uint16 index = indexList[i+j];
IndexT index = indexList[i+j] - vertexBaseIndex;
OptimizeVertexData& vertexData = vertexDataList[index];
activeFaceList[vertexData.activeFaceListStart + vertexData.activeFaceListSize] = i;
vertexData.activeFaceListSize++;
}
}
std::vector<byte> processedFaceList;
std::vector<uint8_t> processedFaceList;
processedFaceList.resize(indexCount);
uint16 vertexCacheBuffer[(kMaxVertexCacheSize+3)*2];
uint16* cache0 = vertexCacheBuffer;
uint16* cache1 = vertexCacheBuffer+(kMaxVertexCacheSize+3);
uint16 entriesInCache0 = 0;
IndexT vertexCacheBuffer[(kMaxVertexCacheSize+3)*2];
IndexT* cache0 = vertexCacheBuffer;
IndexT* cache1 = vertexCacheBuffer+(kMaxVertexCacheSize+3);
IndexT entriesInCache0 = 0;
uint bestFace = 0;
uint32_t bestFace = 0;
float bestScore = -1.f;
const float maxValenceScore = FindVertexScore(1, kEvictedCacheIndex, lruCacheSize) * 3.f;
for (uint i = 0; i < indexCount; i += 3)
for (uint32_t i = 0; i < indexCount; i += 3)
{
if (bestScore < 0.f)
{
// no verts in the cache are used by any unprocessed faces so
// search all unprocessed faces for a new starting point
for (uint j = 0; j < indexCount; j += 3)
for (uint32_t j = 0; j < indexCount; j += 3)
{
if (processedFaceList[j] == 0)
{
uint face = j;
uint32_t face = j;
float faceScore = 0.f;
for (uint k=0; k<3; ++k)
for (uint32_t k=0; k<3; ++k)
{
uint16 index = indexList[face+k];
IndexT index = indexList[face+k] - vertexBaseIndex;
OptimizeVertexData& vertexData = vertexDataList[index];
assert(vertexData.activeFaceListSize > 0);
assert(vertexData.cachePos0 >= lruCacheSize);
@ -269,13 +280,13 @@ namespace Forsyth
}
processedFaceList[bestFace] = 1;
uint16 entriesInCache1 = 0;
uint16_t entriesInCache1 = 0;
// add bestFace to LRU cache and to newIndexList
for (uint v = 0; v < 3; ++v)
for (uint32_t v = 0; v < 3; ++v)
{
uint16 index = indexList[bestFace+v];
newIndexList[i+v] = index;
IndexT index = indexList[bestFace+v] - vertexBaseIndex;
newIndexList[i+v] = index + vertexBaseIndex;
OptimizeVertexData& vertexData = vertexDataList[index];
@ -292,9 +303,9 @@ namespace Forsyth
}
assert(vertexData.activeFaceListSize > 0);
uint* begin = &activeFaceList[vertexData.activeFaceListStart];
uint* end = &(activeFaceList[vertexData.activeFaceListStart + vertexData.activeFaceListSize - 1]) + 1;
uint* it = std::find(begin, end, bestFace);
uint32_t* begin = &activeFaceList[vertexData.activeFaceListStart];
uint32_t* end = &(activeFaceList[vertexData.activeFaceListStart + vertexData.activeFaceListSize - 1]) + 1;
uint32_t* it = std::find(begin, end, bestFace);
assert(it != end);
std::swap(*it, *(end-1));
--vertexData.activeFaceListSize;
@ -303,9 +314,9 @@ namespace Forsyth
}
// move the rest of the old verts in the cache down and compute their new scores
for (uint c0 = 0; c0 < entriesInCache0; ++c0)
for (uint32_t c0 = 0; c0 < entriesInCache0; ++c0)
{
uint16 index = cache0[c0];
IndexT index = cache0[c0];
OptimizeVertexData& vertexData = vertexDataList[index];
if (vertexData.cachePos1 >= entriesInCache1)
@ -318,19 +329,19 @@ namespace Forsyth
// find the best scoring triangle in the current cache (including up to 3 that were just evicted)
bestScore = -1.f;
for (uint c1 = 0; c1 < entriesInCache1; ++c1)
for (uint32_t c1 = 0; c1 < entriesInCache1; ++c1)
{
uint16 index = cache1[c1];
IndexT index = cache1[c1];
OptimizeVertexData& vertexData = vertexDataList[index];
vertexData.cachePos0 = vertexData.cachePos1;
vertexData.cachePos1 = kEvictedCacheIndex;
for (uint j=0; j<vertexData.activeFaceListSize; ++j)
for (uint32_t j=0; j<vertexData.activeFaceListSize; ++j)
{
uint face = activeFaceList[vertexData.activeFaceListStart+j];
uint32_t face = activeFaceList[vertexData.activeFaceListStart+j];
float faceScore = 0.f;
for (uint v=0; v<3; v++)
for (uint32_t v=0; v<3; v++)
{
uint16 faceIndex = indexList[face+v];
IndexT faceIndex = indexList[face+v] - vertexBaseIndex;
OptimizeVertexData& faceVertexData = vertexDataList[faceIndex];
faceScore += faceVertexData.score;
}

View File

@ -21,23 +21,27 @@
namespace Forsyth
{
//-----------------------------------------------------------------------------
// OptimizeFaces
//-----------------------------------------------------------------------------
// Parameters:
// indexList
// input index list
// indexCount
// the number of indices in the list
// vertexCount
// the largest index value in indexList
// newIndexList
// a pointer to a preallocated buffer the same size as indexList to
// hold the optimized index list
// lruCacheSize
// the size of the simulated post-transform cache (max:64)
//-----------------------------------------------------------------------------
void OptimizeFaces(const uint16_t* indexList, uint32_t indexCount, uint32_t vertexCount, uint16_t* newIndexList, uint16_t lruCacheSize);
//-----------------------------------------------------------------------------
// OptimizeFaces
//-----------------------------------------------------------------------------
// Parameters:
// indexList
// input index list
// indexCount
// the number of indices in the list
// vertexCount
// the largest index value in indexList
// vertexBaseIndex
// starting vertex index subtracted from each index in indexList to
// allow safe operation on multiple objects in a single index buffer
// newIndexList
// a pointer to a preallocated buffer the same size as indexList to
// hold the optimized index list
// lruCacheSize
// the size of the simulated post-transform cache (max:64)
//-----------------------------------------------------------------------------
void OptimizeFaces(const uint16_t* indexList, uint32_t indexCount, uint32_t vertexCount, uint16_t vertexBaseIndex, uint16_t* newIndexList, uint16_t lruCacheSize);
void OptimizeFaces(const uint32_t* indexList, uint32_t indexCount, uint32_t vertexCount, uint32_t vertexBaseIndex, uint32_t* newIndexList, uint16_t lruCacheSize);
} // namespace Forsyth

File diff suppressed because it is too large Load Diff

View File

@ -170,6 +170,10 @@ struct glslopt_shader
{
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++)
ralloc_free(whole_program->_LinkedShaders[i]);
for(GLuint i =0;i< whole_program->NumShaders;i++)
ralloc_free(whole_program->Shaders[i]);
ralloc_free(whole_program->Shaders);
ralloc_free(whole_program->InfoLog);
ralloc_free(whole_program);
ralloc_free(rawOutput);
ralloc_free(optimizedOutput);

View File

@ -31,8 +31,11 @@ matrix:
# scripts that run after cloning repository
install:
- git clone https://github.com/google/googletest.git External/googletest
- C:/Python27/python.exe update_glslang_sources.py
- git clone https://github.com/google/googletest.git External/googletest
- cd External/googletest
- git checkout 440527a61e1c91188195f7de212c63c77e8f0a45
- cd ../..
build:
parallel: true # enable MSBuild parallel builds
@ -40,7 +43,7 @@ build:
build_script:
- mkdir build && cd build
- cmake .. -DCMAKE_INSTALL_PREFIX=install
- cmake -G "Visual Studio 12 2013 Win64" -DCMAKE_INSTALL_PREFIX=install ..
- cmake --build . --config %CONFIGURATION% --target install
test_script:
@ -60,6 +63,7 @@ after_test:
# Zip all glslang artifacts for uploading and deploying
- 7z a glslang-master-windows-"%PLATFORM%"-"%CONFIGURATION%".zip
bin\glslangValidator.exe
bin\spirv-remap.exe
include\glslang\*
include\SPIRV\*
lib\glslang%SUFFIX%.lib

View File

@ -48,12 +48,16 @@ install:
- if [[ "$TRAVIS_OS_NAME" == "linux" && "$CC" == "clang" ]]; then
export CC=clang-3.6 CXX=clang++-3.6;
fi
# Download Android NDK and Android CMake toolchain file.
# Download a recent Android NDK and use its android.toolchain.cmake file.
- if [[ "$BUILD_NDK" == "ON" ]]; then
git clone --depth=1 https://github.com/urho3d/android-ndk.git $HOME/android-ndk;
export ANDROID_NDK=$HOME/android-ndk;
git clone --depth=1 https://github.com/taka-no-me/android-cmake.git $HOME/android-cmake;
export TOOLCHAIN_PATH=$HOME/android-cmake/android.toolchain.cmake;
git init $ANDROID_NDK;
pushd $ANDROID_NDK;
git remote add dneto0 https://github.com/dneto0/android-ndk.git;
git fetch --depth=1 dneto0 r17b-strip;
git checkout FETCH_HEAD;
popd;
export TOOLCHAIN_PATH=$ANDROID_NDK/build/cmake/android.toolchain.cmake;
fi
before_script:
@ -63,10 +67,12 @@ before_script:
script:
- mkdir build && cd build
# For Android, do release building using NDK without testing.
# Use android-14, the oldest native API level supporeted by NDK r17b.
# We can use newer API levels if we want.
# For Linux and macOS, do debug/release building with testing.
- if [[ "$BUILD_NDK" == "ON" ]]; then
cmake -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_PATH}
-DANDROID_NATIVE_API_LEVEL=android-12
-DANDROID_NATIVE_API_LEVEL=android-14
-DCMAKE_BUILD_TYPE=Release
-DANDROID_ABI="armeabi-v7a with NEON"
-DBUILD_TESTING=OFF ..;

View File

@ -0,0 +1,100 @@
LOCAL_PATH := $(call my-dir)
GLSLANG_OS_FLAGS := -DGLSLANG_OSINCLUDE_UNIX
# AMD and NV extensions are turned on by default in upstream Glslang.
GLSLANG_DEFINES:= -DAMD_EXTENSIONS -DNV_EXTENSIONS -DENABLE_HLSL $(GLSLANG_OS_FLAGS)
include $(CLEAR_VARS)
LOCAL_MODULE:=OSDependent
LOCAL_CXXFLAGS:=-std=c++11 -fno-exceptions -fno-rtti $(GLSLANG_DEFINES)
LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH)
LOCAL_SRC_FILES:=glslang/OSDependent/Unix/ossource.cpp
LOCAL_C_INCLUDES:=$(LOCAL_PATH) $(LOCAL_PATH)/glslang/OSDependent/Unix/
LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH)/glslang/OSDependent/Unix/
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE:=OGLCompiler
LOCAL_CXXFLAGS:=-std=c++11 -fno-exceptions -fno-rtti $(GLSLANG_DEFINES)
LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH)
LOCAL_SRC_FILES:=OGLCompilersDLL/InitializeDll.cpp
LOCAL_C_INCLUDES:=$(LOCAL_PATH)/OGLCompiler
LOCAL_STATIC_LIBRARIES:=OSDependent
include $(BUILD_STATIC_LIBRARY)
# Build Glslang's HLSL parser library.
include $(CLEAR_VARS)
LOCAL_MODULE:=HLSL
LOCAL_CXXFLAGS:=-std=c++11 -fno-exceptions -fno-rtti $(GLSLANG_DEFINES)
LOCAL_SRC_FILES:= \
hlsl/hlslAttributes.cpp \
hlsl/hlslGrammar.cpp \
hlsl/hlslOpMap.cpp \
hlsl/hlslParseables.cpp \
hlsl/hlslParseHelper.cpp \
hlsl/hlslScanContext.cpp \
hlsl/hlslTokenStream.cpp
LOCAL_C_INCLUDES:=$(LOCAL_PATH) \
$(LOCAL_PATH)/hlsl
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
GLSLANG_OUT_PATH=$(if $(call host-path-is-absolute,$(TARGET_OUT)),$(TARGET_OUT),$(abspath $(TARGET_OUT)))
LOCAL_MODULE:=glslang
LOCAL_CXXFLAGS:=-std=c++11 -fno-exceptions -fno-rtti $(GLSLANG_DEFINES)
LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH)
LOCAL_SRC_FILES:= \
glslang/GenericCodeGen/CodeGen.cpp \
glslang/GenericCodeGen/Link.cpp \
glslang/MachineIndependent/attribute.cpp \
glslang/MachineIndependent/Constant.cpp \
glslang/MachineIndependent/glslang_tab.cpp \
glslang/MachineIndependent/InfoSink.cpp \
glslang/MachineIndependent/Initialize.cpp \
glslang/MachineIndependent/Intermediate.cpp \
glslang/MachineIndependent/intermOut.cpp \
glslang/MachineIndependent/IntermTraverse.cpp \
glslang/MachineIndependent/iomapper.cpp \
glslang/MachineIndependent/limits.cpp \
glslang/MachineIndependent/linkValidate.cpp \
glslang/MachineIndependent/parseConst.cpp \
glslang/MachineIndependent/ParseContextBase.cpp \
glslang/MachineIndependent/ParseHelper.cpp \
glslang/MachineIndependent/PoolAlloc.cpp \
glslang/MachineIndependent/propagateNoContraction.cpp \
glslang/MachineIndependent/reflection.cpp \
glslang/MachineIndependent/RemoveTree.cpp \
glslang/MachineIndependent/Scan.cpp \
glslang/MachineIndependent/ShaderLang.cpp \
glslang/MachineIndependent/SymbolTable.cpp \
glslang/MachineIndependent/Versions.cpp \
glslang/MachineIndependent/preprocessor/PpAtom.cpp \
glslang/MachineIndependent/preprocessor/PpContext.cpp \
glslang/MachineIndependent/preprocessor/Pp.cpp \
glslang/MachineIndependent/preprocessor/PpScanner.cpp \
glslang/MachineIndependent/preprocessor/PpTokens.cpp
LOCAL_C_INCLUDES:=$(LOCAL_PATH) \
$(LOCAL_PATH)/glslang/MachineIndependent \
$(GLSLANG_OUT_PATH)
LOCAL_STATIC_LIBRARIES:=OSDependent OGLCompiler HLSL
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE:=SPIRV
LOCAL_CXXFLAGS:=-std=c++11 -fno-exceptions -fno-rtti -Werror $(GLSLANG_DEFINES)
LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH)
LOCAL_SRC_FILES:= \
SPIRV/GlslangToSpv.cpp \
SPIRV/InReadableOrder.cpp \
SPIRV/Logger.cpp \
SPIRV/SPVRemapper.cpp \
SPIRV/SpvBuilder.cpp \
SPIRV/SpvPostProcess.cpp \
SPIRV/SpvTools.cpp \
SPIRV/disassemble.cpp \
SPIRV/doc.cpp
LOCAL_C_INCLUDES:=$(LOCAL_PATH) $(LOCAL_PATH)/glslang/SPIRV
LOCAL_EXPORT_C_INCLUDES:=$(LOCAL_PATH)/glslang/SPIRV
LOCAL_STATIC_LIBRARIES:=glslang
include $(BUILD_STATIC_LIBRARY)

153
3rdparty/bgfx/3rdparty/glslang/BUILD.gn vendored Normal file
View File

@ -0,0 +1,153 @@
# Copyright (C) 2018 Google, Inc.
#
# 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 Google Inc. nor the names of its
# 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 HOLDERS 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.
import("//build_overrides/glslang.gni")
spirv_tools_dir = glslang_spirv_tools_dir
config("glslang_public") {
include_dirs = [ "." ]
}
source_set("glslang_sources") {
public_configs = [ ":glslang_public" ]
sources = [
"OGLCompilersDLL/InitializeDll.cpp",
"OGLCompilersDLL/InitializeDll.h",
"SPIRV/GLSL.ext.EXT.h",
"SPIRV/GLSL.ext.KHR.h",
"SPIRV/GLSL.std.450.h",
"SPIRV/GlslangToSpv.cpp",
"SPIRV/GlslangToSpv.h",
"SPIRV/InReadableOrder.cpp",
"SPIRV/Logger.cpp",
"SPIRV/Logger.h",
"SPIRV/SPVRemapper.cpp",
"SPIRV/SPVRemapper.h",
"SPIRV/SpvBuilder.cpp",
"SPIRV/SpvBuilder.h",
"SPIRV/SpvPostProcess.cpp",
"SPIRV/bitutils.h",
"SPIRV/disassemble.cpp",
"SPIRV/disassemble.h",
"SPIRV/doc.cpp",
"SPIRV/doc.h",
"SPIRV/hex_float.h",
"SPIRV/spirv.hpp",
"SPIRV/spvIR.h",
"glslang/GenericCodeGen/CodeGen.cpp",
"glslang/GenericCodeGen/Link.cpp",
"glslang/Include/BaseTypes.h",
"glslang/Include/Common.h",
"glslang/Include/ConstantUnion.h",
"glslang/Include/InfoSink.h",
"glslang/Include/InitializeGlobals.h",
"glslang/Include/PoolAlloc.h",
"glslang/Include/ResourceLimits.h",
"glslang/Include/ShHandle.h",
"glslang/Include/Types.h",
"glslang/Include/arrays.h",
"glslang/Include/intermediate.h",
"glslang/Include/revision.h",
"glslang/MachineIndependent/Constant.cpp",
"glslang/MachineIndependent/InfoSink.cpp",
"glslang/MachineIndependent/Initialize.cpp",
"glslang/MachineIndependent/Initialize.h",
"glslang/MachineIndependent/IntermTraverse.cpp",
"glslang/MachineIndependent/Intermediate.cpp",
"glslang/MachineIndependent/LiveTraverser.h",
"glslang/MachineIndependent/ParseContextBase.cpp",
"glslang/MachineIndependent/ParseHelper.cpp",
"glslang/MachineIndependent/ParseHelper.h",
"glslang/MachineIndependent/PoolAlloc.cpp",
"glslang/MachineIndependent/RemoveTree.cpp",
"glslang/MachineIndependent/RemoveTree.h",
"glslang/MachineIndependent/Scan.cpp",
"glslang/MachineIndependent/Scan.h",
"glslang/MachineIndependent/ScanContext.h",
"glslang/MachineIndependent/ShaderLang.cpp",
"glslang/MachineIndependent/SymbolTable.cpp",
"glslang/MachineIndependent/SymbolTable.h",
"glslang/MachineIndependent/Versions.cpp",
"glslang/MachineIndependent/Versions.h",
"glslang/MachineIndependent/attribute.cpp",
"glslang/MachineIndependent/attribute.h",
"glslang/MachineIndependent/gl_types.h",
"glslang/MachineIndependent/glslang.y",
"glslang/MachineIndependent/glslang_tab.cpp",
"glslang/MachineIndependent/glslang_tab.cpp.h",
"glslang/MachineIndependent/intermOut.cpp",
"glslang/MachineIndependent/iomapper.cpp",
"glslang/MachineIndependent/iomapper.h",
"glslang/MachineIndependent/limits.cpp",
"glslang/MachineIndependent/linkValidate.cpp",
"glslang/MachineIndependent/localintermediate.h",
"glslang/MachineIndependent/parseConst.cpp",
"glslang/MachineIndependent/parseVersions.h",
"glslang/MachineIndependent/preprocessor/Pp.cpp",
"glslang/MachineIndependent/preprocessor/PpAtom.cpp",
"glslang/MachineIndependent/preprocessor/PpContext.cpp",
"glslang/MachineIndependent/preprocessor/PpContext.h",
"glslang/MachineIndependent/preprocessor/PpScanner.cpp",
"glslang/MachineIndependent/preprocessor/PpTokens.cpp",
"glslang/MachineIndependent/preprocessor/PpTokens.h",
"glslang/MachineIndependent/propagateNoContraction.cpp",
"glslang/MachineIndependent/propagateNoContraction.h",
"glslang/MachineIndependent/reflection.cpp",
"glslang/MachineIndependent/reflection.h",
"glslang/OSDependent/osinclude.h",
"glslang/Public/ShaderLang.h",
]
defines = []
if (is_win) {
sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
defines += [ "GLSLANG_OSINCLUDE_WIN32" ]
} else {
sources += [ "glslang/OSDependent/Unix/ossource.cpp" ]
defines += [ "GLSLANG_OSINCLUDE_UNIX" ]
}
if (is_clang) {
cflags_cc = [
"-Wno-implicit-fallthrough",
"-Wno-ignored-qualifiers",
"-Wno-unused-variable",
]
}
deps = [
"${spirv_tools_dir}:spvtools_opt",
]
}

View File

@ -9,10 +9,19 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Adhere to GNU filesystem layout conventions
include(GNUInstallDirs)
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
set(LIB_TYPE STATIC)
if(BUILD_SHARED_LIBS)
set(LIB_TYPE SHARED)
endif()
option(SKIP_GLSLANG_INSTALL "Skip installation" ${SKIP_GLSLANG_INSTALL})
if(NOT ${SKIP_GLSLANG_INSTALL})
set(ENABLE_GLSLANG_INSTALL ON)
endif()
option(ENABLE_SPVREMAPPER "Enables building of SPVRemapper" ON)
option(ENABLE_AMD_EXTENSIONS "Enables support of AMD-specific extensions" ON)
option(ENABLE_GLSLANG_BINARIES "Builds glslangValidator and spirv-remap" ON)
@ -27,6 +36,30 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND WIN32)
set(CMAKE_INSTALL_PREFIX "install" CACHE STRING "..." FORCE)
endif()
option(USE_CCACHE "Use ccache" OFF)
if(USE_CCACHE)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
endif(CCACHE_FOUND)
endif()
# Precompiled header macro. Parameters are source file list and filename for pch cpp file.
macro(glslang_pch SRCS PCHCPP)
if(MSVC)
if (CMAKE_GENERATOR MATCHES "^Visual Studio")
set(PCH_NAME "$(IntDir)\\pch.pch")
else()
set(PCH_NAME "${CMAKE_CURRENT_BINARY_DIR}/pch.pch")
endif()
# make source files use/depend on PCH_NAME
set_source_files_properties(${${SRCS}} PROPERTIES COMPILE_FLAGS "/Yupch.h /FIpch.h /Fp${PCH_NAME} /Zm300" OBJECT_DEPENDS "${PCH_NAME}")
# make PCHCPP file compile and generate PCH_NAME
set_source_files_properties(${PCHCPP} PROPERTIES COMPILE_FLAGS "/Ycpch.h /Fp${PCH_NAME} /Zm300" OBJECT_OUTPUTS "${PCH_NAME}")
list(APPEND ${SRCS} "${PCHCPP}")
endif()
endmacro(glslang_pch)
project(glslang)
# make testing optional
include(CTest)
@ -44,7 +77,7 @@ if(ENABLE_HLSL)
endif(ENABLE_HLSL)
if(WIN32)
set(CMAKE_DEBUG_POSTFIX "d")
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Adds a postfix for debug-built libraries.")
if(MSVC)
include(ChooseMSVCCRT.cmake)
endif(MSVC)
@ -94,9 +127,12 @@ endif()
if(ENABLE_OPT)
message(STATUS "optimizer enabled")
add_definitions(-DENABLE_OPT)
elseif(ENABLE_HLSL)
message(STATUS "spirv-tools not linked - illegal SPIRV may be generated for HLSL")
add_definitions(-DENABLE_OPT=1)
else()
if(ENABLE_HLSL)
message(STATUS "spirv-tools not linked - illegal SPIRV may be generated for HLSL")
endif()
add_definitions(-DENABLE_OPT=0)
endif()
add_subdirectory(glslang)

View File

@ -0,0 +1 @@
A reminder that this issue tracker is managed by the Khronos Group. Interactions here should follow the Khronos Code of Conduct (https://www.khronos.org/developers/code-of-conduct), which prohibits aggressive or derogatory language. Please keep the discussion friendly and civil.

View File

@ -57,20 +57,23 @@ branch.
### Dependencies
* A C++11 compiler.
(For MSVS: 2015 is recommended, 2013 is fully supported/tested, and 2010 support is attempted, but not tested.)
* [CMake][cmake]: for generating compilation targets.
* make: _Linux_, ninja is an alternative, if configured.
* [Python 2.7][python]: for executing SPIRV-Tools scripts. (Optional if not using SPIRV-Tools.)
* [bison][bison]: _optional_, but needed when changing the grammar (glslang.y).
* [googletest][googletest]: _optional_, but should use if making any changes to glslang.
### Build steps
The following steps assume a Bash shell. On Windows, that could be the Git Bash
shell or some other shell of your choosing.
#### 1) Check-Out this project
```bash
cd <parent of where you want glslang to be>
# If using SSH
git clone git@github.com:KhronosGroup/glslang.git
# Or if using HTTPS
git clone https://github.com/KhronosGroup/glslang.git
```
@ -81,6 +84,15 @@ cd <the directory glslang was cloned to, "External" will be a subdirectory>
git clone https://github.com/google/googletest.git External/googletest
```
If you want to use googletest with Visual Studio 2013, you also need to check out an older version:
```bash
# to use googletest with Visual Studio 2013
cd External/googletest
git checkout 440527a61e1c91188195f7de212c63c77e8f0a45
cd ../..
```
If you wish to assure that SPIR-V generated from HLSL is legal for Vulkan,
or wish to invoke -Os to reduce SPIR-V size from HLSL or GLSL, install
spirv-tools with this:
@ -89,28 +101,27 @@ spirv-tools with this:
./update_glslang_sources.py
```
For running the CMake GUI or Visual Studio with python dependencies, you will,
in addition to python within the cygwin environment, need a Windows [python][python]
installation, including selecting the `PATH` update.
#### 3) Configure
Assume the source directory is `$SOURCE_DIR` and
the build directory is `$BUILD_DIR`:
For building on Linux (assuming using the Ninja generator):
Assume the source directory is `$SOURCE_DIR` and the build directory is
`$BUILD_DIR`. First ensure the build directory exists, then navigate to it:
```bash
mkdir -p $BUILD_DIR
cd $BUILD_DIR
```
cmake -GNinja -DCMAKE_BUILD_TYPE={Debug|Release|RelWithDebInfo} \
-DCMAKE_INSTALL_PREFIX=`pwd`/install $SOURCE_DIR
For building on Linux:
```bash
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$(pwd)/install" $SOURCE_DIR
# "Release" (for CMAKE_BUILD_TYPE) could also be "Debug" or "RelWithDebInfo"
```
For building on Windows:
```bash
cmake $SOURCE_DIR -DCMAKE_INSTALL_PREFIX=`pwd`/install
cmake $SOURCE_DIR -DCMAKE_INSTALL_PREFIX="$(pwd)/install"
# The CMAKE_INSTALL_PREFIX part is for testing (explained later).
```
@ -120,11 +131,11 @@ The CMake GUI also works for Windows (version 3.4.1 tested).
```bash
# for Linux:
ninja install
make -j4 install
# for Windows:
cmake --build . --config {Release|Debug|MinSizeRel|RelWithDebInfo} \
--target install
cmake --build . --config Release --target install
# "Release" (for --config) could also be "Debug", "MinSizeRel", or "RelWithDebInfo"
```
If using MSVC, after running CMake to configure, use the
@ -239,8 +250,11 @@ bool InitializeProcess();
void FinalizeProcess();
class TShader
setStrings(...);
setEnvInput(EShSourceHlsl or EShSourceGlsl, stage, EShClientVulkan or EShClientOpenGL, 100);
setEnvClient(EShClientVulkan or EShClientOpenGL, EShTargetVulkan_1_0 or EShTargetVulkan_1_1 or EShTargetOpenGL_450);
setEnvTarget(EShTargetSpv, EShTargetSpv_1_0 or EShTargetSpv_1_3);
bool parse(...);
void setStrings(...);
const char* getInfoLog();
class TProgram

View File

@ -3,7 +3,9 @@ set(SOURCES
InReadableOrder.cpp
Logger.cpp
SpvBuilder.cpp
SpvPostProcess.cpp
doc.cpp
SpvTools.cpp
disassemble.cpp)
set(SPVREMAP_SOURCES
@ -14,6 +16,7 @@ set(HEADERS
bitutils.h
spirv.hpp
GLSL.std.450.h
GLSL.ext.EXT.h
GLSL.ext.KHR.h
GlslangToSpv.h
hex_float.h
@ -21,6 +24,7 @@ set(HEADERS
SpvBuilder.h
spvIR.h
doc.h
SpvTools.h
disassemble.h)
set(SPVREMAP_HEADERS
@ -39,20 +43,31 @@ if(ENABLE_NV_EXTENSIONS)
GLSL.ext.NV.h)
endif(ENABLE_NV_EXTENSIONS)
add_library(SPIRV STATIC ${SOURCES} ${HEADERS})
add_library(SPIRV ${LIB_TYPE} ${SOURCES} ${HEADERS})
set_property(TARGET SPIRV PROPERTY FOLDER glslang)
set_property(TARGET SPIRV PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(SPIRV PUBLIC ..)
add_library(SPVRemapper STATIC ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS})
set_property(TARGET SPVRemapper PROPERTY FOLDER glslang)
set_property(TARGET SPVRemapper PROPERTY POSITION_INDEPENDENT_CODE ON)
if (ENABLE_SPVREMAPPER)
add_library(SPVRemapper ${LIB_TYPE} ${SPVREMAP_SOURCES} ${SPVREMAP_HEADERS})
set_property(TARGET SPVRemapper PROPERTY FOLDER glslang)
set_property(TARGET SPVRemapper PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
if(WIN32 AND BUILD_SHARED_LIBS)
set_target_properties(SPIRV PROPERTIES PREFIX "")
if (ENABLE_SPVREMAPPER)
set_target_properties(SPVRemapper PROPERTIES PREFIX "")
endif()
endif()
if(ENABLE_OPT)
target_include_directories(SPIRV
PRIVATE ${spirv-tools_SOURCE_DIR}/include
PRIVATE ${spirv-tools_SOURCE_DIR}/source
)
target_link_libraries(SPIRV glslang SPIRV-Tools-opt SPVRemapper)
target_link_libraries(SPIRV glslang SPIRV-Tools-opt)
target_include_directories(SPIRV PUBLIC ../External)
else()
target_link_libraries(SPIRV glslang)
endif(ENABLE_OPT)
@ -63,8 +78,23 @@ if(WIN32)
endif(WIN32)
if(ENABLE_GLSLANG_INSTALL)
install(TARGETS SPIRV SPVRemapper
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(BUILD_SHARED_LIBS)
if (ENABLE_SPVREMAPPER)
install(TARGETS SPVRemapper
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
install(TARGETS SPIRV
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
else()
if (ENABLE_SPVREMAPPER)
install(TARGETS SPVRemapper
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
install(TARGETS SPIRV
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
install(FILES ${HEADERS} ${SPVREMAP_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SPIRV/)
endif(ENABLE_GLSLANG_INSTALL)

View File

@ -27,13 +27,8 @@
#ifndef GLSLextAMD_H
#define GLSLextAMD_H
enum BuiltIn;
enum Capability;
enum Decoration;
enum Op;
static const int GLSLextAMDVersion = 100;
static const int GLSLextAMDRevision = 6;
static const int GLSLextAMDRevision = 7;
// SPV_AMD_shader_ballot
static const char* const E_SPV_AMD_shader_ballot = "SPV_AMD_shader_ballot";
@ -104,14 +99,10 @@ static const char* const E_SPV_AMD_gpu_shader_int16 = "SPV_AMD_gpu_shader_int16"
// SPV_AMD_shader_image_load_store_lod
static const char* const E_SPV_AMD_shader_image_load_store_lod = "SPV_AMD_shader_image_load_store_lod";
static const Capability CapabilityImageReadWriteLodAMD = static_cast<Capability>(5015);
// SPV_AMD_shader_fragment_mask
static const char* const E_SPV_AMD_shader_fragment_mask = "SPV_AMD_shader_fragment_mask";
static const Capability CapabilityFragmentMaskAMD = static_cast<Capability>(5010);
static const Op OpFragmentMaskFetchAMD = static_cast<Op>(5011);
static const Op OpFragmentFetchAMD = static_cast<Op>(5012);
// SPV_AMD_gpu_shader_half_float_fetch
static const char* const E_SPV_AMD_gpu_shader_half_float_fetch = "SPV_AMD_gpu_shader_half_float_fetch";
#endif // #ifndef GLSLextAMD_H

View File

@ -0,0 +1,38 @@
/*
** Copyright (c) 2014-2016 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and/or associated documentation files (the "Materials"),
** to deal in the Materials without restriction, including without limitation
** the rights to use, copy, modify, merge, publish, distribute, sublicense,
** and/or sell copies of the Materials, and to permit persons to whom the
** Materials are 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 Materials.
**
** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
**
** THE MATERIALS ARE 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 MATERIALS OR THE USE OR OTHER DEALINGS
** IN THE MATERIALS.
*/
#ifndef GLSLextEXT_H
#define GLSLextEXT_H
static const int GLSLextEXTVersion = 100;
static const int GLSLextEXTRevision = 2;
static const char* const E_SPV_EXT_shader_stencil_export = "SPV_EXT_shader_stencil_export";
static const char* const E_SPV_EXT_shader_viewport_index_layer = "SPV_EXT_shader_viewport_index_layer";
static const char* const E_SPV_EXT_fragment_fully_covered = "SPV_EXT_fragment_fully_covered";
static const char* const E_SPV_EXT_fragment_invocation_density = "SPV_EXT_fragment_invocation_density";
#endif // #ifndef GLSLextEXT_H

View File

@ -27,10 +27,6 @@
#ifndef GLSLextKHR_H
#define GLSLextKHR_H
enum BuiltIn;
enum Op;
enum Capability;
static const int GLSLextKHRVersion = 100;
static const int GLSLextKHRRevision = 2;
@ -40,9 +36,9 @@ static const char* const E_SPV_KHR_device_group = "SPV_KHR_devic
static const char* const E_SPV_KHR_multiview = "SPV_KHR_multiview";
static const char* const E_SPV_KHR_shader_draw_parameters = "SPV_KHR_shader_draw_parameters";
static const char* const E_SPV_KHR_16bit_storage = "SPV_KHR_16bit_storage";
static const char* const E_SPV_KHR_8bit_storage = "SPV_KHR_8bit_storage";
static const char* const E_SPV_KHR_storage_buffer_storage_class = "SPV_KHR_storage_buffer_storage_class";
static const char* const E_SPV_KHR_post_depth_coverage = "SPV_KHR_post_depth_coverage";
static const char* const E_SPV_EXT_shader_stencil_export = "SPV_EXT_shader_stencil_export";
static const char* const E_SPV_EXT_shader_viewport_index_layer = "SPV_EXT_shader_viewport_index_layer";
static const char* const E_SPV_KHR_vulkan_memory_model = "SPV_KHR_vulkan_memory_model";
#endif // #ifndef GLSLextKHR_H

View File

@ -33,7 +33,7 @@ enum Op;
enum Capability;
static const int GLSLextNVVersion = 100;
static const int GLSLextNVRevision = 5;
static const int GLSLextNVRevision = 11;
//SPV_NV_sample_mask_override_coverage
const char* const E_SPV_NV_sample_mask_override_coverage = "SPV_NV_sample_mask_override_coverage";
@ -51,4 +51,25 @@ const char* const E_SPV_NV_stereo_view_rendering = "SPV_NV_stereo_view_rendering
//SPV_NVX_multiview_per_view_attributes
const char* const E_SPV_NVX_multiview_per_view_attributes = "SPV_NVX_multiview_per_view_attributes";
#endif // #ifndef GLSLextNV_H
//SPV_NV_shader_subgroup_partitioned
const char* const E_SPV_NV_shader_subgroup_partitioned = "SPV_NV_shader_subgroup_partitioned";
//SPV_NV_fragment_shader_barycentric
const char* const E_SPV_NV_fragment_shader_barycentric = "SPV_NV_fragment_shader_barycentric";
//SPV_NV_compute_shader_derivatives
const char* const E_SPV_NV_compute_shader_derivatives = "SPV_NV_compute_shader_derivatives";
//SPV_NV_shader_image_footprint
const char* const E_SPV_NV_shader_image_footprint = "SPV_NV_shader_image_footprint";
//SPV_NV_mesh_shader
const char* const E_SPV_NV_mesh_shader = "SPV_NV_mesh_shader";
//SPV_NV_raytracing
const char* const E_SPV_NV_ray_tracing = "SPV_NV_ray_tracing";
//SPV_NV_shading_rate
const char* const E_SPV_NV_shading_rate = "SPV_NV_shading_rate";
#endif // #ifndef GLSLextNV_H

File diff suppressed because it is too large Load Diff

View File

@ -34,10 +34,11 @@
#pragma once
#if _MSC_VER >= 1900
#if defined(_MSC_VER) && _MSC_VER >= 1900
#pragma warning(disable : 4464) // relative include path contains '..'
#endif
#include "SpvTools.h"
#include "../glslang/Include/intermediate.h"
#include <string>
@ -47,14 +48,6 @@
namespace glslang {
struct SpvOptions {
SpvOptions() : generateDebugInfo(false), disableOptimizer(true),
optimizeSize(false) { }
bool generateDebugInfo;
bool disableOptimizer;
bool optimizeSize;
};
void GetSpirvVersion(std::string&);
int GetSpirvGeneratorVersion();
void GlslangToSpv(const glslang::TIntermediate& intermediate, std::vector<unsigned int>& spirv,

View File

@ -220,11 +220,11 @@ namespace spv {
bool spirvbin_t::isConstOp(spv::Op opCode) const
{
switch (opCode) {
case spv::OpConstantNull:
case spv::OpConstantSampler:
error("unimplemented constant type");
return true;
case spv::OpConstantNull:
case spv::OpConstantTrue:
case spv::OpConstantFalse:
case spv::OpConstantComposite:
@ -256,7 +256,7 @@ namespace spv {
spv::Id spirvbin_t::localId(spv::Id id, spv::Id newId)
{
assert(id != spv::NoResult && newId != spv::NoResult);
//assert(id != spv::NoResult && newId != spv::NoResult);
if (id > bound()) {
error(std::string("ID out of range: ") + std::to_string(id));
@ -1326,10 +1326,6 @@ namespace spv {
case spv::OpTypeReserveId: return 300002;
case spv::OpTypeQueue: return 300003;
case spv::OpTypePipe: return 300004;
case spv::OpConstantNull: return 300005;
case spv::OpConstantSampler: return 300006;
case spv::OpConstantTrue: return 300007;
case spv::OpConstantFalse: return 300008;
case spv::OpConstantComposite:
@ -1346,6 +1342,18 @@ namespace spv {
hash += w * spv[typeStart+w];
return hash;
}
case spv::OpConstantNull:
{
std::uint32_t hash = 500009 + hashType(idPos(spv[typeStart+1]));
return hash;
}
case spv::OpConstantSampler:
{
std::uint32_t hash = 600011 + hashType(idPos(spv[typeStart+1]));
for (unsigned w=3; w < wordCount; ++w)
hash += w * spv[typeStart+w];
return hash;
}
default:
error("unknown type opcode");

View File

@ -46,9 +46,7 @@
#include "SpvBuilder.h"
#ifdef AMD_EXTENSIONS
#include "hex_float.h"
#endif
#include "hex_float.h"
#ifndef _WIN32
#include <cstdio>
@ -56,7 +54,8 @@
namespace spv {
Builder::Builder(unsigned int magicNumber, SpvBuildLogger* buildLogger) :
Builder::Builder(unsigned int spvVersion, unsigned int magicNumber, SpvBuildLogger* buildLogger) :
spvVersion(spvVersion),
source(SourceLanguageUnknown),
sourceVersion(0),
sourceFileStringId(NoResult),
@ -82,6 +81,7 @@ Id Builder::import(const char* name)
{
Instruction* import = new Instruction(getUniqueId(), NoType, OpExtInstImport);
import->addStringOperand(name);
module.mapInstruction(import);
imports.push_back(std::unique_ptr<Instruction>(import));
return import->getResultId();
@ -193,8 +193,9 @@ Id Builder::makeIntegerType(int width, bool hasSign)
// deal with capabilities
switch (width) {
case 8:
case 16:
addCapability(CapabilityInt16);
// these are currently handled by storage-type declarations and post processing
break;
case 64:
addCapability(CapabilityInt64);
@ -226,7 +227,7 @@ Id Builder::makeFloatType(int width)
// deal with capabilities
switch (width) {
case 16:
addCapability(CapabilityFloat16);
// currently handled by storage-type declarations and post processing
break;
case 64:
addCapability(CapabilityFloat64);
@ -502,12 +503,27 @@ Id Builder::makeSampledImageType(Id imageType)
return type->getResultId();
}
#ifdef NV_EXTENSIONS
Id Builder::makeAccelerationStructureNVType()
{
Instruction *type;
if (groupedTypes[OpTypeAccelerationStructureNV].size() == 0) {
type = new Instruction(getUniqueId(), NoType, OpTypeAccelerationStructureNV);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(type));
module.mapInstruction(type);
} else {
type = groupedTypes[OpTypeAccelerationStructureNV].back();
}
return type->getResultId();
}
#endif
Id Builder::getDerefTypeId(Id resultId) const
{
Id typeId = getTypeId(resultId);
assert(isPointerType(typeId));
return module.getInstruction(typeId)->getImmediateOperand(1);
return module.getInstruction(typeId)->getIdOperand(1);
}
Op Builder::getMostBasicTypeClass(Id typeId) const
@ -517,12 +533,6 @@ Op Builder::getMostBasicTypeClass(Id typeId) const
Op typeClass = instr->getOpCode();
switch (typeClass)
{
case OpTypeVoid:
case OpTypeBool:
case OpTypeInt:
case OpTypeFloat:
case OpTypeStruct:
return typeClass;
case OpTypeVector:
case OpTypeMatrix:
case OpTypeArray:
@ -531,8 +541,7 @@ Op Builder::getMostBasicTypeClass(Id typeId) const
case OpTypePointer:
return getMostBasicTypeClass(instr->getIdOperand(1));
default:
assert(0);
return OpTypeFloat;
return typeClass;
}
}
@ -551,7 +560,7 @@ int Builder::getNumTypeConstituents(Id typeId) const
return instr->getImmediateOperand(1);
case OpTypeArray:
{
Id lengthId = instr->getImmediateOperand(1);
Id lengthId = instr->getIdOperand(1);
return module.getInstruction(lengthId)->getImmediateOperand(0);
}
case OpTypeStruct:
@ -619,9 +628,39 @@ Id Builder::getContainedTypeId(Id typeId) const
return getContainedTypeId(typeId, 0);
}
// Returns true if 'typeId' is or contains a scalar type declared with 'typeOp'
// of width 'width'. The 'width' is only consumed for int and float types.
// Returns false otherwise.
bool Builder::containsType(Id typeId, spv::Op typeOp, unsigned int width) const
{
const Instruction& instr = *module.getInstruction(typeId);
Op typeClass = instr.getOpCode();
switch (typeClass)
{
case OpTypeInt:
case OpTypeFloat:
return typeClass == typeOp && instr.getImmediateOperand(0) == width;
case OpTypeStruct:
for (int m = 0; m < instr.getNumOperands(); ++m) {
if (containsType(instr.getIdOperand(m), typeOp, width))
return true;
}
return false;
case OpTypeVector:
case OpTypeMatrix:
case OpTypeArray:
case OpTypeRuntimeArray:
case OpTypePointer:
return containsType(getContainedTypeId(typeId), typeOp, width);
default:
return typeClass == typeOp;
}
}
// See if a scalar constant of this type has already been created, so it
// can be reused rather than duplicated. (Required by the specification).
Id Builder::findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned value) const
Id Builder::findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned value)
{
Instruction* constant;
for (int i = 0; i < (int)groupedConstants[typeClass].size(); ++i) {
@ -636,7 +675,7 @@ Id Builder::findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned valu
}
// Version of findScalarConstant (see above) for scalars that take two operands (e.g. a 'double' or 'int64').
Id Builder::findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned v1, unsigned v2) const
Id Builder::findScalarConstant(Op typeClass, Op opcode, Id typeId, unsigned v1, unsigned v2)
{
Instruction* constant;
for (int i = 0; i < (int)groupedConstants[typeClass].size(); ++i) {
@ -818,7 +857,6 @@ Id Builder::makeDoubleConstant(double d, bool specConstant)
return c->getResultId();
}
#ifdef AMD_EXTENSIONS
Id Builder::makeFloat16Constant(float f16, bool specConstant)
{
Op opcode = specConstant ? OpSpecConstant : OpConstant;
@ -846,9 +884,27 @@ Id Builder::makeFloat16Constant(float f16, bool specConstant)
return c->getResultId();
}
#endif
Id Builder::findCompositeConstant(Op typeClass, const std::vector<Id>& comps) const
Id Builder::makeFpConstant(Id type, double d, bool specConstant)
{
assert(isFloatType(type));
switch (getScalarTypeWidth(type)) {
case 16:
return makeFloat16Constant((float)d, specConstant);
case 32:
return makeFloatConstant((float)d, specConstant);
case 64:
return makeDoubleConstant(d, specConstant);
default:
break;
}
assert(false);
return NoResult;
}
Id Builder::findCompositeConstant(Op typeClass, const std::vector<Id>& comps)
{
Instruction* constant = 0;
bool found = false;
@ -876,6 +932,30 @@ Id Builder::findCompositeConstant(Op typeClass, const std::vector<Id>& comps) co
return found ? constant->getResultId() : NoResult;
}
Id Builder::findStructConstant(Id typeId, const std::vector<Id>& comps)
{
Instruction* constant = 0;
bool found = false;
for (int i = 0; i < (int)groupedStructConstants[typeId].size(); ++i) {
constant = groupedStructConstants[typeId][i];
// same contents?
bool mismatch = false;
for (int op = 0; op < constant->getNumOperands(); ++op) {
if (constant->getIdOperand(op) != comps[op]) {
mismatch = true;
break;
}
}
if (! mismatch) {
found = true;
break;
}
}
return found ? constant->getResultId() : NoResult;
}
// Comments in header
Id Builder::makeCompositeConstant(Id typeId, const std::vector<Id>& members, bool specConstant)
{
@ -886,25 +966,33 @@ Id Builder::makeCompositeConstant(Id typeId, const std::vector<Id>& members, boo
switch (typeClass) {
case OpTypeVector:
case OpTypeArray:
case OpTypeStruct:
case OpTypeMatrix:
if (! specConstant) {
Id existing = findCompositeConstant(typeClass, members);
if (existing)
return existing;
}
break;
case OpTypeStruct:
if (! specConstant) {
Id existing = findStructConstant(typeId, members);
if (existing)
return existing;
}
break;
default:
assert(0);
return makeFloatConstant(0.0);
}
if (! specConstant) {
Id existing = findCompositeConstant(typeClass, members);
if (existing)
return existing;
}
Instruction* c = new Instruction(getUniqueId(), typeId, opcode);
for (int op = 0; op < (int)members.size(); ++op)
c->addIdOperand(members[op]);
constantsTypesGlobals.push_back(std::unique_ptr<Instruction>(c));
groupedConstants[typeClass].push_back(c);
if (typeClass == OpTypeStruct)
groupedStructConstants[typeId].push_back(c);
else
groupedConstants[typeClass].push_back(c);
module.mapInstruction(c);
return c->getResultId();
@ -961,6 +1049,7 @@ void Builder::addDecoration(Id id, Decoration decoration, int num)
{
if (decoration == spv::DecorationMax)
return;
Instruction* dec = new Instruction(OpDecorate);
dec->addIdOperand(id);
dec->addImmediateOperand(decoration);
@ -970,8 +1059,37 @@ void Builder::addDecoration(Id id, Decoration decoration, int num)
decorations.push_back(std::unique_ptr<Instruction>(dec));
}
void Builder::addDecoration(Id id, Decoration decoration, const char* s)
{
if (decoration == spv::DecorationMax)
return;
Instruction* dec = new Instruction(OpDecorateStringGOOGLE);
dec->addIdOperand(id);
dec->addImmediateOperand(decoration);
dec->addStringOperand(s);
decorations.push_back(std::unique_ptr<Instruction>(dec));
}
void Builder::addDecorationId(Id id, Decoration decoration, Id idDecoration)
{
if (decoration == spv::DecorationMax)
return;
Instruction* dec = new Instruction(OpDecorateId);
dec->addIdOperand(id);
dec->addImmediateOperand(decoration);
dec->addIdOperand(idDecoration);
decorations.push_back(std::unique_ptr<Instruction>(dec));
}
void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decoration, int num)
{
if (decoration == spv::DecorationMax)
return;
Instruction* dec = new Instruction(OpMemberDecorate);
dec->addIdOperand(id);
dec->addImmediateOperand(member);
@ -982,6 +1100,20 @@ void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decorat
decorations.push_back(std::unique_ptr<Instruction>(dec));
}
void Builder::addMemberDecoration(Id id, unsigned int member, Decoration decoration, const char *s)
{
if (decoration == spv::DecorationMax)
return;
Instruction* dec = new Instruction(OpMemberDecorateStringGOOGLE);
dec->addIdOperand(id);
dec->addImmediateOperand(member);
dec->addImmediateOperand(decoration);
dec->addStringOperand(s);
decorations.push_back(std::unique_ptr<Instruction>(dec));
}
// Comments in header
Function* Builder::makeEntryPoint(const char* entryPoint)
{
@ -1099,19 +1231,35 @@ Id Builder::createUndefined(Id type)
}
// Comments in header
void Builder::createStore(Id rValue, Id lValue)
void Builder::createStore(Id rValue, Id lValue, spv::MemoryAccessMask memoryAccess, spv::Scope scope)
{
Instruction* store = new Instruction(OpStore);
store->addIdOperand(lValue);
store->addIdOperand(rValue);
if (memoryAccess != MemoryAccessMaskNone) {
store->addImmediateOperand(memoryAccess);
if (memoryAccess & spv::MemoryAccessMakePointerAvailableKHRMask) {
store->addIdOperand(makeUintConstant(scope));
}
}
buildPoint->addInstruction(std::unique_ptr<Instruction>(store));
}
// Comments in header
Id Builder::createLoad(Id lValue)
Id Builder::createLoad(Id lValue, spv::MemoryAccessMask memoryAccess, spv::Scope scope)
{
Instruction* load = new Instruction(getUniqueId(), getDerefTypeId(lValue), OpLoad);
load->addIdOperand(lValue);
if (memoryAccess != MemoryAccessMaskNone) {
load->addImmediateOperand(memoryAccess);
if (memoryAccess & spv::MemoryAccessMakePointerVisibleKHRMask) {
load->addIdOperand(makeUintConstant(scope));
}
}
buildPoint->addInstruction(std::unique_ptr<Instruction>(load));
return load->getResultId();
@ -1145,7 +1293,7 @@ Id Builder::createAccessChain(StorageClass storageClass, Id base, const std::vec
Id Builder::createArrayLength(Id base, unsigned int member)
{
spv::Id intType = makeIntType(32);
spv::Id intType = makeUintType(32);
Instruction* length = new Instruction(getUniqueId(), intType, OpArrayLength);
length->addIdOperand(base);
length->addImmediateOperand(member);
@ -1236,7 +1384,7 @@ void Builder::createNoResultOp(Op opCode)
buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
}
// An opcode that has one operand, no result id, and no type
// An opcode that has one id operand, no result id, and no type
void Builder::createNoResultOp(Op opCode, Id operand)
{
Instruction* op = new Instruction(opCode);
@ -1244,29 +1392,43 @@ void Builder::createNoResultOp(Op opCode, Id operand)
buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
}
// An opcode that has one operand, no result id, and no type
// An opcode that has one or more operands, no result id, and no type
void Builder::createNoResultOp(Op opCode, const std::vector<Id>& operands)
{
Instruction* op = new Instruction(opCode);
for (auto it = operands.cbegin(); it != operands.cend(); ++it)
for (auto it = operands.cbegin(); it != operands.cend(); ++it) {
op->addIdOperand(*it);
}
buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
}
// An opcode that has multiple operands, no result id, and no type
void Builder::createNoResultOp(Op opCode, const std::vector<IdImmediate>& operands)
{
Instruction* op = new Instruction(opCode);
for (auto it = operands.cbegin(); it != operands.cend(); ++it) {
if (it->isId)
op->addIdOperand(it->word);
else
op->addImmediateOperand(it->word);
}
buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
}
void Builder::createControlBarrier(Scope execution, Scope memory, MemorySemanticsMask semantics)
{
Instruction* op = new Instruction(OpControlBarrier);
op->addImmediateOperand(makeUintConstant(execution));
op->addImmediateOperand(makeUintConstant(memory));
op->addImmediateOperand(makeUintConstant(semantics));
op->addIdOperand(makeUintConstant(execution));
op->addIdOperand(makeUintConstant(memory));
op->addIdOperand(makeUintConstant(semantics));
buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
}
void Builder::createMemoryBarrier(unsigned executionScope, unsigned memorySemantics)
{
Instruction* op = new Instruction(OpMemoryBarrier);
op->addImmediateOperand(makeUintConstant(executionScope));
op->addImmediateOperand(makeUintConstant(memorySemantics));
op->addIdOperand(makeUintConstant(executionScope));
op->addIdOperand(makeUintConstant(memorySemantics));
buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
}
@ -1333,6 +1495,20 @@ Id Builder::createOp(Op opCode, Id typeId, const std::vector<Id>& operands)
return op->getResultId();
}
Id Builder::createOp(Op opCode, Id typeId, const std::vector<IdImmediate>& operands)
{
Instruction* op = new Instruction(getUniqueId(), typeId, opCode);
for (auto it = operands.cbegin(); it != operands.cend(); ++it) {
if (it->isId)
op->addIdOperand(it->word);
else
op->addImmediateOperand(it->word);
}
buildPoint->addInstruction(std::unique_ptr<Instruction>(op));
return op->getResultId();
}
Id Builder::createSpecConstantOp(Op opCode, Id typeId, const std::vector<Id>& operands, const std::vector<unsigned>& literals)
{
Instruction* op = new Instruction(getUniqueId(), typeId, OpSpecConstantOp);
@ -1387,16 +1563,13 @@ Id Builder::createLvalueSwizzle(Id typeId, Id target, Id source, const std::vect
return createCompositeInsert(source, target, typeId, channels.front());
Instruction* swizzle = new Instruction(getUniqueId(), typeId, OpVectorShuffle);
assert(isVector(target));
swizzle->addIdOperand(target);
if (accessChain.component != NoResult)
// For dynamic component selection, source does not involve in l-value swizzle
swizzle->addIdOperand(target);
else {
assert(getNumComponents(source) == (int)channels.size());
assert(isVector(source));
swizzle->addIdOperand(source);
}
assert(getNumComponents(source) == (int)channels.size());
assert(isVector(source));
swizzle->addIdOperand(source);
// Set up an identity shuffle from the base value to the result value
unsigned int components[4];
@ -1405,12 +1578,8 @@ Id Builder::createLvalueSwizzle(Id typeId, Id target, Id source, const std::vect
components[i] = i;
// Punch in the l-value swizzle
for (int i = 0; i < (int)channels.size(); ++i) {
if (accessChain.component != NoResult)
components[i] = channels[i]; // Only shuffle the base value
else
components[channels[i]] = numTargetComponents + i;
}
for (int i = 0; i < (int)channels.size(); ++i)
components[channels[i]] = numTargetComponents + i;
// finish the instruction with these components selectors
for (int i = 0; i < numTargetComponents; ++i)
@ -1482,7 +1651,8 @@ Id Builder::createBuiltinCall(Id resultType, Id builtins, int entryPoint, const
// Accept all parameters needed to create a texture instruction.
// Create the correct instruction based on the inputs, and make the call.
Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse, bool fetch, bool proj, bool gather, bool noImplicitLod, const TextureParameters& parameters)
Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse, bool fetch, bool proj, bool gather,
bool noImplicitLod, const TextureParameters& parameters)
{
static const int maxTextureArgs = 10;
Id texArgs[maxTextureArgs] = {};
@ -1499,6 +1669,13 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse,
if (parameters.component != NoResult)
texArgs[numArgs++] = parameters.component;
#ifdef NV_EXTENSIONS
if (parameters.granularity != NoResult)
texArgs[numArgs++] = parameters.granularity;
if (parameters.coarse != NoResult)
texArgs[numArgs++] = parameters.coarse;
#endif
//
// Set up the optional arguments
//
@ -1535,6 +1712,7 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse,
texArgs[numArgs++] = parameters.offset;
}
if (parameters.offsets) {
addCapability(CapabilityImageGatherExtended);
mask = (ImageOperandsMask)(mask | ImageOperandsConstOffsetsMask);
texArgs[numArgs++] = parameters.offsets;
}
@ -1549,6 +1727,12 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse,
mask = (ImageOperandsMask)(mask | ImageOperandsMinLodMask);
texArgs[numArgs++] = parameters.lodClamp;
}
if (parameters.nonprivate) {
mask = mask | ImageOperandsNonPrivateTexelKHRMask;
}
if (parameters.volatil) {
mask = mask | ImageOperandsVolatileTexelKHRMask;
}
if (mask == ImageOperandsMaskNone)
--numArgs; // undo speculative reservation for the mask argument
else
@ -1563,6 +1747,10 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse,
opCode = OpImageSparseFetch;
else
opCode = OpImageFetch;
#ifdef NV_EXTENSIONS
} else if (parameters.granularity && parameters.coarse) {
opCode = OpImageSampleFootprintNV;
#endif
} else if (gather) {
if (parameters.Dref)
if (sparse)
@ -1684,9 +1872,6 @@ Id Builder::createTextureCall(Decoration precision, Id resultType, bool sparse,
// Comments in header
Id Builder::createTextureQueryCall(Op opCode, const TextureParameters& parameters, bool isUnsignedResult)
{
// All these need a capability
addCapability(CapabilityImageQuery);
// Figure out the result type
Id resultType = 0;
switch (opCode) {
@ -1725,7 +1910,11 @@ Id Builder::createTextureQueryCall(Op opCode, const TextureParameters& parameter
break;
}
case OpImageQueryLod:
#ifdef AMD_EXTENSIONS
resultType = makeVectorType(getScalarTypeId(getTypeId(parameters.coords)), 2);
#else
resultType = makeVectorType(makeFloatType(32), 2);
#endif
break;
case OpImageQueryLevels:
case OpImageQuerySamples:
@ -1935,9 +2124,39 @@ Id Builder::createMatrixConstructor(Decoration precision, const std::vector<Id>&
int numRows = getTypeNumRows(resultTypeId);
Instruction* instr = module.getInstruction(componentTypeId);
Id bitCount = instr->getIdOperand(0);
unsigned bitCount = instr->getImmediateOperand(0);
// Will use a two step process
// Optimize matrix constructed from a bigger matrix
if (isMatrix(sources[0]) && getNumColumns(sources[0]) >= numCols && getNumRows(sources[0]) >= numRows) {
// To truncate the matrix to a smaller number of rows/columns, we need to:
// 1. For each column, extract the column and truncate it to the required size using shuffle
// 2. Assemble the resulting matrix from all columns
Id matrix = sources[0];
Id columnTypeId = getContainedTypeId(resultTypeId);
Id sourceColumnTypeId = getContainedTypeId(getTypeId(matrix));
std::vector<unsigned> channels;
for (int row = 0; row < numRows; ++row)
channels.push_back(row);
std::vector<Id> matrixColumns;
for (int col = 0; col < numCols; ++col) {
std::vector<unsigned> indexes;
indexes.push_back(col);
Id colv = createCompositeExtract(matrix, sourceColumnTypeId, indexes);
setPrecision(colv, precision);
if (numRows != getNumRows(matrix)) {
matrixColumns.push_back(createRvalueSwizzle(precision, columnTypeId, colv, channels));
} else {
matrixColumns.push_back(colv);
}
}
return setPrecision(createCompositeConstruct(resultTypeId, matrixColumns), precision);
}
// Otherwise, will use a two step process
// 1. make a compile-time 2D array of values
// 2. construct a matrix from that array
@ -2191,6 +2410,7 @@ void Builder::clearAccessChain()
accessChain.component = NoResult;
accessChain.preSwizzleBaseType = NoType;
accessChain.isRValue = false;
accessChain.coherentFlags.clear();
}
// Comments in header
@ -2202,7 +2422,7 @@ void Builder::accessChainPushSwizzle(std::vector<unsigned>& swizzle, Id preSwizz
accessChain.preSwizzleBaseType = preSwizzleBaseType;
// if needed, propagate the swizzle for the current access chain
if (accessChain.swizzle.size()) {
if (accessChain.swizzle.size() > 0) {
std::vector<unsigned> oldSwizzle = accessChain.swizzle;
accessChain.swizzle.resize(0);
for (unsigned int i = 0; i < swizzle.size(); ++i) {
@ -2217,40 +2437,34 @@ void Builder::accessChainPushSwizzle(std::vector<unsigned>& swizzle, Id preSwizz
}
// Comments in header
void Builder::accessChainStore(Id rvalue)
void Builder::accessChainStore(Id rvalue, spv::MemoryAccessMask memoryAccess, spv::Scope scope)
{
assert(accessChain.isRValue == false);
transferAccessChainSwizzle(true);
Id base = collapseAccessChain();
Id source = rvalue;
// dynamic component should be gone
assert(accessChain.component == NoResult);
// If swizzle still exists, it is out-of-order or not full, we must load the target vector,
// extract and insert elements to perform writeMask and/or swizzle.
Id source = NoResult;
if (accessChain.swizzle.size()) {
if (accessChain.swizzle.size() > 0) {
Id tempBaseId = createLoad(base);
source = createLvalueSwizzle(getTypeId(tempBaseId), tempBaseId, rvalue, accessChain.swizzle);
source = createLvalueSwizzle(getTypeId(tempBaseId), tempBaseId, source, accessChain.swizzle);
}
// dynamic component selection
if (accessChain.component != NoResult) {
Id tempBaseId = (source == NoResult) ? createLoad(base) : source;
source = createVectorInsertDynamic(tempBaseId, getTypeId(tempBaseId), rvalue, accessChain.component);
}
if (source == NoResult)
source = rvalue;
createStore(source, base);
createStore(source, base, memoryAccess, scope);
}
// Comments in header
Id Builder::accessChainLoad(Decoration precision, Id resultType)
Id Builder::accessChainLoad(Decoration precision, Decoration nonUniform, Id resultType, spv::MemoryAccessMask memoryAccess, spv::Scope scope)
{
Id id;
if (accessChain.isRValue) {
// transfer access chain, but keep it static, so we can stay in registers
// transfer access chain, but try to stay in registers
transferAccessChainSwizzle(false);
if (accessChain.indexChain.size() > 0) {
Id swizzleBase = accessChain.preSwizzleBaseType != NoType ? accessChain.preSwizzleBaseType : resultType;
@ -2289,8 +2503,9 @@ Id Builder::accessChainLoad(Decoration precision, Id resultType)
} else {
transferAccessChainSwizzle(true);
// load through the access chain
id = createLoad(collapseAccessChain());
id = createLoad(collapseAccessChain(), memoryAccess, scope);
setPrecision(id, precision);
addDecoration(id, nonUniform);
}
// Done, unless there are swizzles to do
@ -2298,19 +2513,20 @@ Id Builder::accessChainLoad(Decoration precision, Id resultType)
return id;
// Do remaining swizzling
// First, static swizzling
if (accessChain.swizzle.size()) {
// static swizzle
// Do the basic swizzle
if (accessChain.swizzle.size() > 0) {
Id swizzledType = getScalarTypeId(getTypeId(id));
if (accessChain.swizzle.size() > 1)
swizzledType = makeVectorType(swizzledType, (int)accessChain.swizzle.size());
id = createRvalueSwizzle(precision, swizzledType, id, accessChain.swizzle);
}
// dynamic single-component selection
// Do the dynamic component
if (accessChain.component != NoResult)
id = setPrecision(createVectorExtractDynamic(id, resultType, accessChain.component), precision);
addDecoration(id, nonUniform);
return id;
}
@ -2363,47 +2579,11 @@ Id Builder::accessChainGetInferredType()
return type;
}
// comment in header
void Builder::eliminateDeadDecorations() {
std::unordered_set<const Block*> reachable_blocks;
std::unordered_set<Id> unreachable_definitions;
// Collect IDs defined in unreachable blocks. For each function, label the
// reachable blocks first. Then for each unreachable block, collect the
// result IDs of the instructions in it.
for (std::vector<Function*>::const_iterator fi = module.getFunctions().cbegin();
fi != module.getFunctions().cend(); fi++) {
Function* f = *fi;
Block* entry = f->getEntryBlock();
inReadableOrder(entry, [&reachable_blocks](const Block* b) {
reachable_blocks.insert(b);
});
for (std::vector<Block*>::const_iterator bi = f->getBlocks().cbegin();
bi != f->getBlocks().cend(); bi++) {
Block* b = *bi;
if (!reachable_blocks.count(b)) {
for (std::vector<std::unique_ptr<Instruction> >::const_iterator
ii = b->getInstructions().cbegin();
ii != b->getInstructions().cend(); ii++) {
Instruction* i = ii->get();
unreachable_definitions.insert(i->getResultId());
}
}
}
}
decorations.erase(std::remove_if(decorations.begin(), decorations.end(),
[&unreachable_definitions](std::unique_ptr<Instruction>& I) -> bool {
Instruction* inst = I.get();
Id decoration_id = inst->getIdOperand(0);
return unreachable_definitions.count(decoration_id) != 0;
}),
decorations.end());
}
void Builder::dump(std::vector<unsigned int>& out) const
{
// Header, before first instructions:
out.push_back(MagicNumber);
out.push_back(Version);
out.push_back(spvVersion);
out.push_back(builderNumber);
out.push_back(uniqueId + 1);
out.push_back(0);
@ -2433,7 +2613,6 @@ void Builder::dump(std::vector<unsigned int>& out) const
// Debug instructions
dumpInstructions(out, strings);
dumpModuleProcesses(out);
dumpSourceInstructions(out);
for (int e = 0; e < (int)sourceExtensions.size(); ++e) {
Instruction sourceExtInst(0, 0, OpSourceExtension);
@ -2441,7 +2620,7 @@ void Builder::dump(std::vector<unsigned int>& out) const
sourceExtInst.dump(out);
}
dumpInstructions(out, names);
dumpInstructions(out, lines);
dumpModuleProcesses(out);
// Annotation instructions
dumpInstructions(out, decorations);
@ -2457,26 +2636,66 @@ void Builder::dump(std::vector<unsigned int>& out) const
// Protected methods.
//
// Turn the described access chain in 'accessChain' into an instruction
// Turn the described access chain in 'accessChain' into an instruction(s)
// computing its address. This *cannot* include complex swizzles, which must
// be handled after this is called, but it does include swizzles that select
// an individual element, as a single address of a scalar type can be
// computed by an OpAccessChain instruction.
// be handled after this is called.
//
// Can generate code.
Id Builder::collapseAccessChain()
{
assert(accessChain.isRValue == false);
if (accessChain.indexChain.size() > 0) {
if (accessChain.instr == 0) {
StorageClass storageClass = (StorageClass)module.getStorageClass(getTypeId(accessChain.base));
accessChain.instr = createAccessChain(storageClass, accessChain.base, accessChain.indexChain);
}
// did we already emit an access chain for this?
if (accessChain.instr != NoResult)
return accessChain.instr;
} else
// If we have a dynamic component, we can still transfer
// that into a final operand to the access chain. We need to remap the
// dynamic component through the swizzle to get a new dynamic component to
// update.
//
// This was not done in transferAccessChainSwizzle() because it might
// generate code.
remapDynamicSwizzle();
if (accessChain.component != NoResult) {
// transfer the dynamic component to the access chain
accessChain.indexChain.push_back(accessChain.component);
accessChain.component = NoResult;
}
// note that non-trivial swizzling is left pending
// do we have an access chain?
if (accessChain.indexChain.size() == 0)
return accessChain.base;
// note that non-trivial swizzling is left pending...
// emit the access chain
StorageClass storageClass = (StorageClass)module.getStorageClass(getTypeId(accessChain.base));
accessChain.instr = createAccessChain(storageClass, accessChain.base, accessChain.indexChain);
return accessChain.instr;
}
// For a dynamic component selection of a swizzle.
//
// Turn the swizzle and dynamic component into just a dynamic component.
//
// Generates code.
void Builder::remapDynamicSwizzle()
{
// do we have a swizzle to remap a dynamic component through?
if (accessChain.component != NoResult && accessChain.swizzle.size() > 1) {
// build a vector of the swizzle for the component to map into
std::vector<Id> components;
for (int c = 0; c < (int)accessChain.swizzle.size(); ++c)
components.push_back(makeUintConstant(accessChain.swizzle[c]));
Id mapType = makeVectorType(makeUintType(32), (int)accessChain.swizzle.size());
Id map = makeCompositeConstant(mapType, components);
// use it
accessChain.component = createVectorExtractDynamic(map, makeUintType(32), accessChain.component);
accessChain.swizzle.clear();
}
}
// clear out swizzle if it is redundant, that is reselecting the same components
@ -2502,38 +2721,30 @@ void Builder::simplifyAccessChainSwizzle()
// To the extent any swizzling can become part of the chain
// of accesses instead of a post operation, make it so.
// If 'dynamic' is true, include transferring a non-static component index,
// otherwise, only transfer static indexes.
// If 'dynamic' is true, include transferring the dynamic component,
// otherwise, leave it pending.
//
// Also, Boolean vectors are likely to be special. While
// for external storage, they should only be integer types,
// function-local bool vectors could use sub-word indexing,
// so keep that as a separate Insert/Extract on a loaded vector.
// Does not generate code. just updates the access chain.
void Builder::transferAccessChainSwizzle(bool dynamic)
{
// too complex?
if (accessChain.swizzle.size() > 1)
return;
// non existent?
if (accessChain.swizzle.size() == 0 && accessChain.component == NoResult)
return;
// single component...
// skip doing it for Boolean vectors
if (isBoolType(getContainedTypeId(accessChain.preSwizzleBaseType)))
// too complex?
// (this requires either a swizzle, or generating code for a dynamic component)
if (accessChain.swizzle.size() > 1)
return;
// single component, either in the swizzle and/or dynamic component
if (accessChain.swizzle.size() == 1) {
// handle static component
assert(accessChain.component == NoResult);
// handle static component selection
accessChain.indexChain.push_back(makeUintConstant(accessChain.swizzle.front()));
accessChain.swizzle.clear();
// note, the only valid remaining dynamic access would be to this one
// component, so don't bother even looking at accessChain.component
accessChain.preSwizzleBaseType = NoType;
accessChain.component = NoResult;
} else if (dynamic && accessChain.component != NoResult) {
assert(accessChain.swizzle.size() == 0);
// handle dynamic component
accessChain.indexChain.push_back(accessChain.component);
accessChain.preSwizzleBaseType = NoType;
@ -2572,12 +2783,15 @@ void Builder::createSelectionMerge(Block* mergeBlock, unsigned int control)
buildPoint->addInstruction(std::unique_ptr<Instruction>(merge));
}
void Builder::createLoopMerge(Block* mergeBlock, Block* continueBlock, unsigned int control)
void Builder::createLoopMerge(Block* mergeBlock, Block* continueBlock, unsigned int control,
unsigned int dependencyLength)
{
Instruction* merge = new Instruction(OpLoopMerge);
merge->addIdOperand(mergeBlock->getId());
merge->addIdOperand(continueBlock->getId());
merge->addImmediateOperand(control);
if ((control & LoopControlDependencyLengthMask) != 0)
merge->addImmediateOperand(dependencyLength);
buildPoint->addInstruction(std::unique_ptr<Instruction>(merge));
}
@ -2644,8 +2858,6 @@ void Builder::dumpInstructions(std::vector<unsigned int>& out, const std::vector
void Builder::dumpModuleProcesses(std::vector<unsigned int>& out) const
{
for (int i = 0; i < (int)moduleProcesses.size(); ++i) {
// TODO: switch this out for the 1.1 headers
const spv::Op OpModuleProcessed = (spv::Op)330;
Instruction moduleProcessed(OpModuleProcessed);
moduleProcessed.addStringOperand(moduleProcesses[i]);
moduleProcessed.dump(out);

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