#pragma region CPL License
/*
Nuclex Native Framework
Copyright (C) 2002-2013 Nuclex Development Labs
This library is free software; you can redistribute it and/or
modify it under the terms of the IBM Common Public License as
published by the IBM Corporation; either version 1.0 of the
License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
IBM Common Public License for more details.
You should have received a copy of the IBM Common Public
License along with this library
*/
#pragma endregion // CPL License
#ifndef NUCLEX_GRAPHICS_RASTERIZATION_DIRECT3D11CONSTANTBUFFEROBSERVER_H
#define NUCLEX_GRAPHICS_RASTERIZATION_DIRECT3D11CONSTANTBUFFEROBSERVER_H
#include "Nuclex/Graphics/Config.h"
#include "Nuclex/Graphics/Rasterization/GenericConstantBuffer.h"
#include "../Direct3D11Api.h"
namespace Nuclex { namespace Graphics { namespace Rasterization {
// ------------------------------------------------------------------------------------------- //
class Direct3D11RasterizerResources;
// ------------------------------------------------------------------------------------------- //
}}} // namespace Nuclex::Graphics::Rasterization
namespace Nuclex { namespace Graphics { namespace Rasterization {
// ------------------------------------------------------------------------------------------- //
///Manages an attached Direct3D 11 constant buffer
class Direct3D11ConstantBufferObserver : public GenericConstantBuffer::Observer {
/// Initializes a new Direct3D 11 constant buffer
/// Manager the index buffer belongs to
/// Index buffer the observer is attached to
public: Direct3D11ConstantBufferObserver(
Direct3D11RasterizerResources &resources, GenericConstantBuffer *indexBuffer
);
/// Frees all resources owned by the constant buffer observer
public: virtual ~Direct3D11ConstantBufferObserver();
/// Called right before the buffer is destroyed
public: void Destroying();
/// Called when the buffer has been cleared
public: void Cleared();
/// Called when the contents of the buffer have changed
///
/// Offset in the buffer from which on its contents have changed
///
/// Number of bytes that have changed in the buffer
public: void Changed(std::size_t offset, std::size_t count);
/// Retrieves the agnostic constant buffer being observed
/// The agnostic constant buffer being observed
public: GenericConstantBuffer *GetResource() const { return this->constantBuffer; }
/// Retrieves the Direct3D constant buffer the observer is managing
/// The observer's Direct3D constant buffer
public: const ID3D11BufferPtr &GetDirect3DConstantBuffer() const {
return this->direct3DConstantBuffer;
}
/// Creates a Direct3D constant buffer matching the observed one
private: void createDirect3DConstantBuffer();
private: Direct3D11ConstantBufferObserver(const Direct3D11ConstantBufferObserver &);
private: Direct3D11ConstantBufferObserver &operator =(
const Direct3D11ConstantBufferObserver &
);
/// Resource manager the constant buffer observer belongs to
private: Direct3D11RasterizerResources &resources;
/// Constant buffer this observer is attached to
private: GenericConstantBuffer *constantBuffer;
/// Constant buffer managed by this observer
private: ID3D11BufferPtr direct3DConstantBuffer;
/// Whether the Direct3D device supports NoOverwrite locks
private: bool noOverwriteLockSupported;
/// Number of bytes currently used by the buffer
private: std::size_t usedBytes;
};
// ------------------------------------------------------------------------------------------- //
}}} // namespace Nuclex::Graphics::Rasterization
#endif // NUCLEX_GRAPHICS_RASTERIZATION_DIRECT3D11CONSTANTBUFFEROBSERVER_H