You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown Nick.Penwarden
#rb none
#rnx
============================
MAJOR FEATURES & CHANGES
============================
Change 3783110 by Thomas.Sarkanen
Added support for logical negation when copying to array properties in the fast path
#jira UE-52043 - Anim fast path correctly doesn't handle copying to arrays of bools with logical negation
Change 3783112 by Thomas.Sarkanen
Fixed not being able to assign/unassign constraint and physical animation profiles from the context menu
#jira UE-50205 - Constraint cannot be assigned or unassigned from current profile when using "Unassign" from the context menu in the Skeleton Tree and Graph
Change 3783114 by Thomas.Sarkanen
Asset picker now only reports 'picks' on user interactions
In Ocean and other projects with lots of animation assets, the asset picker amortizes its filter queries over a number of frames. This causes the list to temporarily not include the currently selected item, which then gets reported to client code as a 'deselection'. To address this (and to maintain backwards compatibility) I've added a new delegate that gives more context for selections to the SAssetPicker, allowing us to not report selections that are 'Direct'.
#jira UE-46802 - Searching for an animation from the dropdown in persona causes it to instantly close
Change 3783118 by Thomas.Sarkanen
Added inline time/frame settings to notify context menu
#jira UE-45410 - Inline MontageSection/Notify Time Entry
Change 3783122 by Thomas.Sarkanen
Collision Response dropdown is now a checkbox
Added details customization to allow the enum to masquerate as a bool property
#jira UE-47916 - Drop down used for Collision Response enable/disable in Physics Asset Editor
Change 3783183 by Jurre.deBaare
Follow up fix for toggling post processing in the preview scene
Change 3783186 by Jurre.deBaare
Material Baking Options has two Mesh Settings sections
#fix Changed category names for to allow for two distinct categories (would have preferred to merge them, but am limited by the way detailsview handles multiple objects with containing same category)
#jira UE-52645
Change 3783188 by Jurre.deBaare
Duplicating:
"Simplygon Skelmesh "Regenerate" button remains for content that had Lods created in simplygon, even when it's not installed. On regenerating editor crashes - FPersonaMeshDetails::ApplyChanges()
#fix Ensure the regenerate button is disabled when there is no MeshReduction interface available
#jira UE-52641
Change 3783205 by Jurre.deBaare
Bounds are not shown correctly in Persona for imported alembic skeletal mesh
#fix Ensured that we do not add invalid of (0,0,0) bounds to outgoing mesh bounds
#jira UE-49338
Change 3783248 by Jurre.deBaare
Preview Scene Settings window is missing Search bar
#fix changed search bar flag on Details View
#jira UE-50063
Change 3783267 by Jurre.deBaare
Animation Modifiers: GetBonePosesForTime does not create valid data for GetBonePose
#fix changed the way we retrieve bone transforms, now take it directly from the raw data rather than from a pose
#jira UE-52057
Change 3783281 by Jurre.deBaare
Tool Tip issues in Animation Editor Preferences
#fix corrected typos in comments
#jira UE-51338
Change 3783373 by Thomas.Sarkanen
Added error-reporting to the profile name widgets
This means that the effect of renaming profiles the same as an existing one is clear (i.e. we deny it now).
#jira UE-48120 - Renaming Physics profiles the same as existing Physics profiles switches profiles and is confusing
Change 3783438 by Jurre.deBaare
Vertex paint fill tool fills all channels
#fix Ensure that the current channel fill selection in the Mesh Painter is also used for the fill tool, to allow the user masking out certain channels when using fill
#jira UE-49256
Change 3783583 by Thomas.Sarkanen
Correctly return whether a mesh section is shown or not when it has not been edited
This fixes skeletal->static mesh conversion
Change 3783598 by Thomas.Sarkanen
Fix multi-convex generastion for skeletal meshes
Some triangle indices were being missed out of the index buffer, so the mesh that the convex hull was generated from was corrupt. Removing an early-out fixes this.
#jira UE-52529 - Inaccurate Collision is Generated When Using Multi Convex Hull (PhysicsAsset Editor)
Change 3783615 by Jurre.deBaare
OpacityMask/Opacity bug in MeshUtilities
#fix ensured that material baking uses correct texture samples for Opacity Mask property
#misc deprecated all of this functionality as users should be using the MaterialBaking module
#jira UE-52382
Change 3783620 by Martin.Wilson
Fix crash due to oversampling animation during compression
#Jira UE-52713
Change 3783633 by Jurre.deBaare
Fix deprecation warnings on CIS
Change 3783636 by Benn.Gallagher
Fixed non-working tethers in clothing
Fixed clothing config not applying to active simulation after editing
Fixed and re-enabled accurate wind mode
#jira UE-50797, UE-43611
Change 3783637 by Benn.Gallagher
Github PR: Fix world to actor transform bug in anim dynamics
Fixed incorrect Actor-space calculations for simulation transforms and world vector transformations inside AnimDynamics highlighted when testing the above PR
#jira UE-48681
#3929
Change 3783638 by Benn.Gallagher
Fixed UBlendProfile properties not being correctly customized on anim nodes - and animation sequence references not being correctly filtered on anim nodes.
Change 3783660 by Danny.Bouimad
Fixing #UE-40686 Mass TranslatedMass Automated test, instead of decreasing tolrence I changed the content to preserve granularity.
Change 3783974 by Ori.Cohen
Refactor when sync components is called and how we pass the data into plugins. Simplifies how we handle physx data getting invalidated by UE4 during updates.
Also fixed crash when scene query returns a destructible component that's been destroyed, but final apex delete flush hasn't happened yet.
#jira UE-50215
Change 3784112 by Benn.Gallagher
Fixed subinstance nodes inside states failing to correctly create bridge variables on their skeleton class due to not correctly processing subgraphs in the anim blueprint compiler.
#jira UE-51000
Change 3784277 by Martin.Wilson
Fix socket name getting an appended _0
#jira UE-46625
Change 3785589 by Ori.Cohen
Fix cis
Change 3786336 by Martin.Wilson
Pushing skeleton to live link can now take source guid
-Message bus source pushes guid when sending skeleton
Change 3786778 by Martin.Wilson
Added ability for worker thread animation blueprint code to report to Message Log + added additive warning when playing an animation on an additive pose
#jira UE-49780
Change 3786847 by Martin.Wilson
Initialization and delta time for live link retargeter
#Jira UE-52112
Change 3786852 by Lina.Halper
Sequencer blending support
#jira: UE-52183
Change 3786924 by Lina.Halper
PR #4210: FIX: Incorrectly passing an unrelated bool rather than the expected pose ind. (Contributed by ruffenman)
Change 3787114 by Jurre.deBaare
Discrepancy in description of Preview Scene setting and keyboard shortcut
#fix Changed naming of the settings to match the Advanced Preview Scene panel
#jira UE-50060
Change 3787115 by Jurre.deBaare
Animation Editor Preferences do not update the preview scene
#fix Removed unused preference from PersonaOptions
#jira UE-51318
Change 3787117 by Jurre.deBaare
Off-by one error in frame time calculations
#fix Fixed up UAnimSequenceBase::GetTimeAtFrame and UAnimSequenceBase::GetFrameAtTime to return correct frame indices, similar to FAnimationRuntime::GetKeyIndicesFromTime
#jira UE-52037
Change 3787412 by Martin.Wilson
CIS Fix
Change 3787622 by Ethan.Geller
Include Google Resonance SDK.
Change 3787633 by Ethan.Geller
Promote AmibsonicsMixerPtr to FAudioDevice
Change 3788026 by Lina.Halper
Retarget source reference to soft object ptr
#jira: UE-48570
Change 3788252 by Ethan.Geller
Add blueprint functions for Resonance Global Reverb
Change 3788750 by Ethan.Geller
fix single file compile for Resonance plugin
Change 3788763 by Ethan.Geller
include IModularFeatures.h explicitly for incremental build
Change 3789108 by Martin.Wilson
Fix animations with scaled root bone generating incorrect root motion
#jira UE-52088
Change 3789642 by Martin.Wilson
Fix transition nodes from referencing the wrong state node due to non unique node guids being introduced by copy and paste
#jira UE-43891
Change 3790165 by Martin.Wilson
Fix marker sync position not being maintained across instant transitions
#jira UE-21355
Change 3790182 by Ethan.Geller
Final Resonance edits pass.
Change 3790184 by Lina.Halper
Fix issue with crash when montage is streamed out while event is queued.
https://udn.unrealengine.com/questions/404318/anim-montage-queued-montage-event-crash.html
Change 3790207 by dan.reynolds
#UE-50774 Updated AEOverviewReverb to not attempt to destroy Audio Component that has already been destroyed.
Change 3790215 by Martin.Wilson
CIS Fix
Change 3790953 by Ethan.Geller
#jira UE-53023 bypass filters when at max frequency for LPF, DC for HPF
Change 3791832 by Martin.Wilson
Don't load animations for preview tooltip in Persona
#jira UE-52118
Change 3792873 by David.Hill
Fix CIS. Remove timer from proxylod code.
Change 3793251 by David.Hill
ProxyLOD Thirdparty libs build cs files.
Update from ModuleRules.WindowsPlatform to ReadOnlyTargetRules.WindowsPlatform
-- The WindowsPlatform alias is deprecated in 4.18
Change 3793400 by Ethan.Geller
Update Resonance blueprint library to fit google naming conventions
Change 3794097 by Benn.Gallagher
Fixed clothing visualizations no longer functioning
#jira UE-52995
Change 3794250 by Danny.Bouimad
Regenerated ground truth on LODCurveLinkingTest1 and AnimatedCloth, expected change as a result of Ben fixing a bug.
Needed to update Owens cloth settings too.
Should resolve automation test CIS fails
Change 3794352 by David.Hill
ProxyLOD code:
Disable openvdb-centric warnings within the openvdb platform.h file.
C6326: Potential comparison of a constant with another constant
and add annotations
C28251: Inconsistent annotation for 'copysign'
also added a warning suppress for static analysis CA_SUPPRESS(6011) within the proxylod version of the simplifier.
Change 3794786 by Lina.Halper
Pose asset retarget source bug fix
#jira: UE-52429
Change 3794841 by Danny.Bouimad
Hopefully fixes the cloth automation CIS
Change 3795191 by Lina.Halper
Fix build issue
Change 3795486 by Ethan.Geller
re-enable android support for Oculus Audio
Change 3796162 by Danny.Bouimad
Third attempt to fix the cloth CIS error. Hopefuly this will solve it.
Change 3796311 by Martin.Wilson
Remove recompress animation from curve track actions. Allows smoother interaction on animations with slow recompress time.
#jira UE-51740
Change 3796321 by Thomas.Sarkanen
Duplicating CL 3770752 from 4.18:
Prevent crash when generating convex bodies fails
Note: speculative fix as the issue cannot be reproduced locally
#jira UE-52449 - [CrashReport] FPhysicsAssetUtils::CreateFromSkeletalMeshInternal()
Change 3797093 by Danny.Bouimad
Constrant node AnimBP Automated tests
Change 3797384 by Danny.Bouimad
Fixing CIS error caused by automated test lighting issue
Change 3800621 by Thomas.Sarkanen
Fix CIS: Shadowed variable warning
#jira UE-53253 - FMenuBuilder declaration shadows a local variable warning appears when building the editor on Linux
Change 3800690 by Danny.Bouimad
Checking in fix for CIS automation for ConstraintNode, set the screenshot tool to use BaseColor. This should fix the issue with the rendering fuzzyness
Change 3800874 by David.Hill
Clean up static analysis warnings
#jira: UE-53270
Change 3801227 by David.Hill
Allow proxylod to fail gracefully if the input mesh is way too big (e.g. sky sphere)
Added code to automatically compute the correct spatial sampling rate based on the geometry size, also allow the user to override.
#cl: UE-53155
Change 3801228 by David.Hill
UI: Mesh Proxy Dialog re-write. Make this more like MeshMerging, and share some code.
#cl UE-53155, UE-52787, UE-53106
Change 3801319 by Danny.Bouimad
Regenerated all the screen shots for the constraint tests.
Change 3801383 by Ethan.Geller
#jira UE-53311 fix additional #if PLATFORM_WINDOWS guards in Oculus Audio
Change 3801697 by Ethan.Geller
include AudioDevice.h directly to resolve FAudioDevice.
Change 3802180 by David.Hill
This should fix the Incremental UE4Editor Linux build.
Change 3802643 by David.Hill
ProxyLOD UI change. Add limits to the target screen size. They now reflect the values in the old version of the UI and the thirdparty tool.
#CL: UE-53313
Change 3802986 by Ethan.Geller
#jira UE-53330 Change vraudio to explicit library path
Change 3803448 by Danny.Bouimad
disabling constraint tests
Change 3803678 by Danny.Bouimad
#jira UE-53306 Fix
Change 3804333 by Ethan.Geller
#jira UE-53330 fix library paths for iOS on Resonance
Change 3804453 by David.Hill
Fix Shadow warning when compiling UE4Editor on linux:
FlattenedMaterials.
#CL: UE-53349
Change 3804510 by Lina.Halper
CIS warning on shadow vars
#jira: UE-53348, UE-53345
Change 3805451 by Lina.Halper
Fix build issue : Renamed variable -
https://ec-01.epicgames.net/commander/link/jobStepDetails/jobSteps/74095846?stepName=Incremental%20UnrealHeaderTool%20Win64&jobId=8173688&jobName=UE4%20Dev-AnimPhys%20-%20CL%203805429%20-%20Incremental%20Editor%20Win64&tabGroup=diagnosticHeader
Change 3805470 by Lina.Halper
Fix build issue
Change 3806524 by Martin.Wilson
Only use previous frame end position if it is valid for this frame
#jira UE-53414
Change 3792620 by David.Hill
Copying //UE4/Dev-ProxyLOD to Dev-AnimPhys-Minimal (//UE4/Dev-AnimPhys-Minimal)
Adding the ProxyLOD code to AnimPhys.
Change 3796059 by Thomas.Sarkanen
Persona viewport settings are now per-asset editor
This prevnets bone following (etc) being shared by all Persona asset editors
FOV & view type is no longer chared by all Persona asset editors
#jira UE-53005 - Viewport settings like bone following are shared between all animation sub-editors
[CL 3806814 by Marc Audy in Main branch]
809 lines
26 KiB
C++
809 lines
26 KiB
C++
//-------------------------------------------------------------------------------------
|
|
// DirectXMeshVBWriter.cpp
|
|
//
|
|
// DirectX Mesh Geometry Library - Vertex Buffer Writer
|
|
//
|
|
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|
|
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
|
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
|
// PARTICULAR PURPOSE.
|
|
//
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
//
|
|
// http://go.microsoft.com/fwlink/?LinkID=324981
|
|
//-------------------------------------------------------------------------------------
|
|
|
|
#include "DirectXMeshP.h"
|
|
|
|
using namespace DirectX::PackedVector;
|
|
|
|
#pragma warning(disable : 4351)
|
|
|
|
namespace
|
|
{
|
|
const size_t c_MaxSlot = 32;
|
|
const size_t c_MaxStride = 2048;
|
|
|
|
enum INPUT_CLASSIFICATION
|
|
{
|
|
PER_VERTEX_DATA = 0,
|
|
PER_INSTANCE_DATA = 1
|
|
};
|
|
|
|
struct InputElementDesc
|
|
{
|
|
const char* SemanticName;
|
|
unsigned int SemanticIndex;
|
|
DXGI_FORMAT Format;
|
|
unsigned int InputSlot;
|
|
unsigned int AlignedByteOffset;
|
|
INPUT_CLASSIFICATION InputSlotClass;
|
|
unsigned int InstanceDataStepRate;
|
|
};
|
|
|
|
#if defined(__d3d11_h__) || defined(__d3d11_x_h__)
|
|
static_assert(sizeof(InputElementDesc) == sizeof(D3D11_INPUT_ELEMENT_DESC), "D3D11 mismatch");
|
|
static_assert(static_cast<int>(PER_VERTEX_DATA) == static_cast<int>(D3D11_INPUT_PER_VERTEX_DATA), "D3D11 mismatch");
|
|
static_assert(static_cast<int>(PER_INSTANCE_DATA) == static_cast<int>(D3D11_INPUT_PER_INSTANCE_DATA), "D3D11 mismatch");
|
|
static_assert(c_MaxSlot == D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, "D3D11 mismatch");
|
|
static_assert(c_MaxStride == D3D11_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES, "D3D11 mismatch");
|
|
#endif
|
|
|
|
#if defined(__d3d12_h__) || defined(__d3d12_x_h__)
|
|
static_assert(sizeof(InputElementDesc) == sizeof(D3D12_INPUT_ELEMENT_DESC), "D3D12 mismatch");
|
|
static_assert(static_cast<int>(PER_VERTEX_DATA) == static_cast<int>(D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA), "D3D12 mismatch");
|
|
static_assert(static_cast<int>(PER_INSTANCE_DATA) == static_cast<int>(D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA), "D3D12 mismatch");
|
|
static_assert(c_MaxSlot == D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, "D3D12 mismatch");
|
|
static_assert(c_MaxStride == D3D12_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES, "D3D12 mismatch");
|
|
#endif
|
|
}
|
|
|
|
namespace DirectX
|
|
{
|
|
|
|
class VBWriter::Impl
|
|
{
|
|
public:
|
|
Impl() :
|
|
mStrides{},
|
|
mBuffers{},
|
|
mVerts{},
|
|
mDefaultStrides{},
|
|
mTempSize(0) {}
|
|
|
|
HRESULT Initialize( _In_reads_(nDecl) const InputElementDesc* vbDecl, size_t nDecl );
|
|
HRESULT AddStream( _Out_writes_bytes_(stride*nVerts) void* vb, size_t nVerts, size_t inputSlot, size_t stride );
|
|
HRESULT Write( _In_reads_(count) const XMVECTOR* buffer, _In_z_ const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias ) const;
|
|
|
|
void Release()
|
|
{
|
|
mInputDesc.clear();
|
|
mSemantics.clear();
|
|
memset( mStrides, 0, sizeof(mStrides) );
|
|
memset( mBuffers, 0, sizeof(mBuffers) );
|
|
memset( mVerts, 0, sizeof(mVerts) );
|
|
memset( mDefaultStrides, 0, sizeof(mDefaultStrides) );
|
|
mTempBuffer.reset();
|
|
}
|
|
|
|
const InputElementDesc* GetElement( _In_z_ const char* semanticName, _In_ unsigned int semanticIndex ) const
|
|
{
|
|
auto range = mSemantics.equal_range(semanticName);
|
|
|
|
auto it = range.first;
|
|
for (; it != range.second; ++it)
|
|
{
|
|
if (mInputDesc[it->second].SemanticIndex == semanticIndex)
|
|
break;
|
|
}
|
|
|
|
if (it == range.second)
|
|
return nullptr;
|
|
|
|
return &mInputDesc[ it->second ];
|
|
}
|
|
|
|
XMVECTOR* GetTemporaryBuffer( size_t count ) const
|
|
{
|
|
if ( !mTempBuffer || ( mTempSize < count ) )
|
|
{
|
|
mTempSize = count;
|
|
|
|
for( size_t j = 0; j < c_MaxSlot; ++j )
|
|
{
|
|
if ( mVerts[ j ] > mTempSize )
|
|
mTempSize = mVerts[ j ];
|
|
}
|
|
|
|
mTempBuffer.reset( reinterpret_cast<XMVECTOR*>( _aligned_malloc( sizeof(XMVECTOR) * mTempSize, 16 ) ) );
|
|
if ( !mTempBuffer )
|
|
mTempSize = 0;
|
|
}
|
|
|
|
return mTempBuffer.get();
|
|
}
|
|
|
|
private:
|
|
typedef std::multimap<std::string,uint32_t> SemanticMap;
|
|
|
|
std::vector<InputElementDesc> mInputDesc;
|
|
SemanticMap mSemantics;
|
|
uint32_t mStrides[c_MaxSlot];
|
|
void* mBuffers[c_MaxSlot];
|
|
size_t mVerts[c_MaxSlot];
|
|
uint32_t mDefaultStrides[c_MaxSlot];
|
|
mutable size_t mTempSize;
|
|
mutable ScopedAlignedArrayXMVECTOR mTempBuffer;
|
|
};
|
|
|
|
|
|
//-------------------------------------------------------------------------------------
|
|
_Use_decl_annotations_
|
|
HRESULT VBWriter::Impl::Initialize( const InputElementDesc* vbDecl, size_t nDecl )
|
|
{
|
|
Release();
|
|
|
|
uint32_t offsets[c_MaxSlot];
|
|
|
|
#if defined(__d3d12_h__) || defined(__d3d12_x_h__)
|
|
{
|
|
if (nDecl > D3D12_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT)
|
|
return E_INVALIDARG;
|
|
|
|
D3D12_INPUT_LAYOUT_DESC desc = { reinterpret_cast<const D3D12_INPUT_ELEMENT_DESC*>(vbDecl), UINT(nDecl) };
|
|
if (!IsValid(desc))
|
|
return E_INVALIDARG;
|
|
|
|
ComputeInputLayout(desc, offsets, mDefaultStrides);
|
|
}
|
|
#else
|
|
if (!IsValid(reinterpret_cast<const D3D11_INPUT_ELEMENT_DESC*>(vbDecl), nDecl))
|
|
return E_INVALIDARG;
|
|
|
|
assert(nDecl <= D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT);
|
|
_Analysis_assume_(nDecl <= D3D11_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT);
|
|
|
|
ComputeInputLayout(reinterpret_cast<const D3D11_INPUT_ELEMENT_DESC*>(vbDecl), nDecl, offsets, mDefaultStrides);
|
|
#endif
|
|
|
|
for( uint32_t j = 0; j < nDecl; ++j )
|
|
{
|
|
if ( vbDecl[ j ].InputSlotClass == PER_INSTANCE_DATA )
|
|
{
|
|
// Does not currently support instance data layouts
|
|
Release();
|
|
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
|
}
|
|
|
|
mInputDesc.push_back( vbDecl[ j ] );
|
|
|
|
mInputDesc[ j ].AlignedByteOffset = offsets[ j ];
|
|
|
|
mSemantics.insert( SemanticMap::value_type( vbDecl[ j ].SemanticName, j ) );
|
|
|
|
// Add common aliases
|
|
if ( _stricmp( vbDecl[ j ].SemanticName, "POSITION" ) == 0 )
|
|
{
|
|
mSemantics.insert( SemanticMap::value_type( "SV_Position", j ) );
|
|
}
|
|
else if ( _stricmp( vbDecl[ j ].SemanticName, "SV_Position" ) == 0 )
|
|
{
|
|
mSemantics.insert( SemanticMap::value_type( "POSITION", j ) );
|
|
}
|
|
}
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
|
|
//-------------------------------------------------------------------------------------
|
|
_Use_decl_annotations_
|
|
HRESULT VBWriter::Impl::AddStream( void* vb, size_t nVerts, size_t inputSlot, size_t stride )
|
|
{
|
|
if ( !vb || !nVerts )
|
|
return E_INVALIDARG;
|
|
|
|
if ( nVerts >= UINT32_MAX )
|
|
return E_INVALIDARG;
|
|
|
|
if ( inputSlot >= c_MaxSlot )
|
|
return E_INVALIDARG;
|
|
|
|
if ( stride > c_MaxStride )
|
|
return E_INVALIDARG;
|
|
|
|
mStrides[ inputSlot ] = ( stride > 0 ) ? uint32_t( stride ) : mDefaultStrides[ inputSlot ];
|
|
mBuffers[ inputSlot ] = vb;
|
|
mVerts[ inputSlot ] = nVerts;
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
|
|
//-------------------------------------------------------------------------------------
|
|
#define STORE_VERTS( type, func )\
|
|
for( size_t icount = 0; icount < count; ++icount )\
|
|
{\
|
|
if ( ( ptr + sizeof(type) ) > eptr )\
|
|
return E_UNEXPECTED;\
|
|
func( reinterpret_cast<type*>(ptr), *buffer++ );\
|
|
ptr += stride;\
|
|
}\
|
|
break;
|
|
|
|
#define STORE_VERTS_X2( type, func, x2bias )\
|
|
for( size_t icount = 0; icount < count; ++icount )\
|
|
{\
|
|
if ( ( ptr + sizeof(type) ) > eptr )\
|
|
return E_UNEXPECTED;\
|
|
XMVECTOR v = *buffer++;\
|
|
if (x2bias)\
|
|
{\
|
|
v = XMVectorClamp(v, g_XMNegativeOne, g_XMOne);\
|
|
v = XMVectorMultiplyAdd(v, g_XMOneHalf, g_XMOneHalf);\
|
|
}\
|
|
func( reinterpret_cast<type*>(ptr), v );\
|
|
ptr += stride;\
|
|
}\
|
|
break;
|
|
|
|
_Use_decl_annotations_
|
|
HRESULT VBWriter::Impl::Write( const XMVECTOR* buffer, const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias ) const
|
|
{
|
|
if ( !buffer || !semanticName || !count )
|
|
return E_INVALIDARG;
|
|
|
|
auto range = mSemantics.equal_range( semanticName );
|
|
|
|
auto it = range.first;
|
|
for( ; it != range.second; ++it )
|
|
{
|
|
if ( mInputDesc[ it->second ].SemanticIndex == semanticIndex )
|
|
break;
|
|
}
|
|
|
|
if ( it == range.second )
|
|
return HRESULT_FROM_WIN32( ERROR_INVALID_NAME );
|
|
|
|
uint32_t inputSlot = mInputDesc[ it->second ].InputSlot;
|
|
|
|
auto vb = reinterpret_cast<uint8_t*>( mBuffers[ inputSlot ] );
|
|
if ( !vb )
|
|
return E_FAIL;
|
|
|
|
if ( count > mVerts[ inputSlot ] )
|
|
return E_BOUNDS;
|
|
|
|
uint32_t stride = mStrides[ inputSlot ];
|
|
if ( !stride )
|
|
return E_UNEXPECTED;
|
|
|
|
const uint8_t* eptr = vb + stride * mVerts[ inputSlot ];
|
|
uint8_t* ptr = vb + mInputDesc[ it->second ].AlignedByteOffset;
|
|
|
|
switch( static_cast<int>( mInputDesc[ it->second ].Format ) )
|
|
{
|
|
case DXGI_FORMAT_R32G32B32A32_FLOAT:
|
|
STORE_VERTS( XMFLOAT4, XMStoreFloat4 )
|
|
|
|
case DXGI_FORMAT_R32G32B32A32_UINT:
|
|
STORE_VERTS( XMUINT4, XMStoreUInt4 )
|
|
|
|
case DXGI_FORMAT_R32G32B32A32_SINT:
|
|
STORE_VERTS( XMINT4, XMStoreSInt4 )
|
|
|
|
case DXGI_FORMAT_R32G32B32_FLOAT:
|
|
STORE_VERTS( XMFLOAT3, XMStoreFloat3 )
|
|
|
|
case DXGI_FORMAT_R32G32B32_UINT:
|
|
STORE_VERTS( XMUINT3, XMStoreUInt3 )
|
|
|
|
case DXGI_FORMAT_R32G32B32_SINT:
|
|
STORE_VERTS( XMINT3, XMStoreSInt3 )
|
|
|
|
case DXGI_FORMAT_R16G16B16A16_FLOAT:
|
|
STORE_VERTS( XMHALF4, XMStoreHalf4 )
|
|
|
|
case DXGI_FORMAT_R16G16B16A16_UNORM:
|
|
STORE_VERTS_X2( XMUSHORTN4, XMStoreUShortN4, x2bias )
|
|
|
|
case DXGI_FORMAT_R16G16B16A16_UINT:
|
|
STORE_VERTS( XMUSHORT4, XMStoreUShort4 )
|
|
|
|
case DXGI_FORMAT_R16G16B16A16_SNORM:
|
|
STORE_VERTS( XMSHORTN4, XMStoreShortN4 )
|
|
|
|
case DXGI_FORMAT_R16G16B16A16_SINT:
|
|
STORE_VERTS( XMSHORT4, XMStoreShort4 )
|
|
|
|
case DXGI_FORMAT_R32G32_FLOAT:
|
|
STORE_VERTS( XMFLOAT2, XMStoreFloat2 )
|
|
|
|
case DXGI_FORMAT_R32G32_UINT:
|
|
STORE_VERTS( XMUINT2, XMStoreUInt2 )
|
|
|
|
case DXGI_FORMAT_R32G32_SINT:
|
|
STORE_VERTS( XMINT2, XMStoreSInt2 )
|
|
|
|
case DXGI_FORMAT_R10G10B10A2_UNORM:
|
|
for (size_t icount = 0; icount < count; ++icount)
|
|
{
|
|
if ((ptr + sizeof(XMUDECN4)) > eptr)
|
|
return E_UNEXPECTED;
|
|
XMVECTOR v = *buffer++;
|
|
if (x2bias)
|
|
{
|
|
XMVECTOR v2 = XMVectorClamp(v, g_XMNegativeOne, g_XMOne);
|
|
v2 = XMVectorMultiplyAdd(v2, g_XMOneHalf, g_XMOneHalf);
|
|
v = XMVectorSelect(v, v2, g_XMSelect1110);
|
|
}
|
|
XMStoreUDecN4(reinterpret_cast<XMUDECN4*>(ptr), v);
|
|
ptr += stride;
|
|
}
|
|
break;
|
|
|
|
case DXGI_FORMAT_R10G10B10A2_UINT:
|
|
STORE_VERTS( XMUDEC4, XMStoreUDec4 );
|
|
|
|
case DXGI_FORMAT_R11G11B10_FLOAT:
|
|
STORE_VERTS_X2( XMFLOAT3PK, XMStoreFloat3PK, x2bias )
|
|
|
|
case DXGI_FORMAT_R8G8B8A8_UNORM:
|
|
STORE_VERTS_X2( XMUBYTEN4, XMStoreUByteN4, x2bias )
|
|
|
|
case DXGI_FORMAT_R8G8B8A8_UINT:
|
|
STORE_VERTS( XMUBYTE4, XMStoreUByte4 )
|
|
|
|
case DXGI_FORMAT_R8G8B8A8_SNORM:
|
|
STORE_VERTS( XMBYTEN4, XMStoreByteN4 )
|
|
|
|
case DXGI_FORMAT_R8G8B8A8_SINT:
|
|
STORE_VERTS( XMBYTE4, XMStoreByte4 )
|
|
|
|
case DXGI_FORMAT_R16G16_FLOAT:
|
|
STORE_VERTS( XMHALF2, XMStoreHalf2 )
|
|
|
|
case DXGI_FORMAT_R16G16_UNORM:
|
|
STORE_VERTS_X2( XMUSHORTN2, XMStoreUShortN2, x2bias )
|
|
|
|
case DXGI_FORMAT_R16G16_UINT:
|
|
STORE_VERTS( XMUSHORT2, XMStoreUShort2 )
|
|
|
|
case DXGI_FORMAT_R16G16_SNORM:
|
|
STORE_VERTS( XMSHORTN2, XMStoreShortN2 )
|
|
|
|
case DXGI_FORMAT_R16G16_SINT:
|
|
STORE_VERTS( XMSHORT2, XMStoreShort2 )
|
|
|
|
case DXGI_FORMAT_R32_FLOAT:
|
|
STORE_VERTS( float, XMStoreFloat )
|
|
|
|
case DXGI_FORMAT_R32_UINT:
|
|
for( size_t icount = 0; icount < count; ++icount )
|
|
{
|
|
if ( ( ptr + sizeof(uint32_t) ) > eptr )
|
|
return E_UNEXPECTED;
|
|
XMVECTOR v = XMConvertVectorFloatToUInt( *buffer++, 0 );
|
|
XMStoreInt( reinterpret_cast<uint32_t*>(ptr), v );
|
|
ptr += stride;
|
|
}
|
|
break;
|
|
|
|
case DXGI_FORMAT_R32_SINT:
|
|
for( size_t icount = 0; icount < count; ++icount )
|
|
{
|
|
if ( ( ptr + sizeof(int32_t) ) > eptr )
|
|
return E_UNEXPECTED;
|
|
XMVECTOR v = XMConvertVectorFloatToInt( *buffer++, 0 );
|
|
XMStoreInt( reinterpret_cast<uint32_t*>(ptr), v );
|
|
ptr += stride;
|
|
}
|
|
break;
|
|
|
|
case DXGI_FORMAT_R8G8_UNORM:
|
|
STORE_VERTS_X2( XMUBYTEN2, XMStoreUByteN2, x2bias )
|
|
|
|
case DXGI_FORMAT_R8G8_UINT:
|
|
STORE_VERTS( XMUBYTE2, XMStoreUByte2 )
|
|
|
|
case DXGI_FORMAT_R8G8_SNORM:
|
|
STORE_VERTS( XMBYTEN2, XMStoreByteN2 )
|
|
|
|
case DXGI_FORMAT_R8G8_SINT:
|
|
STORE_VERTS( XMBYTE2, XMStoreByte2 )
|
|
|
|
case DXGI_FORMAT_R16_FLOAT:
|
|
for( size_t icount = 0; icount < count; ++icount )
|
|
{
|
|
if ( ( ptr + sizeof(HALF) ) > eptr )
|
|
return E_UNEXPECTED;
|
|
float f = XMVectorGetX( *buffer++ );
|
|
*reinterpret_cast<HALF*>(ptr) = XMConvertFloatToHalf(f);
|
|
ptr += stride;
|
|
}
|
|
break;
|
|
|
|
case DXGI_FORMAT_R16_UNORM:
|
|
for( size_t icount = 0; icount < count; ++icount )
|
|
{
|
|
if ( ( ptr + sizeof(uint16_t) ) > eptr )
|
|
return E_UNEXPECTED;
|
|
float f = XMVectorGetX( *buffer++ );
|
|
if (x2bias)
|
|
{
|
|
f = std::max<float>(std::min<float>(f, 1.f), -1.f);
|
|
f = f * 0.5f + 0.5f;
|
|
}
|
|
else
|
|
{
|
|
f = std::max<float>(std::min<float>(f, 1.f), 0.f);
|
|
}
|
|
*reinterpret_cast<uint16_t*>(ptr) = static_cast<uint16_t>( f*65535.f + 0.5f );
|
|
ptr += stride;
|
|
}
|
|
break;
|
|
|
|
case DXGI_FORMAT_R16_UINT:
|
|
for( size_t icount = 0; icount < count; ++icount )
|
|
{
|
|
if ( ( ptr + sizeof(uint16_t) ) > eptr )
|
|
return E_UNEXPECTED;
|
|
float f = XMVectorGetX( *buffer++ );
|
|
f = std::max<float>( std::min<float>( f, 65535.f ), 0.f );
|
|
*reinterpret_cast<uint16_t*>(ptr) = static_cast<uint16_t>( f );
|
|
ptr += stride;
|
|
}
|
|
break;
|
|
|
|
case DXGI_FORMAT_R16_SNORM:
|
|
for( size_t icount = 0; icount < count; ++icount )
|
|
{
|
|
if ( ( ptr + sizeof(int16_t) ) > eptr )
|
|
return E_UNEXPECTED;
|
|
float f = XMVectorGetX( *buffer++ );
|
|
f = std::max<float>( std::min<float>( f, 1.f ), -1.f );
|
|
*reinterpret_cast<int16_t*>(ptr) = static_cast<int16_t>( f * 32767.f );
|
|
ptr += stride;
|
|
}
|
|
break;
|
|
|
|
case DXGI_FORMAT_R16_SINT:
|
|
for( size_t icount = 0; icount < count; ++icount )
|
|
{
|
|
if ( ( ptr + sizeof(int16_t) ) > eptr )
|
|
return E_UNEXPECTED;
|
|
float f = XMVectorGetX( *buffer++ );
|
|
f = std::max<float>( std::min<float>( f, 32767.f ), -32767.f );
|
|
*reinterpret_cast<int16_t*>(ptr) = static_cast<int16_t>(f);
|
|
ptr += stride;
|
|
}
|
|
break;
|
|
|
|
case DXGI_FORMAT_R8_UNORM:
|
|
for( size_t icount = 0; icount < count; ++icount )
|
|
{
|
|
if ( ( ptr + sizeof(uint8_t) ) > eptr )
|
|
return E_UNEXPECTED;
|
|
float f = XMVectorGetX( *buffer++ );
|
|
if (x2bias)
|
|
{
|
|
f = std::max<float>(std::min<float>(f, 1.f), -1.f);
|
|
f = f * 0.5f + 0.5f;
|
|
}
|
|
else
|
|
{
|
|
f = std::max<float>(std::min<float>(f, 1.f), 0.f);
|
|
}
|
|
*reinterpret_cast<uint8_t*>(ptr) = static_cast<uint8_t>( f * 255.f );
|
|
ptr += stride;
|
|
}
|
|
break;
|
|
|
|
case DXGI_FORMAT_R8_UINT:
|
|
for( size_t icount = 0; icount < count; ++icount )
|
|
{
|
|
if ( ( ptr + sizeof(uint8_t) ) > eptr )
|
|
return E_UNEXPECTED;
|
|
float f = XMVectorGetX( *buffer++ );
|
|
f = std::max<float>( std::min<float>( f, 255.f ), 0.f );
|
|
*reinterpret_cast<uint8_t*>(ptr) = static_cast<uint8_t>( f );
|
|
ptr += stride;
|
|
}
|
|
break;
|
|
|
|
case DXGI_FORMAT_R8_SNORM:
|
|
for( size_t icount = 0; icount < count; ++icount )
|
|
{
|
|
if ( ( ptr + sizeof(int8_t) ) > eptr )
|
|
return E_UNEXPECTED;
|
|
float f = XMVectorGetX( *buffer++ );
|
|
f = std::max<float>( std::min<float>( f, 1.f ), -1.f );
|
|
*reinterpret_cast<int8_t*>(ptr) = static_cast<int8_t>( f * 127.f );
|
|
ptr += stride;
|
|
}
|
|
break;
|
|
|
|
case DXGI_FORMAT_R8_SINT:
|
|
for( size_t icount = 0; icount < count; ++icount )
|
|
{
|
|
if ( ( ptr + sizeof(int8_t) ) > eptr )
|
|
return E_UNEXPECTED;
|
|
float f = XMVectorGetX( *buffer++ );
|
|
f = std::max<float>( std::min<float>( f, 127.f ), -127.f );
|
|
*reinterpret_cast<int8_t*>(ptr) = static_cast<int8_t>(f);
|
|
ptr += stride;
|
|
}
|
|
break;
|
|
|
|
case DXGI_FORMAT_B5G6R5_UNORM:
|
|
{
|
|
static const XMVECTORF32 s_Scale = { { { 31.f, 63.f, 31.f, 1.f } } };
|
|
for( size_t icount = 0; icount < count; ++icount )
|
|
{
|
|
if ( ( ptr + sizeof(XMU565) ) > eptr )
|
|
return E_UNEXPECTED;
|
|
XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>( *buffer++ );
|
|
if (x2bias)
|
|
{
|
|
v = XMVectorClamp(v, g_XMNegativeOne, g_XMOne);
|
|
v = XMVectorMultiplyAdd(v, g_XMOneHalf, g_XMOneHalf);
|
|
}
|
|
v = XMVectorMultiply( v, s_Scale );
|
|
XMStoreU565( reinterpret_cast<XMU565*>(ptr), v );
|
|
ptr += stride;
|
|
}
|
|
}
|
|
break;
|
|
|
|
case DXGI_FORMAT_B5G5R5A1_UNORM:
|
|
{
|
|
static const XMVECTORF32 s_Scale = { { { 31.f, 31.f, 31.f, 1.f } } };
|
|
for( size_t icount = 0; icount < count; ++icount )
|
|
{
|
|
if ( ( ptr + sizeof(XMU555) ) > eptr )
|
|
return E_UNEXPECTED;
|
|
XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>( *buffer++ );
|
|
if (x2bias)
|
|
{
|
|
XMVECTOR v2 = XMVectorClamp(v, g_XMNegativeOne, g_XMOne);
|
|
v2 = XMVectorMultiplyAdd(v2, g_XMOneHalf, g_XMOneHalf);
|
|
v = XMVectorSelect(v, v2, g_XMSelect1110);
|
|
}
|
|
v = XMVectorMultiply(v, s_Scale);
|
|
XMStoreU555( reinterpret_cast<XMU555*>(ptr), v );
|
|
reinterpret_cast<XMU555*>(ptr)->w = ( XMVectorGetW( v ) > 0.5f ) ? 1 : 0;
|
|
ptr += stride;
|
|
}
|
|
}
|
|
break;
|
|
|
|
case DXGI_FORMAT_B8G8R8A8_UNORM:
|
|
for( size_t icount = 0; icount < count; ++icount )
|
|
{
|
|
if ( ( ptr + sizeof(XMUBYTEN4) ) > eptr )
|
|
return E_UNEXPECTED;
|
|
XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>( *buffer++ );
|
|
if (x2bias)
|
|
{
|
|
v = XMVectorClamp(v, g_XMNegativeOne, g_XMOne);
|
|
v = XMVectorMultiplyAdd(v, g_XMOneHalf, g_XMOneHalf);
|
|
}
|
|
XMStoreUByteN4( reinterpret_cast<XMUBYTEN4*>(ptr), v );
|
|
ptr += stride;
|
|
}
|
|
break;
|
|
|
|
case DXGI_FORMAT_B8G8R8X8_UNORM:
|
|
for( size_t icount = 0; icount < count; ++icount )
|
|
{
|
|
if ( ( ptr + sizeof(XMUBYTEN4) ) > eptr )
|
|
return E_UNEXPECTED;
|
|
XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>( *buffer++ );
|
|
if (x2bias)
|
|
{
|
|
v = XMVectorClamp(v, g_XMNegativeOne, g_XMOne);
|
|
v = XMVectorMultiplyAdd(v, g_XMOneHalf, g_XMOneHalf);
|
|
}
|
|
v = XMVectorSelect(g_XMZero, v, g_XMSelect1110);
|
|
XMStoreUByteN4( reinterpret_cast<XMUBYTEN4*>(ptr), v );
|
|
ptr += stride;
|
|
}
|
|
break;
|
|
|
|
case DXGI_FORMAT_B4G4R4A4_UNORM:
|
|
{
|
|
static const XMVECTORF32 s_Scale = { { { 15.f, 15.f, 15.f, 15.f } } };
|
|
for( size_t icount = 0; icount < count; ++icount )
|
|
{
|
|
if ( ( ptr + sizeof(XMUNIBBLE4) ) > eptr )
|
|
return E_UNEXPECTED;
|
|
XMVECTOR v = XMVectorSwizzle<2, 1, 0, 3>( *buffer++ );
|
|
if (x2bias)
|
|
{
|
|
v = XMVectorClamp(v, g_XMNegativeOne, g_XMOne);
|
|
v = XMVectorMultiplyAdd(v, g_XMOneHalf, g_XMOneHalf);
|
|
}
|
|
v = XMVectorMultiply(v, s_Scale);
|
|
XMStoreUNibble4( reinterpret_cast<XMUNIBBLE4*>(ptr), v );
|
|
ptr += stride;
|
|
}
|
|
}
|
|
break;
|
|
|
|
case XBOX_DXGI_FORMAT_R10G10B10_SNORM_A2_UNORM:
|
|
// Xbox One specific format
|
|
STORE_VERTS( XMXDECN4, XMStoreXDecN4 );
|
|
|
|
default:
|
|
return E_FAIL;
|
|
}
|
|
|
|
return S_OK;
|
|
}
|
|
|
|
|
|
//=====================================================================================
|
|
// Entry-points
|
|
//=====================================================================================
|
|
|
|
// Public constructor.
|
|
VBWriter::VBWriter()
|
|
: pImpl( new Impl() )
|
|
{
|
|
}
|
|
|
|
|
|
// Move constructor.
|
|
VBWriter::VBWriter(VBWriter&& moveFrom)
|
|
: pImpl(std::move(moveFrom.pImpl))
|
|
{
|
|
}
|
|
|
|
|
|
// Move assignment.
|
|
VBWriter& VBWriter::operator= (VBWriter&& moveFrom)
|
|
{
|
|
pImpl = std::move(moveFrom.pImpl);
|
|
return *this;
|
|
}
|
|
|
|
|
|
// Public destructor.
|
|
VBWriter::~VBWriter()
|
|
{
|
|
}
|
|
|
|
|
|
//-------------------------------------------------------------------------------------
|
|
#if defined(__d3d11_h__) || defined(__d3d11_x_h__)
|
|
_Use_decl_annotations_
|
|
HRESULT VBWriter::Initialize( const D3D11_INPUT_ELEMENT_DESC* vbDecl, size_t nDecl )
|
|
{
|
|
return pImpl->Initialize(reinterpret_cast<const InputElementDesc*>(vbDecl), nDecl);
|
|
}
|
|
#endif
|
|
|
|
#if defined(__d3d12_h__) || defined(__d3d12_x_h__)
|
|
HRESULT VBWriter::Initialize( const D3D12_INPUT_LAYOUT_DESC& vbDecl )
|
|
{
|
|
return pImpl->Initialize(reinterpret_cast<const InputElementDesc*>(vbDecl.pInputElementDescs), vbDecl.NumElements);
|
|
}
|
|
#endif
|
|
|
|
|
|
//-------------------------------------------------------------------------------------
|
|
_Use_decl_annotations_
|
|
HRESULT VBWriter::AddStream( void* vb, size_t nVerts, size_t inputSlot, size_t stride )
|
|
{
|
|
return pImpl->AddStream( vb, nVerts, inputSlot, stride );
|
|
}
|
|
|
|
|
|
//-------------------------------------------------------------------------------------
|
|
_Use_decl_annotations_
|
|
HRESULT VBWriter::Write( const XMVECTOR* buffer, const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias ) const
|
|
{
|
|
return pImpl->Write( buffer, semanticName, semanticIndex, count, x2bias );
|
|
}
|
|
|
|
|
|
//-------------------------------------------------------------------------------------
|
|
_Use_decl_annotations_
|
|
HRESULT VBWriter::Write( const float* buffer, const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias ) const
|
|
{
|
|
XMVECTOR* temp = pImpl->GetTemporaryBuffer( count );
|
|
if ( !temp )
|
|
return E_OUTOFMEMORY;
|
|
|
|
XMVECTOR* dptr = temp;
|
|
const float* sptr = buffer;
|
|
for( size_t j = 0; j < count; ++j )
|
|
{
|
|
XMVECTOR v = XMLoadFloat( sptr++ );
|
|
*(dptr)++ = v;
|
|
}
|
|
|
|
return pImpl->Write( temp, semanticName, semanticIndex, count, x2bias );
|
|
}
|
|
|
|
_Use_decl_annotations_
|
|
HRESULT VBWriter::Write( const XMFLOAT2* buffer, const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias ) const
|
|
{
|
|
XMVECTOR* temp = pImpl->GetTemporaryBuffer( count );
|
|
if ( !temp )
|
|
return E_OUTOFMEMORY;
|
|
|
|
XMVECTOR* dptr = temp;
|
|
const XMFLOAT2* sptr = buffer;
|
|
for( size_t j = 0; j < count; ++j )
|
|
{
|
|
XMVECTOR v = XMLoadFloat2( sptr++ );
|
|
*(dptr)++ = v;
|
|
}
|
|
|
|
return pImpl->Write( temp, semanticName, semanticIndex, count, x2bias );
|
|
}
|
|
|
|
_Use_decl_annotations_
|
|
HRESULT VBWriter::Write( const XMFLOAT3* buffer, const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias ) const
|
|
{
|
|
XMVECTOR* temp = pImpl->GetTemporaryBuffer( count );
|
|
if ( !temp )
|
|
return E_OUTOFMEMORY;
|
|
|
|
XMVECTOR* dptr = temp;
|
|
const XMFLOAT3* sptr = buffer;
|
|
for( size_t j = 0; j < count; ++j )
|
|
{
|
|
XMVECTOR v = XMLoadFloat3( sptr++ );
|
|
*(dptr)++ = v;
|
|
}
|
|
|
|
return pImpl->Write( temp, semanticName, semanticIndex, count, x2bias );
|
|
}
|
|
|
|
_Use_decl_annotations_
|
|
HRESULT VBWriter::Write( const XMFLOAT4* buffer, const char* semanticName, unsigned int semanticIndex, size_t count, bool x2bias ) const
|
|
{
|
|
XMVECTOR* temp = pImpl->GetTemporaryBuffer( count );
|
|
if ( !temp )
|
|
return E_OUTOFMEMORY;
|
|
|
|
XMVECTOR* dptr = temp;
|
|
const XMFLOAT4* sptr = buffer;
|
|
for( size_t j = 0; j < count; ++j )
|
|
{
|
|
XMVECTOR v = XMLoadFloat4( sptr++ );
|
|
*(dptr)++ = v;
|
|
}
|
|
|
|
return pImpl->Write( temp, semanticName, semanticIndex, count, x2bias );
|
|
}
|
|
|
|
|
|
//-------------------------------------------------------------------------------------
|
|
void VBWriter::Release()
|
|
{
|
|
pImpl->Release();
|
|
}
|
|
|
|
|
|
//-------------------------------------------------------------------------------------
|
|
#if defined(__d3d11_h__) || defined(__d3d11_x_h__)
|
|
_Use_decl_annotations_
|
|
const D3D11_INPUT_ELEMENT_DESC* VBWriter::GetElement11(const char* semanticName, unsigned int semanticIndex) const
|
|
{
|
|
return reinterpret_cast<const D3D11_INPUT_ELEMENT_DESC*>(pImpl->GetElement(semanticName, semanticIndex));
|
|
}
|
|
#endif
|
|
|
|
#if defined(__d3d12_h__) || defined(__d3d12_x_h__)
|
|
_Use_decl_annotations_
|
|
const D3D12_INPUT_ELEMENT_DESC* VBWriter::GetElement12(const char* semanticName, unsigned int semanticIndex) const
|
|
{
|
|
return reinterpret_cast<const D3D12_INPUT_ELEMENT_DESC*>(pImpl->GetElement(semanticName, semanticIndex));
|
|
}
|
|
#endif
|
|
|
|
} // namespace
|