Graphics API decouple part2
This commit is contained in:
@@ -89,7 +89,7 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID){
|
||||
wiRenderer::SetClipPlane(XMFLOAT4(0, 0, 0, 0), threadID);
|
||||
|
||||
wiRenderer::DrawWorld(wiRenderer::getCamera(), false, tessellationQuality, threadID, false, false
|
||||
, SHADERTYPE_DEFERRED, rtReflection.shaderResource.front(), true, GRAPHICSTHREAD_SCENE);
|
||||
, SHADERTYPE_DEFERRED, rtReflection.GetTexture(), true, GRAPHICSTHREAD_SCENE);
|
||||
|
||||
wiRenderer::DrawSky(threadID);
|
||||
|
||||
@@ -101,7 +101,7 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID){
|
||||
fx.sampleFlag = SAMPLEMODE_CLAMP;
|
||||
fx.quality = QUALITY_NEAREST;
|
||||
fx.process.setLinDepth(true);
|
||||
wiImage::Draw(rtGBuffer.depth->shaderResource, fx, threadID);
|
||||
wiImage::Draw(rtGBuffer.depth->GetTexture(), fx, threadID);
|
||||
fx.process.clear();
|
||||
}
|
||||
rtLinearDepth.Deactivate(threadID);
|
||||
@@ -110,7 +110,7 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID){
|
||||
|
||||
wiRenderer::graphicsDevice->UnbindTextures(TEXSLOT_ONDEMAND0, TEXSLOT_ONDEMAND_COUNT, threadID);
|
||||
|
||||
wiRenderer::UpdateDepthBuffer(dtDepthCopy.shaderResource, rtLinearDepth.shaderResource.front(), threadID);
|
||||
wiRenderer::UpdateDepthBuffer(dtDepthCopy.GetTexture(), rtLinearDepth.GetTexture(), threadID);
|
||||
|
||||
if (getStereogramEnabled())
|
||||
{
|
||||
@@ -124,7 +124,7 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID){
|
||||
}
|
||||
rtGBuffer.Deactivate(threadID);
|
||||
|
||||
wiRenderer::UpdateGBuffer(rtGBuffer.shaderResource, threadID);
|
||||
wiRenderer::UpdateGBuffer(rtGBuffer.GetTexture(0), rtGBuffer.GetTexture(1), rtGBuffer.GetTexture(2), nullptr, nullptr, threadID);
|
||||
|
||||
rtLight.Activate(threadID, rtGBuffer.depth); {
|
||||
wiRenderer::DrawLights(wiRenderer::getCamera(), threadID);
|
||||
@@ -149,13 +149,13 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID){
|
||||
fx.blur = getSSAOBlur();
|
||||
fx.blurDir = 0;
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
wiImage::Draw(rtSSAO[0].shaderResource.back(), fx, threadID);
|
||||
wiImage::Draw(rtSSAO[0].GetTexture(), fx, threadID);
|
||||
}
|
||||
rtSSAO[2].Activate(threadID); {
|
||||
fx.blur = getSSAOBlur();
|
||||
fx.blurDir = 1;
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
wiImage::Draw(rtSSAO[1].shaderResource.back(), fx, threadID);
|
||||
wiImage::Draw(rtSSAO[1].GetTexture(), fx, threadID);
|
||||
fx.blur = 0;
|
||||
}
|
||||
fx.stencilRef = 0;
|
||||
@@ -164,9 +164,9 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID){
|
||||
|
||||
|
||||
rtDeferred.Activate(threadID); {
|
||||
wiImage::DrawDeferred(rtGBuffer.shaderResource[0]
|
||||
, rtLinearDepth.shaderResource.back(), rtLight.shaderResource.front(), rtGBuffer.shaderResource[1]
|
||||
, getSSAOEnabled() ? rtSSAO.back().shaderResource.back() : wiTextureHelper::getInstance()->getWhite()
|
||||
wiImage::DrawDeferred(rtGBuffer.GetTexture(0)
|
||||
, rtLinearDepth.GetTexture(), rtLight.GetTexture(), rtGBuffer.GetTexture(1)
|
||||
, getSSAOEnabled() ? rtSSAO.back().GetTexture() : wiTextureHelper::getInstance()->getWhite()
|
||||
, threadID, 0);
|
||||
wiRenderer::DrawDebugBoneLines(wiRenderer::getCamera(), threadID);
|
||||
wiRenderer::DrawDebugLines(wiRenderer::getCamera(), threadID);
|
||||
@@ -191,9 +191,9 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID){
|
||||
dir.y = stren;
|
||||
fx.process.setSSSS(dir);
|
||||
if (i == 0)
|
||||
wiImage::Draw(rtDeferred.shaderResource.back(), fx, threadID);
|
||||
wiImage::Draw(rtDeferred.GetTexture(), fx, threadID);
|
||||
else
|
||||
wiImage::Draw(rtSSS[i - 1].shaderResource.back(), fx, threadID);
|
||||
wiImage::Draw(rtSSS[i - 1].GetTexture(), fx, threadID);
|
||||
}
|
||||
fx.process.clear();
|
||||
rtSSS.back().Activate(threadID, rtGBuffer.depth); {
|
||||
@@ -204,10 +204,10 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID){
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
fx.stencilRef = 0;
|
||||
fx.stencilComp = 0;
|
||||
wiImage::Draw(rtDeferred.shaderResource.front(), fx, threadID);
|
||||
wiImage::Draw(rtDeferred.GetTexture(), fx, threadID);
|
||||
fx.stencilRef = STENCILREF_SKIN;
|
||||
fx.stencilComp = COMPARISON_LESS;
|
||||
wiImage::Draw(rtSSS[rtSSS.size() - 2].shaderResource.back(), fx, threadID);
|
||||
wiImage::Draw(rtSSS[rtSSS.size() - 2].GetTexture(), fx, threadID);
|
||||
}
|
||||
|
||||
fx.stencilRef = 0;
|
||||
@@ -216,16 +216,16 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID){
|
||||
|
||||
if (getSSREnabled()){
|
||||
rtSSR.Activate(threadID); {
|
||||
wiRenderer::graphicsDevice->GenerateMips(rtDeferred.shaderResource[0], threadID);
|
||||
wiRenderer::graphicsDevice->GenerateMips(rtDeferred.GetTexture(0), threadID);
|
||||
fx.process.setSSR(true);
|
||||
//fx.setDepthMap(dtDepthCopy.shaderResource);
|
||||
//fx.setNormalMap(rtGBuffer.shaderResource[1]);
|
||||
//fx.setVelocityMap(rtGBuffer.shaderResource[2]);
|
||||
fx.setMaskMap(rtLinearDepth.shaderResource.front());
|
||||
fx.setMaskMap(rtLinearDepth.GetTexture());
|
||||
if (getSSSEnabled())
|
||||
wiImage::Draw(rtSSS.back().shaderResource.front(), fx, threadID);
|
||||
wiImage::Draw(rtSSS.back().GetTexture(), fx, threadID);
|
||||
else
|
||||
wiImage::Draw(rtDeferred.shaderResource.front(), fx, threadID);
|
||||
wiImage::Draw(rtDeferred.GetTexture(), fx, threadID);
|
||||
fx.process.clear();
|
||||
}
|
||||
}
|
||||
@@ -237,14 +237,14 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID){
|
||||
//fx.setDepthMap(rtLinearDepth.shaderResource.back());
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
if (getSSREnabled()){
|
||||
wiImage::Draw(rtSSR.shaderResource.front(), fx, threadID);
|
||||
wiImage::Draw(rtSSR.GetTexture(), fx, threadID);
|
||||
}
|
||||
else if (getSSSEnabled())
|
||||
{
|
||||
wiImage::Draw(rtSSS.back().shaderResource.front(), fx, threadID);
|
||||
wiImage::Draw(rtSSS.back().GetTexture(), fx, threadID);
|
||||
}
|
||||
else{
|
||||
wiImage::Draw(rtDeferred.shaderResource.front(), fx, threadID);
|
||||
wiImage::Draw(rtDeferred.GetTexture(), fx, threadID);
|
||||
}
|
||||
fx.process.clear();
|
||||
}
|
||||
|
||||
@@ -91,12 +91,12 @@ void ForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
|
||||
fx.quality = QUALITY_NEAREST;
|
||||
fx.process.setLinDepth(true);
|
||||
//wiImage::BatchBegin(threadID);
|
||||
wiImage::Draw(rtMain.depth->shaderResource, fx, threadID);
|
||||
wiImage::Draw(rtMain.depth->GetTexture(), fx, threadID);
|
||||
}
|
||||
rtLinearDepth.Deactivate(threadID);
|
||||
dtDepthCopy.CopyFrom(*rtMain.depth, threadID);
|
||||
|
||||
wiRenderer::UpdateDepthBuffer(dtDepthCopy.shaderResource, rtLinearDepth.shaderResource.front(), threadID);
|
||||
wiRenderer::UpdateDepthBuffer(dtDepthCopy.GetTexture(), rtLinearDepth.GetTexture(), threadID);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ void Renderable2DComponent::Compose()
|
||||
wiImageEffects fx((float)wiRenderer::GetScreenWidth(), (float)wiRenderer::GetScreenHeight());
|
||||
fx.presentFullScreen = true;
|
||||
|
||||
wiImage::Draw(rtFinal.shaderResource.back(), fx);
|
||||
wiImage::Draw(rtFinal.GetTexture(), fx);
|
||||
|
||||
RenderableComponent::Compose();
|
||||
}
|
||||
|
||||
@@ -286,9 +286,9 @@ void Renderable3DComponent::RenderSecondaryScene(wiRenderTarget& mainRT, wiRende
|
||||
|
||||
//wiRenderer::UnbindTextures(TEXSLOT_ONDEMAND0, TEXSLOT_ONDEMAND_COUNT, threadID);
|
||||
rtTransparent.Activate(threadID, mainRT.depth); {
|
||||
wiRenderer::DrawWorldTransparent(wiRenderer::getCamera(), shadedSceneRT.shaderResource.front(), rtReflection.shaderResource.front()
|
||||
, rtWaterRipple.shaderResource.back(), threadID);
|
||||
wiRenderer::DrawTrails(threadID, shadedSceneRT.shaderResource.front());
|
||||
wiRenderer::DrawWorldTransparent(wiRenderer::getCamera(), shadedSceneRT.GetTexture(), rtReflection.GetTexture()
|
||||
, rtWaterRipple.GetTexture(), threadID);
|
||||
wiRenderer::DrawTrails(threadID, shadedSceneRT.GetTexture());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -310,26 +310,26 @@ void Renderable3DComponent::RenderBloom(GRAPHICSTHREAD threadID)
|
||||
fx.bloom.threshold = getBloomThreshold();
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
fx.sampleFlag = SAMPLEMODE_CLAMP;
|
||||
wiImage::Draw(rtFinal[0].shaderResource.front(), fx, threadID);
|
||||
wiImage::Draw(rtFinal[0].GetTexture(), fx, threadID);
|
||||
}
|
||||
|
||||
|
||||
rtBloom[1].Activate(threadID); //horizontal
|
||||
{
|
||||
wiRenderer::graphicsDevice->GenerateMips(rtBloom[0].shaderResource[0], threadID);
|
||||
wiRenderer::graphicsDevice->GenerateMips(rtBloom[0].GetTexture(), threadID);
|
||||
//wiRenderer::graphicsDevice->GenerateMips(rtBloom[0].shaderResource[0], threadID);
|
||||
fx.mipLevel = 5.32f;
|
||||
fx.blur = getBloomStrength();
|
||||
fx.blurDir = 0;
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
wiImage::Draw(rtBloom[0].shaderResource.back(), fx, threadID);
|
||||
wiImage::Draw(rtBloom[0].GetTexture(), fx, threadID);
|
||||
}
|
||||
rtBloom[2].Activate(threadID); //vertical
|
||||
{
|
||||
fx.blur = getBloomStrength();
|
||||
fx.blurDir = 1;
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
wiImage::Draw(rtBloom[1].shaderResource.back(), fx, threadID);
|
||||
wiImage::Draw(rtBloom[1].GetTexture(), fx, threadID);
|
||||
}
|
||||
}
|
||||
void Renderable3DComponent::RenderLightShafts(wiRenderTarget& mainRT, GRAPHICSTHREAD threadID)
|
||||
@@ -363,7 +363,7 @@ void Renderable3DComponent::RenderLightShafts(wiRenderTarget& mainRT, GRAPHICSTH
|
||||
XMVECTOR sunPos = XMVector3Project(wiRenderer::GetSunPosition() * 100000, 0, 0, (float)wiRenderer::GetScreenWidth(), (float)wiRenderer::GetScreenHeight(), 0.1f, 1.0f, wiRenderer::getCamera()->GetProjection(), wiRenderer::getCamera()->GetView(), XMMatrixIdentity());
|
||||
{
|
||||
XMStoreFloat2(&fxs.sunPos, sunPos);
|
||||
wiImage::Draw(rtSun[0].shaderResource.back(), fxs, threadID);
|
||||
wiImage::Draw(rtSun[0].GetTexture(), fxs, threadID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -381,27 +381,27 @@ void Renderable3DComponent::RenderComposition1(wiRenderTarget& shadedSceneRT, GR
|
||||
rtFinal[0].Activate(threadID);
|
||||
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
wiImage::Draw(shadedSceneRT.shaderResource.front(), fx, threadID);
|
||||
wiImage::Draw(shadedSceneRT.GetTexture(), fx, threadID);
|
||||
|
||||
|
||||
fx.blendFlag = BLENDMODE_ALPHA;
|
||||
wiImage::Draw(rtTransparent.shaderResource.back(), fx, threadID);
|
||||
wiImage::Draw(rtTransparent.GetTexture(), fx, threadID);
|
||||
if (getEmittedParticlesEnabled()){
|
||||
wiImage::Draw(rtParticle.shaderResource.back(), fx, threadID);
|
||||
wiImage::Draw(rtParticle.GetTexture(), fx, threadID);
|
||||
}
|
||||
|
||||
fx.blendFlag = BLENDMODE_ADDITIVE;
|
||||
if (getVolumeLightsEnabled()){
|
||||
wiImage::Draw(rtVolumeLight.shaderResource.back(), fx, threadID);
|
||||
wiImage::Draw(rtVolumeLight.GetTexture(), fx, threadID);
|
||||
}
|
||||
if (getEmittedParticlesEnabled()){
|
||||
wiImage::Draw(rtParticleAdditive.shaderResource.back(), fx, threadID);
|
||||
wiImage::Draw(rtParticleAdditive.GetTexture(), fx, threadID);
|
||||
}
|
||||
if (getLightShaftsEnabled()){
|
||||
wiImage::Draw(rtSun.back().shaderResource.back(), fx, threadID);
|
||||
wiImage::Draw(rtSun.back().GetTexture(), fx, threadID);
|
||||
}
|
||||
if (getLensFlareEnabled()){
|
||||
wiImage::Draw(rtLensFlare.shaderResource.back(), fx, threadID);
|
||||
wiImage::Draw(rtLensFlare.GetTexture(), fx, threadID);
|
||||
}
|
||||
}
|
||||
void Renderable3DComponent::RenderComposition2(GRAPHICSTHREAD threadID){
|
||||
@@ -420,20 +420,20 @@ void Renderable3DComponent::RenderComposition2(GRAPHICSTHREAD threadID){
|
||||
rtDof[0].Activate(threadID);
|
||||
fx.blur = getDepthOfFieldStrength();
|
||||
fx.blurDir = 0;
|
||||
wiImage::Draw(rtFinal[0].shaderResource.back(), fx, threadID);
|
||||
wiImage::Draw(rtFinal[0].GetTexture(), fx, threadID);
|
||||
|
||||
rtDof[1].Activate(threadID);
|
||||
fx.blurDir = 1;
|
||||
wiImage::Draw(rtDof[0].shaderResource.back(), fx, threadID);
|
||||
wiImage::Draw(rtDof[0].GetTexture(), fx, threadID);
|
||||
fx.blur = 0;
|
||||
fx.process.clear();
|
||||
|
||||
// depth of field compose pass
|
||||
rtDof[2].Activate(threadID);
|
||||
fx.process.setDOF(getDepthOfFieldFocus());
|
||||
fx.setMaskMap(rtDof[1].shaderResource.back());
|
||||
fx.setMaskMap(rtDof[1].GetTexture());
|
||||
//fx.setDepthMap(rtLinearDepth.shaderResource.back());
|
||||
wiImage::Draw(rtFinal[0].shaderResource.back(), fx, threadID);
|
||||
wiImage::Draw(rtFinal[0].GetTexture(), fx, threadID);
|
||||
fx.setMaskMap(nullptr);
|
||||
//fx.setDepthMap(nullptr);
|
||||
fx.process.clear();
|
||||
@@ -443,16 +443,16 @@ void Renderable3DComponent::RenderComposition2(GRAPHICSTHREAD threadID){
|
||||
|
||||
fx.process.setFXAA(getFXAAEnabled());
|
||||
if (getDepthOfFieldEnabled())
|
||||
wiImage::Draw(rtDof[2].shaderResource.back(), fx, threadID);
|
||||
wiImage::Draw(rtDof[2].GetTexture(), fx, threadID);
|
||||
else
|
||||
wiImage::Draw(rtFinal[0].shaderResource.back(), fx, threadID);
|
||||
wiImage::Draw(rtFinal[0].GetTexture(), fx, threadID);
|
||||
fx.process.clear();
|
||||
|
||||
if (getBloomEnabled())
|
||||
{
|
||||
fx.blendFlag = BLENDMODE_ADDITIVE;
|
||||
fx.presentFullScreen = true;
|
||||
wiImage::Draw(rtBloom.back().shaderResource.back(), fx, threadID);
|
||||
wiImage::Draw(rtBloom.back().GetTexture(), fx, threadID);
|
||||
}
|
||||
}
|
||||
void Renderable3DComponent::RenderColorGradedComposition(){
|
||||
@@ -488,7 +488,7 @@ void Renderable3DComponent::RenderColorGradedComposition(){
|
||||
fx.presentFullScreen = true;
|
||||
}
|
||||
|
||||
wiImage::Draw(rtFinal[1].shaderResource.back(), fx);
|
||||
wiImage::Draw(rtFinal[1].GetTexture(), fx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ Luna<Texture_BindLua>::PropertyType Texture_BindLua::properties[] = {
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
Texture_BindLua::Texture_BindLua(TextureView texture) :texture(texture)
|
||||
Texture_BindLua::Texture_BindLua(Texture2D* texture) :texture(texture)
|
||||
{
|
||||
}
|
||||
Texture_BindLua::Texture_BindLua(lua_State *L)
|
||||
|
||||
@@ -6,13 +6,13 @@
|
||||
class Texture_BindLua
|
||||
{
|
||||
public:
|
||||
TextureView texture;
|
||||
Texture2D* texture;
|
||||
|
||||
static const char className[];
|
||||
static Luna<Texture_BindLua>::FunctionType methods[];
|
||||
static Luna<Texture_BindLua>::PropertyType properties[];
|
||||
|
||||
Texture_BindLua(TextureView texture = nullptr);
|
||||
Texture_BindLua(Texture2D* texture = nullptr);
|
||||
Texture_BindLua(lua_State *L);
|
||||
~Texture_BindLua();
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ float wiBackLog::pos;
|
||||
int wiBackLog::scroll;
|
||||
stringstream wiBackLog::inputArea;
|
||||
int wiBackLog::historyPos=0;
|
||||
TextureView wiBackLog::backgroundTex = nullptr;
|
||||
Texture2D* wiBackLog::backgroundTex = nullptr;
|
||||
wiFont wiBackLog::font;
|
||||
|
||||
void wiBackLog::Initialize(){
|
||||
@@ -144,7 +144,7 @@ void wiBackLog::historyNext(){
|
||||
}
|
||||
}
|
||||
|
||||
void wiBackLog::setBackground(TextureView texture)
|
||||
void wiBackLog::setBackground(Texture2D* texture)
|
||||
{
|
||||
backgroundTex = texture;
|
||||
}
|
||||
|
||||
@@ -45,9 +45,9 @@ public:
|
||||
|
||||
static bool isActive(){return state==IDLE;}
|
||||
|
||||
static void setBackground(TextureView texture);
|
||||
static void setBackground(Texture2D* texture);
|
||||
|
||||
static TextureView backgroundTex;
|
||||
static Texture2D* backgroundTex;
|
||||
static wiFont font;
|
||||
};
|
||||
|
||||
|
||||
@@ -4,21 +4,26 @@
|
||||
|
||||
wiDepthTarget::wiDepthTarget()
|
||||
{
|
||||
texture2D = NULL;
|
||||
depthTarget = NULL;
|
||||
shaderResource = NULL;
|
||||
//texture2D = NULL;
|
||||
//depthTarget = NULL;
|
||||
//shaderResource = NULL;
|
||||
texture = nullptr;
|
||||
isCube = false;
|
||||
}
|
||||
|
||||
|
||||
wiDepthTarget::~wiDepthTarget()
|
||||
{
|
||||
if(texture2D) texture2D->Release(); texture2D = NULL;
|
||||
if(depthTarget) depthTarget->Release(); depthTarget = NULL;
|
||||
if(shaderResource) shaderResource->Release(); shaderResource = NULL;
|
||||
//if(texture2D) texture2D->Release(); texture2D = NULL;
|
||||
//if(depthTarget) depthTarget->Release(); depthTarget = NULL;
|
||||
//if(shaderResource) shaderResource->Release(); shaderResource = NULL;
|
||||
SAFE_DELETE(texture);
|
||||
}
|
||||
|
||||
void wiDepthTarget::Initialize(int width, int height, UINT MSAAC, UINT MSAAQ)
|
||||
{
|
||||
isCube = false;
|
||||
|
||||
Texture2DDesc depthBufferDesc;
|
||||
ZeroMemory(&depthBufferDesc, sizeof(depthBufferDesc));
|
||||
|
||||
@@ -35,33 +40,37 @@ void wiDepthTarget::Initialize(int width, int height, UINT MSAAC, UINT MSAAQ)
|
||||
depthBufferDesc.CPUAccessFlags = 0;
|
||||
depthBufferDesc.MiscFlags = 0;
|
||||
|
||||
HRESULT hr;
|
||||
// Create the texture for the depth buffer using the filled out description.
|
||||
hr=wiRenderer::graphicsDevice->CreateTexture2D(&depthBufferDesc, nullptr, &texture2D);
|
||||
wiRenderer::graphicsDevice->CreateTexture2D(&depthBufferDesc, nullptr, &texture);
|
||||
|
||||
DepthStencilViewDesc depthStencilViewDesc;
|
||||
ZeroMemory(&depthStencilViewDesc, sizeof(depthStencilViewDesc));
|
||||
depthStencilViewDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
|
||||
depthStencilViewDesc.ViewDimension = (MSAAQ==0 ? RESOURCE_DIMENSION_TEXTURE2D : RESOURCE_DIMENSION_TEXTURE2DMS);
|
||||
//depthStencilViewDesc.Texture2D.MipSlice = 0;
|
||||
depthStencilViewDesc.Flags = 0;
|
||||
//HRESULT hr;
|
||||
//// Create the texture for the depth buffer using the filled out description.
|
||||
//hr=wiRenderer::graphicsDevice->CreateTexture2D(&depthBufferDesc, nullptr, &texture2D);
|
||||
|
||||
// Create the depth stencil view.
|
||||
hr=wiRenderer::graphicsDevice->CreateDepthStencilView(texture2D, &depthStencilViewDesc, &depthTarget);
|
||||
//DepthStencilViewDesc depthStencilViewDesc;
|
||||
//ZeroMemory(&depthStencilViewDesc, sizeof(depthStencilViewDesc));
|
||||
//depthStencilViewDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
|
||||
//depthStencilViewDesc.ViewDimension = (MSAAQ==0 ? RESOURCE_DIMENSION_TEXTURE2D : RESOURCE_DIMENSION_TEXTURE2DMS);
|
||||
////depthStencilViewDesc.Texture2D.MipSlice = 0;
|
||||
//depthStencilViewDesc.Flags = 0;
|
||||
|
||||
//Create Depth ShaderResource
|
||||
//ShaderResourceViewDesc shaderResourceViewDesc;
|
||||
ZeroMemory(&shaderResourceViewDesc, sizeof(shaderResourceViewDesc));
|
||||
shaderResourceViewDesc.Format = DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
|
||||
shaderResourceViewDesc.ViewDimension = (MSAAQ==0 ? RESOURCE_DIMENSION_TEXTURE2D : RESOURCE_DIMENSION_TEXTURE2DMS);
|
||||
//shaderResourceViewDesc.Texture2D.MostDetailedMip = 0;
|
||||
//shaderResourceViewDesc.Texture2D.MipLevels = 1;
|
||||
shaderResourceViewDesc.mipLevels = 1;
|
||||
//// Create the depth stencil view.
|
||||
//hr=wiRenderer::graphicsDevice->CreateDepthStencilView(texture2D, &depthStencilViewDesc, &depthTarget);
|
||||
|
||||
wiRenderer::graphicsDevice->CreateShaderResourceView(texture2D, &shaderResourceViewDesc, &shaderResource);
|
||||
////Create Depth ShaderResource
|
||||
////ShaderResourceViewDesc shaderResourceViewDesc;
|
||||
//ZeroMemory(&shaderResourceViewDesc, sizeof(shaderResourceViewDesc));
|
||||
//shaderResourceViewDesc.Format = DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
|
||||
//shaderResourceViewDesc.ViewDimension = (MSAAQ==0 ? RESOURCE_DIMENSION_TEXTURE2D : RESOURCE_DIMENSION_TEXTURE2DMS);
|
||||
////shaderResourceViewDesc.Texture2D.MostDetailedMip = 0;
|
||||
////shaderResourceViewDesc.Texture2D.MipLevels = 1;
|
||||
//shaderResourceViewDesc.mipLevels = 1;
|
||||
|
||||
//wiRenderer::graphicsDevice->CreateShaderResourceView(texture2D, &shaderResourceViewDesc, &shaderResource);
|
||||
}
|
||||
void wiDepthTarget::InitializeCube(int size)
|
||||
{
|
||||
isCube = true;
|
||||
|
||||
Texture2DDesc depthBufferDesc;
|
||||
ZeroMemory(&depthBufferDesc, sizeof(depthBufferDesc));
|
||||
|
||||
@@ -78,45 +87,49 @@ void wiDepthTarget::InitializeCube(int size)
|
||||
depthBufferDesc.CPUAccessFlags = 0;
|
||||
depthBufferDesc.MiscFlags = RESOURCE_MISC_TEXTURECUBE;
|
||||
|
||||
HRESULT hr;
|
||||
// Create the texture for the depth buffer using the filled out description.
|
||||
hr=wiRenderer::graphicsDevice->CreateTexture2D(&depthBufferDesc, NULL, &texture2D);
|
||||
wiRenderer::graphicsDevice->CreateTextureCube(&depthBufferDesc, nullptr, &textureCube);
|
||||
|
||||
DepthStencilViewDesc depthStencilViewDesc;
|
||||
ZeroMemory(&depthStencilViewDesc, sizeof(depthStencilViewDesc));
|
||||
depthStencilViewDesc.Format = DXGI_FORMAT_D32_FLOAT;
|
||||
depthStencilViewDesc.ViewDimension = RESOURCE_DIMENSION_TEXTURE2DARRAY;
|
||||
// depthStencilViewDesc.Texture2DArray.FirstArraySlice = 0;
|
||||
//depthStencilViewDesc.Texture2DArray.ArraySize = 6;
|
||||
// depthStencilViewDesc.Texture2DArray.MipSlice = 0;
|
||||
depthStencilViewDesc.ArraySize = 6;
|
||||
depthStencilViewDesc.Flags = 0;
|
||||
//HRESULT hr;
|
||||
//// Create the texture for the depth buffer using the filled out description.
|
||||
//hr=wiRenderer::graphicsDevice->CreateTexture2D(&depthBufferDesc, NULL, &texture2D);
|
||||
|
||||
// Create the depth stencil view.
|
||||
hr=wiRenderer::graphicsDevice->CreateDepthStencilView(texture2D, &depthStencilViewDesc, &depthTarget);
|
||||
//DepthStencilViewDesc depthStencilViewDesc;
|
||||
//ZeroMemory(&depthStencilViewDesc, sizeof(depthStencilViewDesc));
|
||||
//depthStencilViewDesc.Format = DXGI_FORMAT_D32_FLOAT;
|
||||
//depthStencilViewDesc.ViewDimension = RESOURCE_DIMENSION_TEXTURE2DARRAY;
|
||||
//// depthStencilViewDesc.Texture2DArray.FirstArraySlice = 0;
|
||||
////depthStencilViewDesc.Texture2DArray.ArraySize = 6;
|
||||
//// depthStencilViewDesc.Texture2DArray.MipSlice = 0;
|
||||
//depthStencilViewDesc.ArraySize = 6;
|
||||
//depthStencilViewDesc.Flags = 0;
|
||||
|
||||
//Create Depth ShaderResource
|
||||
//ShaderResourceViewDesc shaderResourceViewDesc;
|
||||
ZeroMemory(&shaderResourceViewDesc, sizeof(shaderResourceViewDesc));
|
||||
shaderResourceViewDesc.Format = DXGI_FORMAT_R32_FLOAT;
|
||||
shaderResourceViewDesc.ViewDimension = RESOURCE_DIMENSION_TEXTURECUBE;
|
||||
//shaderResourceViewDesc.Texture2D.MostDetailedMip = 0;
|
||||
//shaderResourceViewDesc.Texture2D.MipLevels = 1;
|
||||
shaderResourceViewDesc.mipLevels = 1;
|
||||
//// Create the depth stencil view.
|
||||
//hr=wiRenderer::graphicsDevice->CreateDepthStencilView(texture2D, &depthStencilViewDesc, &depthTarget);
|
||||
|
||||
wiRenderer::graphicsDevice->CreateShaderResourceView(texture2D, &shaderResourceViewDesc, &shaderResource);
|
||||
////Create Depth ShaderResource
|
||||
////ShaderResourceViewDesc shaderResourceViewDesc;
|
||||
//ZeroMemory(&shaderResourceViewDesc, sizeof(shaderResourceViewDesc));
|
||||
//shaderResourceViewDesc.Format = DXGI_FORMAT_R32_FLOAT;
|
||||
//shaderResourceViewDesc.ViewDimension = RESOURCE_DIMENSION_TEXTURECUBE;
|
||||
////shaderResourceViewDesc.Texture2D.MostDetailedMip = 0;
|
||||
////shaderResourceViewDesc.Texture2D.MipLevels = 1;
|
||||
//shaderResourceViewDesc.mipLevels = 1;
|
||||
|
||||
//wiRenderer::graphicsDevice->CreateShaderResourceView(texture2D, &shaderResourceViewDesc, &shaderResource);
|
||||
}
|
||||
|
||||
void wiDepthTarget::Clear(GRAPHICSTHREAD threadID)
|
||||
{
|
||||
wiRenderer::graphicsDevice->ClearDepthStencil( depthTarget, CLEAR_DEPTH | CLEAR_STENCIL, 1.0f, 0);
|
||||
wiRenderer::graphicsDevice->ClearDepthStencil( texture, CLEAR_DEPTH | CLEAR_STENCIL, 1.0f, 0);
|
||||
}
|
||||
void wiDepthTarget::CopyFrom(const wiDepthTarget& from, GRAPHICSTHREAD threadID)
|
||||
{
|
||||
if(shaderResource) shaderResource->Release();
|
||||
//static ShaderResourceViewDesc desc;
|
||||
//from.shaderResource->GetDesc(&desc);
|
||||
wiRenderer::graphicsDevice->CopyResource(texture2D,from.texture2D);
|
||||
HRESULT r = wiRenderer::graphicsDevice->CreateShaderResourceView(texture2D,&from.shaderResourceViewDesc,&shaderResource);
|
||||
//if(shaderResource) shaderResource->Release();
|
||||
////static ShaderResourceViewDesc desc;
|
||||
////from.shaderResource->GetDesc(&desc);
|
||||
//wiRenderer::graphicsDevice->CopyResource(texture2D,from.texture2D);
|
||||
//HRESULT r = wiRenderer::graphicsDevice->CreateShaderResourceView(texture2D,&from.shaderResourceViewDesc,&shaderResource);
|
||||
|
||||
wiRenderer::graphicsDevice->CopyTexture2D(GetTexture(), from.GetTexture(), threadID);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,12 +4,17 @@
|
||||
|
||||
class wiDepthTarget
|
||||
{
|
||||
private:
|
||||
Texture2D* texture;
|
||||
TextureCube* textureCube;
|
||||
bool isCube;
|
||||
public:
|
||||
Texture2D texture2D;
|
||||
DepthStencilView depthTarget;
|
||||
TextureView shaderResource;
|
||||
//Texture2D texture2D;
|
||||
//DepthStencilView depthTarget;
|
||||
//Texture2D* shaderResource;
|
||||
|
||||
//ShaderResourceViewDesc shaderResourceViewDesc;
|
||||
|
||||
ShaderResourceViewDesc shaderResourceViewDesc;
|
||||
|
||||
wiDepthTarget();
|
||||
~wiDepthTarget();
|
||||
@@ -18,5 +23,7 @@ public:
|
||||
void InitializeCube(int size);
|
||||
void Clear(GRAPHICSTHREAD threadID);
|
||||
void CopyFrom(const wiDepthTarget&, GRAPHICSTHREAD threadID);
|
||||
|
||||
Texture2D* GetTexture() const { return(isCube ? textureCube : texture); }
|
||||
};
|
||||
|
||||
|
||||
@@ -362,7 +362,7 @@ wiFont::wiFontStyle::wiFontStyle(const string& newName){
|
||||
ss1<<"fonts/"<<name<<".dds";
|
||||
std::ifstream file(ss.str());
|
||||
if(file.is_open()){
|
||||
texture = (TextureView)wiResourceManager::GetGlobal()->add(ss1.str());
|
||||
texture = (Texture2D*)wiResourceManager::GetGlobal()->add(ss1.str());
|
||||
file>>texWidth>>texHeight>>recSize>>charSize;
|
||||
int i=0;
|
||||
while(!file.eof()){
|
||||
@@ -381,7 +381,7 @@ wiFont::wiFontStyle::wiFontStyle(const string& newName){
|
||||
wiRenderer::graphicsDevice->UNLOCK();
|
||||
}
|
||||
void wiFont::wiFontStyle::CleanUp(){
|
||||
SAFE_RELEASE(texture);
|
||||
SAFE_DELETE(texture);
|
||||
}
|
||||
void wiFont::addFontStyle( const string& toAdd ){
|
||||
for (auto& x : fontStyles)
|
||||
|
||||
@@ -76,7 +76,7 @@ private:
|
||||
|
||||
struct wiFontStyle{
|
||||
string name;
|
||||
ID3D11ShaderResourceView *texture;
|
||||
Texture2D* texture;
|
||||
|
||||
struct LookUp{
|
||||
int code;
|
||||
|
||||
@@ -19,8 +19,8 @@ typedef ID3D11DeviceContext* DeviceContext;
|
||||
//typedef ID3D11Device* GraphicsDevice;
|
||||
typedef ID3D11CommandList* CommandList;
|
||||
typedef ID3D11RenderTargetView* RenderTargetView;
|
||||
typedef ID3D11ShaderResourceView* TextureView;
|
||||
typedef ID3D11Texture2D* Texture2D;
|
||||
typedef ID3D11ShaderResourceView* ShaderResourceView;
|
||||
typedef ID3D11Texture2D* APITexture2D;
|
||||
typedef ID3D11SamplerState* Sampler;
|
||||
typedef ID3D11Resource* APIResource;
|
||||
typedef ID3D11Buffer* BufferResource;
|
||||
@@ -164,21 +164,6 @@ enum TEXTURE_ADDRESS_MODE
|
||||
TEXTURE_ADDRESS_BORDER = D3D11_TEXTURE_ADDRESS_BORDER,
|
||||
TEXTURE_ADDRESS_MIRROR_ONCE = D3D11_TEXTURE_ADDRESS_MIRROR_ONCE,
|
||||
};
|
||||
enum RESOURCE_DIMENSION
|
||||
{
|
||||
RESOURCE_DIMENSION_UNKNOWN = D3D_SRV_DIMENSION_UNKNOWN,
|
||||
RESOURCE_DIMENSION_BUFFER = D3D_SRV_DIMENSION_BUFFER,
|
||||
RESOURCE_DIMENSION_TEXTURE1D = D3D_SRV_DIMENSION_TEXTURE1D,
|
||||
RESOURCE_DIMENSION_TEXTURE1DARRAY = D3D_SRV_DIMENSION_TEXTURE1DARRAY,
|
||||
RESOURCE_DIMENSION_TEXTURE2D = D3D_SRV_DIMENSION_TEXTURE2D,
|
||||
RESOURCE_DIMENSION_TEXTURE2DARRAY = D3D_SRV_DIMENSION_TEXTURE2DARRAY,
|
||||
RESOURCE_DIMENSION_TEXTURE2DMS = D3D_SRV_DIMENSION_TEXTURE2DMS,
|
||||
RESOURCE_DIMENSION_TEXTURE2DMSARRAY = D3D_SRV_DIMENSION_TEXTURE2DMSARRAY,
|
||||
RESOURCE_DIMENSION_TEXTURE3D = D3D_SRV_DIMENSION_TEXTURE3D,
|
||||
RESOURCE_DIMENSION_TEXTURECUBE = D3D_SRV_DIMENSION_TEXTURECUBE,
|
||||
RESOURCE_DIMENSION_TEXTURECUBEARRAY = D3D_SRV_DIMENSION_TEXTURECUBEARRAY,
|
||||
RESOURCE_DIMENSION_BUFFEREX = D3D_SRV_DIMENSION_BUFFEREX
|
||||
};
|
||||
enum FILTER
|
||||
{
|
||||
FILTER_MIN_MAG_MIP_POINT = D3D11_FILTER_MIN_MAG_MIP_POINT,
|
||||
@@ -284,25 +269,6 @@ struct Texture2DDesc
|
||||
UINT CPUAccessFlags;
|
||||
UINT MiscFlags;
|
||||
};
|
||||
struct ShaderResourceViewDesc
|
||||
{
|
||||
DXGI_FORMAT Format;
|
||||
RESOURCE_DIMENSION ViewDimension;
|
||||
UINT mipLevels;
|
||||
};
|
||||
struct RenderTargetViewDesc
|
||||
{
|
||||
DXGI_FORMAT Format;
|
||||
RESOURCE_DIMENSION ViewDimension;
|
||||
UINT ArraySize;
|
||||
};
|
||||
struct DepthStencilViewDesc
|
||||
{
|
||||
DXGI_FORMAT Format;
|
||||
RESOURCE_DIMENSION ViewDimension;
|
||||
UINT Flags;
|
||||
UINT ArraySize;
|
||||
};
|
||||
struct SamplerDesc
|
||||
{
|
||||
FILTER Filter;
|
||||
@@ -390,17 +356,51 @@ struct VertexShaderInfo {
|
||||
}
|
||||
};
|
||||
|
||||
class Texture
|
||||
{
|
||||
public:
|
||||
ShaderResourceView shaderResourceView;
|
||||
RenderTargetView renderTargetView;
|
||||
DepthStencilView depthStencilView;
|
||||
|
||||
Texture() :shaderResourceView(nullptr), renderTargetView(nullptr), depthStencilView(nullptr) {}
|
||||
virtual ~Texture()
|
||||
{
|
||||
SAFE_RELEASE(shaderResourceView);
|
||||
SAFE_RELEASE(renderTargetView);
|
||||
SAFE_RELEASE(depthStencilView);
|
||||
}
|
||||
};
|
||||
class Texture2D : public Texture
|
||||
{
|
||||
public:
|
||||
APITexture2D texture2D;
|
||||
Texture2DDesc desc;
|
||||
|
||||
Texture2D() :Texture(), texture2D(nullptr) {}
|
||||
virtual ~Texture2D()
|
||||
{
|
||||
SAFE_RELEASE(texture2D);
|
||||
}
|
||||
};
|
||||
class TextureCube : public Texture2D
|
||||
{
|
||||
public:
|
||||
TextureCube():Texture2D() {}
|
||||
virtual ~TextureCube(){}
|
||||
};
|
||||
|
||||
class GraphicsDevice : public wiThreadSafeManager
|
||||
{
|
||||
public:
|
||||
virtual HRESULT CreateBuffer(const BufferDesc *pDesc, const SubresourceData* pInitialData, BufferResource *ppBuffer) = 0;
|
||||
virtual HRESULT CreateTexture1D() = 0;
|
||||
virtual HRESULT CreateTexture2D(const Texture2DDesc* pDesc, const SubresourceData *pInitialData, Texture2D *ppTexture2D) = 0;
|
||||
virtual HRESULT CreateTexture2D(const Texture2DDesc* pDesc, const SubresourceData *pInitialData, Texture2D **ppTexture2D) = 0;
|
||||
virtual HRESULT CreateTexture3D() = 0;
|
||||
virtual HRESULT CreateShaderResourceView(APIResource pResource, const ShaderResourceViewDesc* pDesc, TextureView *ppSRView) = 0;
|
||||
virtual HRESULT CreateUnorderedAccessView() = 0;
|
||||
virtual HRESULT CreateRenderTargetView(APIResource pResource, const RenderTargetViewDesc* pDesc, RenderTargetView *ppRTView) = 0;
|
||||
virtual HRESULT CreateDepthStencilView(APIResource pResource, const DepthStencilViewDesc* pDesc, DepthStencilView *ppDepthStencilView) = 0;
|
||||
virtual HRESULT CreateTextureCube(const Texture2DDesc* pDesc, const SubresourceData *pInitialData, TextureCube **ppTextureCube) = 0;
|
||||
virtual HRESULT CreateShaderResourceView(Texture2D* pTexture) = 0;
|
||||
virtual HRESULT CreateRenderTargetView(Texture2D* pTexture) = 0;
|
||||
virtual HRESULT CreateDepthStencilView(Texture2D* pTexture) = 0;
|
||||
virtual HRESULT CreateInputLayout(const VertexLayoutDesc *pInputElementDescs, UINT NumElements,
|
||||
const void *pShaderBytecodeWithInputSignature, SIZE_T BytecodeLength, VertexLayout *ppInputLayout) = 0;
|
||||
virtual HRESULT CreateVertexShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage pClassLinkage, VertexShader *ppVertexShader) = 0;
|
||||
@@ -411,26 +411,10 @@ public:
|
||||
virtual HRESULT CreateHullShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage pClassLinkage, HullShader *ppHullShader) = 0;
|
||||
virtual HRESULT CreateDomainShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage pClassLinkage, DomainShader *ppDomainShader) = 0;
|
||||
virtual HRESULT CreateComputeShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage pClassLinkage, ComputeShader *ppComputeShader) = 0;
|
||||
virtual HRESULT CreateClassLinkage() = 0;
|
||||
virtual HRESULT CreateBlendState(const BlendDesc *pBlendStateDesc, BlendState *ppBlendState) = 0;
|
||||
virtual HRESULT CreateDepthStencilState(const DepthStencilDesc *pDepthStencilDesc, DepthStencilState *ppDepthStencilState) = 0;
|
||||
virtual HRESULT CreateRasterizerState(const RasterizerDesc *pRasterizerDesc, RasterizerState *ppRasterizerState) = 0;
|
||||
virtual HRESULT CreateSamplerState(const SamplerDesc *pSamplerDesc, Sampler *ppSamplerState) = 0;
|
||||
virtual HRESULT CreateQuery() = 0;
|
||||
virtual HRESULT CreatePredicate() = 0;
|
||||
virtual HRESULT CreateDeferredContext(UINT ContextFlags, DeviceContext *ppDeferredContext) = 0;
|
||||
virtual HRESULT OpenSharedResource() = 0;
|
||||
virtual HRESULT CheckFormatSupport() = 0;
|
||||
virtual HRESULT CheckMultiSampleQualityLevels() = 0;
|
||||
virtual HRESULT CheckCounterInfo() = 0;
|
||||
virtual HRESULT CheckCounter() = 0;
|
||||
virtual HRESULT CheckFeatureSupport() = 0;
|
||||
virtual HRESULT GetPrivateData() = 0;
|
||||
virtual HRESULT SetPrivateData() = 0;
|
||||
virtual HRESULT SetPrivateDataInterface() = 0;
|
||||
virtual UINT GetCreationFlags() = 0;
|
||||
virtual HRESULT GetDeviceRemovedReason() = 0;
|
||||
virtual DeviceContext GetImmediateContext() = 0;
|
||||
|
||||
virtual void PresentBegin() = 0;
|
||||
virtual void PresentEnd() = 0;
|
||||
@@ -439,7 +423,6 @@ public:
|
||||
virtual void FinishCommandList(GRAPHICSTHREAD thread) = 0;
|
||||
|
||||
virtual bool GetMultithreadingSupport() = 0;
|
||||
virtual DeviceContext GetDeferredContext(GRAPHICSTHREAD thread) = 0;
|
||||
|
||||
virtual bool GetVSyncEnabled() = 0;
|
||||
virtual void SetVSyncEnabled(bool value) = 0;
|
||||
@@ -447,19 +430,14 @@ public:
|
||||
///////////////Thread-sensitive////////////////////////
|
||||
|
||||
virtual void BindViewports(UINT NumViewports, const ViewPort *pViewports, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindRenderTargets(UINT NumViews, RenderTargetView const *ppRenderTargetViews, DepthStencilView pDepthStencilView, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void ClearRenderTarget(RenderTargetView pRenderTargetView, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void ClearDepthStencil(DepthStencilView pDepthStencilView, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindTexturePS(TextureView texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindTexturesPS(TextureView textures[], int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindTextureVS(TextureView texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindTexturesVS(TextureView textures[], int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindTextureGS(TextureView texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindTexturesGS(TextureView textures[], int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindTextureDS(TextureView texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindTexturesDS(TextureView textures[], int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindTextureHS(TextureView texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindTexturesHS(TextureView textures[], int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindRenderTargets(UINT NumViews, Texture2D* const *ppRenderTargetViews, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void ClearRenderTarget(Texture2D* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindTexturePS(const Texture* texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindTextureVS(const Texture* texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindTextureGS(const Texture* texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindTextureDS(const Texture* texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindTextureHS(const Texture* texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void UnbindTextures(int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindSamplerPS(Sampler sampler, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void BindSamplersPS(Sampler samplers[], int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
@@ -494,11 +472,12 @@ public:
|
||||
virtual void Draw(int vertexCount, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void DrawIndexed(int indexCount, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void DrawIndexedInstanced(int indexCount, int instanceCount, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void GenerateMips(TextureView texture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void CopyResource(APIResource pDstResource, APIResource pSrcResource, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void GenerateMips(Texture* texture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void CopyResource(APIResource pDstResource, const APIResource pSrcResource, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void CopyTexture2D(Texture2D* pDst, const Texture2D* pSrc, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual void UpdateBuffer(BufferResource& buffer, const void* data, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int dataSize = -1) = 0;
|
||||
|
||||
virtual HRESULT CreateTextureFromFile(const wstring& fileName, TextureView *ppShaderResourceView, bool mipMaps = true, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
virtual HRESULT CreateTextureFromFile(const wstring& fileName, Texture2D **ppTexture, bool mipMaps = true, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,12 +20,12 @@ public:
|
||||
|
||||
virtual HRESULT CreateBuffer(const BufferDesc *pDesc, const SubresourceData* pInitialData, BufferResource *ppBuffer);
|
||||
virtual HRESULT CreateTexture1D();
|
||||
virtual HRESULT CreateTexture2D(const Texture2DDesc* pDesc, const SubresourceData *pInitialData, Texture2D *ppTexture2D);
|
||||
virtual HRESULT CreateTexture2D(const Texture2DDesc* pDesc, const SubresourceData *pInitialData, Texture2D **ppTexture2D);
|
||||
virtual HRESULT CreateTexture3D();
|
||||
virtual HRESULT CreateShaderResourceView(APIResource pResource, const ShaderResourceViewDesc* pDesc, TextureView *ppSRView);
|
||||
virtual HRESULT CreateUnorderedAccessView();
|
||||
virtual HRESULT CreateRenderTargetView(APIResource pResource, const RenderTargetViewDesc* pDesc, RenderTargetView *ppRTView);
|
||||
virtual HRESULT CreateDepthStencilView(APIResource pResource, const DepthStencilViewDesc* pDesc, DepthStencilView *ppDepthStencilView);
|
||||
virtual HRESULT CreateTextureCube(const Texture2DDesc* pDesc, const SubresourceData *pInitialData, TextureCube **ppTextureCube);
|
||||
virtual HRESULT CreateShaderResourceView(Texture2D* pTexture);
|
||||
virtual HRESULT CreateRenderTargetView(Texture2D* pTexture);
|
||||
virtual HRESULT CreateDepthStencilView(Texture2D* pTexture);
|
||||
virtual HRESULT CreateInputLayout(const VertexLayoutDesc *pInputElementDescs, UINT NumElements,
|
||||
const void *pShaderBytecodeWithInputSignature, SIZE_T BytecodeLength, VertexLayout *ppInputLayout);
|
||||
virtual HRESULT CreateVertexShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage pClassLinkage, VertexShader *ppVertexShader);
|
||||
@@ -36,26 +36,10 @@ public:
|
||||
virtual HRESULT CreateHullShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage pClassLinkage, HullShader *ppHullShader);
|
||||
virtual HRESULT CreateDomainShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage pClassLinkage, DomainShader *ppDomainShader);
|
||||
virtual HRESULT CreateComputeShader(const void *pShaderBytecode, SIZE_T BytecodeLength, ClassLinkage pClassLinkage, ComputeShader *ppComputeShader);
|
||||
virtual HRESULT CreateClassLinkage();
|
||||
virtual HRESULT CreateBlendState(const BlendDesc *pBlendStateDesc, BlendState *ppBlendState);
|
||||
virtual HRESULT CreateDepthStencilState(const DepthStencilDesc *pDepthStencilDesc, DepthStencilState *ppDepthStencilState);
|
||||
virtual HRESULT CreateRasterizerState(const RasterizerDesc *pRasterizerDesc, RasterizerState *ppRasterizerState);
|
||||
virtual HRESULT CreateSamplerState(const SamplerDesc *pSamplerDesc, Sampler *ppSamplerState);
|
||||
virtual HRESULT CreateQuery();
|
||||
virtual HRESULT CreatePredicate();
|
||||
virtual HRESULT CreateDeferredContext(UINT ContextFlags, DeviceContext *ppDeferredContext);
|
||||
virtual HRESULT OpenSharedResource();
|
||||
virtual HRESULT CheckFormatSupport();
|
||||
virtual HRESULT CheckMultiSampleQualityLevels();
|
||||
virtual HRESULT CheckCounterInfo();
|
||||
virtual HRESULT CheckCounter();
|
||||
virtual HRESULT CheckFeatureSupport();
|
||||
virtual HRESULT GetPrivateData();
|
||||
virtual HRESULT SetPrivateData();
|
||||
virtual HRESULT SetPrivateDataInterface();
|
||||
virtual UINT GetCreationFlags();
|
||||
virtual HRESULT GetDeviceRemovedReason();
|
||||
virtual DeviceContext GetImmediateContext();
|
||||
|
||||
virtual void PresentBegin();
|
||||
virtual void PresentEnd();
|
||||
@@ -63,8 +47,7 @@ public:
|
||||
virtual void ExecuteDeferredContexts();
|
||||
virtual void FinishCommandList(GRAPHICSTHREAD thread);
|
||||
|
||||
virtual bool GetMultithreadingSupport();
|
||||
virtual DeviceContext GetDeferredContext(GRAPHICSTHREAD thread);
|
||||
virtual bool GetMultithreadingSupport() { return DEFERREDCONTEXT_SUPPORT; }
|
||||
|
||||
virtual bool GetVSyncEnabled() { return VSYNC; }
|
||||
virtual void SetVSyncEnabled(bool value) { VSYNC = value; }
|
||||
@@ -87,69 +70,50 @@ public:
|
||||
SAFE_DELETE_ARRAY(pd3dViewPorts);
|
||||
}
|
||||
}
|
||||
virtual void BindRenderTargets(UINT NumViews, RenderTargetView const *ppRenderTargetViews, DepthStencilView pDepthStencilView, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
virtual void BindRenderTargets(UINT NumViews, Texture2D* const *ppRenderTargetViews, Texture2D* depthStencilTexture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
if (deviceContexts[threadID] != nullptr) {
|
||||
deviceContexts[threadID]->OMSetRenderTargets(NumViews, ppRenderTargetViews, pDepthStencilView);
|
||||
static thread_local RenderTargetView renderTargetViews[8];
|
||||
for (UINT i = 0; i < min(NumViews, 8); ++i)
|
||||
{
|
||||
renderTargetViews[i] = ppRenderTargetViews[i]->renderTargetView;
|
||||
}
|
||||
deviceContexts[threadID]->OMSetRenderTargets(NumViews, renderTargetViews,
|
||||
(depthStencilTexture == nullptr ? nullptr : depthStencilTexture->depthStencilView));
|
||||
}
|
||||
}
|
||||
virtual void ClearRenderTarget(RenderTargetView pRenderTargetView, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
if (deviceContexts[threadID] != nullptr) {
|
||||
deviceContexts[threadID]->ClearRenderTargetView(pRenderTargetView, ColorRGBA);
|
||||
virtual void ClearRenderTarget(Texture2D* pTexture, const FLOAT ColorRGBA[4], GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
if (deviceContexts[threadID] != nullptr && pTexture != nullptr && pTexture->renderTargetView != nullptr) {
|
||||
deviceContexts[threadID]->ClearRenderTargetView(pTexture->renderTargetView, ColorRGBA);
|
||||
}
|
||||
}
|
||||
virtual void ClearDepthStencil(DepthStencilView pDepthStencilView, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
if (deviceContexts[threadID] != nullptr) {
|
||||
deviceContexts[threadID]->ClearDepthStencilView(pDepthStencilView, ClearFlags, Depth, Stencil);
|
||||
virtual void ClearDepthStencil(Texture2D* pTexture, UINT ClearFlags, FLOAT Depth, UINT8 Stencil, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
if (deviceContexts[threadID] != nullptr && pTexture != nullptr && pTexture->depthStencilView != nullptr) {
|
||||
deviceContexts[threadID]->ClearDepthStencilView(pTexture->depthStencilView, ClearFlags, Depth, Stencil);
|
||||
}
|
||||
}
|
||||
virtual void BindTexturePS(TextureView texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
virtual void BindTexturePS(const Texture* texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
if (deviceContexts[threadID] != nullptr && texture != nullptr) {
|
||||
deviceContexts[threadID]->PSSetShaderResources(slot, 1, &texture);
|
||||
deviceContexts[threadID]->PSSetShaderResources(slot, 1, &texture->shaderResourceView);
|
||||
}
|
||||
}
|
||||
virtual void BindTexturesPS(TextureView textures[], int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
if (deviceContexts[threadID] != nullptr && textures != nullptr) {
|
||||
deviceContexts[threadID]->PSSetShaderResources(slot, num, textures);
|
||||
}
|
||||
}
|
||||
virtual void BindTextureVS(TextureView texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
virtual void BindTextureVS(const Texture* texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
if (deviceContexts[threadID] != nullptr && texture != nullptr) {
|
||||
deviceContexts[threadID]->VSSetShaderResources(slot, 1, &texture);
|
||||
deviceContexts[threadID]->VSSetShaderResources(slot, 1, &texture->shaderResourceView);
|
||||
}
|
||||
}
|
||||
virtual void BindTexturesVS(TextureView textures[], int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
if (deviceContexts[threadID] != nullptr && textures != nullptr) {
|
||||
deviceContexts[threadID]->VSSetShaderResources(slot, num, textures);
|
||||
}
|
||||
}
|
||||
virtual void BindTextureGS(TextureView texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
virtual void BindTextureGS(const Texture* texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
if (deviceContexts[threadID] != nullptr && texture != nullptr) {
|
||||
deviceContexts[threadID]->GSSetShaderResources(slot, 1, &texture);
|
||||
deviceContexts[threadID]->GSSetShaderResources(slot, 1, &texture->shaderResourceView);
|
||||
}
|
||||
}
|
||||
virtual void BindTexturesGS(TextureView textures[], int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
if (deviceContexts[threadID] != nullptr && textures != nullptr) {
|
||||
deviceContexts[threadID]->GSSetShaderResources(slot, num, textures);
|
||||
}
|
||||
}
|
||||
virtual void BindTextureDS(TextureView texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
virtual void BindTextureDS(const Texture* texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
if (deviceContexts[threadID] != nullptr && texture != nullptr) {
|
||||
deviceContexts[threadID]->DSSetShaderResources(slot, 1, &texture);
|
||||
deviceContexts[threadID]->DSSetShaderResources(slot, 1, &texture->shaderResourceView);
|
||||
}
|
||||
}
|
||||
virtual void BindTexturesDS(TextureView textures[], int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
if (deviceContexts[threadID] != nullptr && textures != nullptr) {
|
||||
deviceContexts[threadID]->DSSetShaderResources(slot, num, textures);
|
||||
}
|
||||
}
|
||||
virtual void BindTextureHS(TextureView texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
virtual void BindTextureHS(const Texture* texture, int slot, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
if (deviceContexts[threadID] != nullptr && texture != nullptr) {
|
||||
deviceContexts[threadID]->HSSetShaderResources(slot, 1, &texture);
|
||||
}
|
||||
}
|
||||
virtual void BindTexturesHS(TextureView textures[], int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
if (deviceContexts[threadID] != nullptr && textures != nullptr) {
|
||||
deviceContexts[threadID]->HSSetShaderResources(slot, num, textures);
|
||||
deviceContexts[threadID]->HSSetShaderResources(slot, 1, &texture->shaderResourceView);
|
||||
}
|
||||
}
|
||||
virtual void UnbindTextures(int slot, int num, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE)
|
||||
@@ -157,7 +121,7 @@ public:
|
||||
assert(num <= 32 && "UnbindTextures limit of 32 reached!");
|
||||
if (deviceContexts[threadID] != nullptr)
|
||||
{
|
||||
static TextureView empties[32] = {
|
||||
static ID3D11ShaderResourceView* empties[32] = {
|
||||
nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,
|
||||
nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,
|
||||
nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,
|
||||
@@ -358,15 +322,22 @@ public:
|
||||
deviceContexts[threadID]->DrawIndexedInstanced(indexCount, instanceCount, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
virtual void GenerateMips(TextureView texture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE)
|
||||
virtual void GenerateMips(Texture* texture, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE)
|
||||
{
|
||||
deviceContexts[threadID]->GenerateMips(texture);
|
||||
deviceContexts[threadID]->GenerateMips(texture->shaderResourceView);
|
||||
}
|
||||
virtual void CopyResource(APIResource pDstResource, APIResource pSrcResource, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
virtual void CopyResource(APIResource pDstResource, const APIResource pSrcResource, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
if (deviceContexts[threadID] != nullptr) {
|
||||
deviceContexts[threadID]->CopyResource(pDstResource, pSrcResource);
|
||||
}
|
||||
}
|
||||
virtual void CopyTexture2D(Texture2D* pDst, const Texture2D* pSrc, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE) {
|
||||
if (deviceContexts[threadID] != nullptr) {
|
||||
SAFE_RELEASE(pDst->shaderResourceView);
|
||||
deviceContexts[threadID]->CopyResource(pDst->texture2D, pSrc->texture2D);
|
||||
CreateShaderResourceView(pDst);
|
||||
}
|
||||
}
|
||||
virtual void UpdateBuffer(BufferResource& buffer, const void* data, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE, int dataSize = -1)
|
||||
{
|
||||
if (buffer != nullptr && data != nullptr && deviceContexts[threadID] != nullptr) {
|
||||
@@ -379,7 +350,7 @@ public:
|
||||
|
||||
BufferDesc desc;
|
||||
desc.ByteWidth = d3dDesc.ByteWidth;
|
||||
switch (desc.Usage)
|
||||
switch (d3dDesc.Usage)
|
||||
{
|
||||
case D3D11_USAGE_DEFAULT:
|
||||
desc.Usage = USAGE_DEFAULT;
|
||||
@@ -415,7 +386,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
virtual HRESULT CreateTextureFromFile(const wstring& fileName, TextureView *ppShaderResourceView, bool mipMaps = true, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
|
||||
virtual HRESULT CreateTextureFromFile(const wstring& fileName, Texture2D **ppTexture, bool mipMaps = true, GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE);
|
||||
|
||||
};
|
||||
|
||||
@@ -387,7 +387,7 @@ void wiHairParticle::Draw(Camera* camera, GRAPHICSTHREAD threadID)
|
||||
|
||||
if(!culledPatches.empty())
|
||||
{
|
||||
TextureView texture = material->texture;
|
||||
Texture2D* texture = material->texture;
|
||||
|
||||
wiRenderer::graphicsDevice->BindPrimitiveTopology(PRIMITIVETOPOLOGY::POINTLIST,threadID);
|
||||
wiRenderer::graphicsDevice->BindVertexLayout(il,threadID);
|
||||
|
||||
@@ -193,13 +193,13 @@ void wiImage::BindPersistentState(GRAPHICSTHREAD threadID)
|
||||
|
||||
wiRenderer::graphicsDevice->BindConstantBufferPS(processCb, CB_GETBINDSLOT(PostProcessCB), threadID);
|
||||
|
||||
wiRenderer::graphicsDevice->LOCK();
|
||||
wiRenderer::graphicsDevice->UNLOCK();
|
||||
}
|
||||
|
||||
void wiImage::Draw(TextureView texture, const wiImageEffects& effects){
|
||||
void wiImage::Draw(Texture2D* texture, const wiImageEffects& effects){
|
||||
Draw(texture,effects,GRAPHICSTHREAD_IMMEDIATE);
|
||||
}
|
||||
void wiImage::Draw(TextureView texture, const wiImageEffects& effects,GRAPHICSTHREAD threadID)
|
||||
void wiImage::Draw(Texture2D* texture, const wiImageEffects& effects,GRAPHICSTHREAD threadID)
|
||||
{
|
||||
|
||||
bool fullScreenEffect = false;
|
||||
@@ -426,9 +426,9 @@ void wiImage::Draw(TextureView texture, const wiImageEffects& effects,GRAPHICSTH
|
||||
wiRenderer::graphicsDevice->Draw((fullScreenEffect ? 3 : 4), threadID);
|
||||
}
|
||||
|
||||
void wiImage::DrawDeferred(TextureView texture
|
||||
, TextureView depth, TextureView lightmap, TextureView normal
|
||||
, TextureView ao, GRAPHICSTHREAD threadID, int stencilRef){
|
||||
void wiImage::DrawDeferred(Texture2D* texture
|
||||
, Texture2D* depth, Texture2D* lightmap, Texture2D* normal
|
||||
, Texture2D* ao, GRAPHICSTHREAD threadID, int stencilRef){
|
||||
|
||||
wiRenderer::graphicsDevice->BindPrimitiveTopology(PRIMITIVETOPOLOGY::TRIANGLELIST,threadID);
|
||||
wiRenderer::graphicsDevice->BindRasterizerState(rasterizerState,threadID);
|
||||
|
||||
@@ -65,12 +65,12 @@ private:
|
||||
public:
|
||||
wiImage();
|
||||
|
||||
static void Draw(TextureView texture, const wiImageEffects& effects);
|
||||
static void Draw(TextureView texture, const wiImageEffects& effects,GRAPHICSTHREAD threadID);
|
||||
static void Draw(Texture2D* texture, const wiImageEffects& effects);
|
||||
static void Draw(Texture2D* texture, const wiImageEffects& effects,GRAPHICSTHREAD threadID);
|
||||
|
||||
static void DrawDeferred(TextureView texture
|
||||
, TextureView depth, TextureView lightmap, TextureView normal
|
||||
, TextureView ao, GRAPHICSTHREAD threadID, int stencilref = 0);
|
||||
static void DrawDeferred(Texture2D* texture
|
||||
, Texture2D* depth, Texture2D* lightmap, Texture2D* normal
|
||||
, Texture2D* ao, GRAPHICSTHREAD threadID, int stencilref = 0);
|
||||
|
||||
static void Load();
|
||||
static void CleanUp();
|
||||
|
||||
@@ -94,13 +94,13 @@ public:
|
||||
};
|
||||
Processing process;
|
||||
bool deferred;
|
||||
TextureView maskMap, distortionMap, refractionSource;
|
||||
Texture2D* maskMap, *distortionMap, *refractionSource;
|
||||
// Generic texture
|
||||
void setMaskMap(TextureView view) { maskMap = view; }
|
||||
void setMaskMap(Texture2D* view) { maskMap = view; }
|
||||
// The normalmap texture which should distort the refraction source
|
||||
void setDistortionMap(TextureView view) { distortionMap = view; }
|
||||
void setDistortionMap(Texture2D* view) { distortionMap = view; }
|
||||
// The texture which should be distorted
|
||||
void setRefractionSource(TextureView view) { refractionSource = view; }
|
||||
void setRefractionSource(Texture2D* view) { refractionSource = view; }
|
||||
|
||||
void init() {
|
||||
pos = XMFLOAT3(0, 0, 0);
|
||||
|
||||
@@ -30,7 +30,7 @@ void wiLensFlare::CleanUp(){
|
||||
if(blendState) blendState->Release(); blendState = NULL;
|
||||
if(depthStencilState) depthStencilState->Release(); depthStencilState = NULL;
|
||||
}
|
||||
void wiLensFlare::Draw(GRAPHICSTHREAD threadID, const XMVECTOR& lightPos, vector<TextureView>& rims){
|
||||
void wiLensFlare::Draw(GRAPHICSTHREAD threadID, const XMVECTOR& lightPos, vector<Texture2D*>& rims){
|
||||
|
||||
if(!rims.empty()){
|
||||
|
||||
@@ -55,7 +55,7 @@ void wiLensFlare::Draw(GRAPHICSTHREAD threadID, const XMVECTOR& lightPos, vector
|
||||
//wiRenderer::graphicsDevice->BindTextureGS(depthMap,0,threadID);
|
||||
|
||||
int i=0;
|
||||
for(TextureView x : rims){
|
||||
for(Texture2D* x : rims){
|
||||
if(x!=nullptr){
|
||||
wiRenderer::graphicsDevice->BindTexturePS(x, TEXSLOT_ONDEMAND0 + i, threadID);
|
||||
wiRenderer::graphicsDevice->BindTextureGS(x, TEXSLOT_ONDEMAND0 + i, threadID);
|
||||
|
||||
@@ -33,7 +33,7 @@ private:
|
||||
public:
|
||||
static void Initialize();
|
||||
static void CleanUp();
|
||||
static void Draw(GRAPHICSTHREAD threadID, const XMVECTOR& lightPos, vector<TextureView>& rims);
|
||||
static void Draw(GRAPHICSTHREAD threadID, const XMVECTOR& lightPos, vector<Texture2D*>& rims);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -187,7 +187,7 @@ void LoadWiMaterialLibrary(const string& directory, const string& name, const st
|
||||
stringstream ss("");
|
||||
ss<<directory<<texturesDir<<resourceName.c_str();
|
||||
currentMat->refMapName=ss.str();
|
||||
currentMat->refMap = (TextureView)wiResourceManager::GetGlobal()->add(ss.str());
|
||||
currentMat->refMap = (Texture2D*)wiResourceManager::GetGlobal()->add(ss.str());
|
||||
}
|
||||
if(currentMat->refMap!=0)
|
||||
currentMat->hasRefMap = true;
|
||||
@@ -199,7 +199,7 @@ void LoadWiMaterialLibrary(const string& directory, const string& name, const st
|
||||
stringstream ss("");
|
||||
ss<<directory<<texturesDir<<resourceName.c_str();
|
||||
currentMat->normalMapName=ss.str();
|
||||
currentMat->normalMap = (TextureView)wiResourceManager::GetGlobal()->add(ss.str());
|
||||
currentMat->normalMap = (Texture2D*)wiResourceManager::GetGlobal()->add(ss.str());
|
||||
}
|
||||
if(currentMat->normalMap!=0)
|
||||
currentMat->hasNormalMap = true;
|
||||
@@ -211,7 +211,7 @@ void LoadWiMaterialLibrary(const string& directory, const string& name, const st
|
||||
stringstream ss("");
|
||||
ss<<directory<<texturesDir<<resourceName.c_str();
|
||||
currentMat->textureName=ss.str();
|
||||
currentMat->texture = (TextureView)wiResourceManager::GetGlobal()->add(ss.str());
|
||||
currentMat->texture = (Texture2D*)wiResourceManager::GetGlobal()->add(ss.str());
|
||||
}
|
||||
if(currentMat->texture!=0)
|
||||
currentMat->hasTexture=true;
|
||||
@@ -224,7 +224,7 @@ void LoadWiMaterialLibrary(const string& directory, const string& name, const st
|
||||
stringstream ss("");
|
||||
ss<<directory<<texturesDir<<resourceName.c_str();
|
||||
currentMat->displacementMapName=ss.str();
|
||||
currentMat->displacementMap = (TextureView)wiResourceManager::GetGlobal()->add(ss.str());
|
||||
currentMat->displacementMap = (Texture2D*)wiResourceManager::GetGlobal()->add(ss.str());
|
||||
}
|
||||
if(currentMat->displacementMap!=0)
|
||||
currentMat->hasDisplacementMap=true;
|
||||
@@ -236,7 +236,7 @@ void LoadWiMaterialLibrary(const string& directory, const string& name, const st
|
||||
stringstream ss("");
|
||||
ss<<directory<<texturesDir<<resourceName.c_str();
|
||||
currentMat->specularMapName=ss.str();
|
||||
currentMat->specularMap = (TextureView)wiResourceManager::GetGlobal()->add(ss.str());
|
||||
currentMat->specularMap = (Texture2D*)wiResourceManager::GetGlobal()->add(ss.str());
|
||||
}
|
||||
if(currentMat->specularMap!=0)
|
||||
currentMat->hasSpecularMap=true;
|
||||
@@ -932,8 +932,8 @@ void LoadWiLights(const string& directory, const string& name, const string& ide
|
||||
file>>t;
|
||||
stringstream rim("");
|
||||
rim<<directory<<"rims/"<<t;
|
||||
TextureView tex=nullptr;
|
||||
if ((tex = (TextureView)wiResourceManager::GetGlobal()->add(rim.str())) != nullptr){
|
||||
Texture2D* tex=nullptr;
|
||||
if ((tex = (Texture2D*)wiResourceManager::GetGlobal()->add(rim.str())) != nullptr){
|
||||
lights.back()->lensFlareRimTextures.push_back(tex);
|
||||
lights.back()->lensFlareNames.push_back(rim.str());
|
||||
}
|
||||
@@ -2832,13 +2832,13 @@ Decal::~Decal() {
|
||||
void Decal::addTexture(const string& tex){
|
||||
texName=tex;
|
||||
if(!tex.empty()){
|
||||
texture = (TextureView)wiResourceManager::GetGlobal()->add(tex);
|
||||
texture = (Texture2D*)wiResourceManager::GetGlobal()->add(tex);
|
||||
}
|
||||
}
|
||||
void Decal::addNormal(const string& nor){
|
||||
norName=nor;
|
||||
if(!nor.empty()){
|
||||
normal = (TextureView)wiResourceManager::GetGlobal()->add(nor);
|
||||
normal = (Texture2D*)wiResourceManager::GetGlobal()->add(nor);
|
||||
}
|
||||
}
|
||||
void Decal::UpdateTransform()
|
||||
|
||||
@@ -99,25 +99,25 @@ struct Material
|
||||
|
||||
bool hasRefMap;
|
||||
string refMapName;
|
||||
TextureView refMap;
|
||||
Texture2D* refMap;
|
||||
|
||||
bool hasTexture;
|
||||
string textureName;
|
||||
TextureView texture;
|
||||
Texture2D* texture;
|
||||
bool premultipliedTexture;
|
||||
BLENDMODE blendFlag;
|
||||
|
||||
bool hasNormalMap;
|
||||
string normalMapName;
|
||||
TextureView normalMap;
|
||||
Texture2D* normalMap;
|
||||
|
||||
bool hasDisplacementMap;
|
||||
string displacementMapName;
|
||||
TextureView displacementMap;
|
||||
Texture2D* displacementMap;
|
||||
|
||||
bool hasSpecularMap;
|
||||
string specularMapName;
|
||||
TextureView specularMap;
|
||||
Texture2D* specularMap;
|
||||
|
||||
bool subsurface_scattering;
|
||||
bool toonshading;
|
||||
@@ -503,8 +503,8 @@ struct Object : public Streamable, public Transform
|
||||
//RIBBON TRAIL
|
||||
deque<RibbonVertex> trail;
|
||||
BufferResource trailBuff;
|
||||
TextureView trailDistortTex;
|
||||
TextureView trailTex;
|
||||
Texture2D* trailDistortTex;
|
||||
Texture2D* trailTex;
|
||||
|
||||
int physicsObjectI;
|
||||
|
||||
@@ -785,7 +785,7 @@ struct Light : public Cullable , public Transform
|
||||
XMFLOAT4 enerDis;
|
||||
bool noHalo;
|
||||
bool shadow;
|
||||
vector<TextureView> lensFlareRimTextures;
|
||||
vector<Texture2D*> lensFlareRimTextures;
|
||||
vector<string> lensFlareNames;
|
||||
|
||||
//vector<wiRenderTarget> shadowMap;
|
||||
@@ -826,7 +826,7 @@ struct Light : public Cullable , public Transform
|
||||
struct Decal : public Cullable, public Transform
|
||||
{
|
||||
string texName,norName;
|
||||
TextureView texture,normal;
|
||||
Texture2D* texture,*normal;
|
||||
XMFLOAT4X4 view,projection;
|
||||
XMFLOAT3 front;
|
||||
float life,fadeStart;
|
||||
|
||||
+106
-79
@@ -4,11 +4,12 @@
|
||||
|
||||
|
||||
void wiRenderTarget::clear(){
|
||||
textureDesc = { 0 };
|
||||
//textureDesc = { 0 };
|
||||
numViews = 0;
|
||||
viewPort = ViewPort();
|
||||
depth = NULL;
|
||||
retargetted = false;
|
||||
depth = nullptr;
|
||||
//retargetted = false;
|
||||
isCube = false;
|
||||
}
|
||||
|
||||
wiRenderTarget::wiRenderTarget()
|
||||
@@ -25,27 +26,39 @@ wiRenderTarget::wiRenderTarget(UINT width, UINT height, int numViews, bool hasDe
|
||||
|
||||
wiRenderTarget::~wiRenderTarget()
|
||||
{
|
||||
for(int i=0;i<numViews;++i){
|
||||
if(texture2D[i]) texture2D[i]->Release(); texture2D[i] = NULL;
|
||||
if(renderTarget[i]) renderTarget[i]->Release(); renderTarget[i] = NULL;
|
||||
if(SAVEDshaderResource[i]) SAVEDshaderResource[i]->Release(); SAVEDshaderResource[i]=NULL;
|
||||
if(shaderResource[i] && !retargetted) shaderResource[i]->Release(); shaderResource[i] = NULL;
|
||||
//for(int i=0;i<numViews;++i){
|
||||
// if(texture2D[i]) texture2D[i]->Release(); texture2D[i] = NULL;
|
||||
// if(renderTarget[i]) renderTarget[i]->Release(); renderTarget[i] = NULL;
|
||||
// if(SAVEDshaderResource[i]) SAVEDshaderResource[i]->Release(); SAVEDshaderResource[i]=NULL;
|
||||
// if(shaderResource[i] && !retargetted) shaderResource[i]->Release(); shaderResource[i] = NULL;
|
||||
//}
|
||||
//texture2D.clear();
|
||||
//renderTarget.clear();
|
||||
//shaderResource.clear();
|
||||
for (unsigned int i = 0; i < renderTargets.size(); ++i)
|
||||
{
|
||||
SAFE_DELETE(renderTargets[i]);
|
||||
}
|
||||
texture2D.clear();
|
||||
renderTarget.clear();
|
||||
shaderResource.clear();
|
||||
if(depth) depth->~wiDepthTarget(); depth=NULL;
|
||||
for (unsigned int i = 0; i < renderTargets_Cube.size(); ++i)
|
||||
{
|
||||
SAFE_DELETE(renderTargets_Cube[i]);
|
||||
}
|
||||
SAFE_DELETE(depth);
|
||||
}
|
||||
|
||||
void wiRenderTarget::Initialize(UINT width, UINT height, int numViews, bool hasDepth, UINT MSAAC, UINT MSAAQ
|
||||
, DXGI_FORMAT format, UINT mipMapLevelCount)
|
||||
{
|
||||
isCube = false;
|
||||
|
||||
this->numViews = numViews;
|
||||
texture2D.resize(numViews);
|
||||
renderTarget.resize(numViews);
|
||||
shaderResource.resize(numViews);
|
||||
SAVEDshaderResource.resize(numViews);
|
||||
|
||||
//texture2D.resize(numViews);
|
||||
//renderTarget.resize(numViews);
|
||||
//shaderResource.resize(numViews);
|
||||
//SAVEDshaderResource.resize(numViews);
|
||||
renderTargets.resize(numViews);
|
||||
|
||||
Texture2DDesc textureDesc;
|
||||
ZeroMemory(&textureDesc, sizeof(textureDesc));
|
||||
textureDesc.Width = width;
|
||||
textureDesc.Height = height;
|
||||
@@ -63,23 +76,27 @@ void wiRenderTarget::Initialize(UINT width, UINT height, int numViews, bool hasD
|
||||
textureDesc.MiscFlags = RESOURCE_MISC_GENERATE_MIPS;
|
||||
}
|
||||
|
||||
RenderTargetViewDesc renderTargetViewDesc;
|
||||
renderTargetViewDesc.Format = format;
|
||||
renderTargetViewDesc.ViewDimension = (MSAAQ==0 ? RESOURCE_DIMENSION_TEXTURE2D : RESOURCE_DIMENSION_TEXTURE2DMS);
|
||||
//renderTargetViewDesc.Texture2D.MipSlice = 0;
|
||||
//RenderTargetViewDesc renderTargetViewDesc;
|
||||
//renderTargetViewDesc.Format = format;
|
||||
//renderTargetViewDesc.ViewDimension = (MSAAQ==0 ? RESOURCE_DIMENSION_TEXTURE2D : RESOURCE_DIMENSION_TEXTURE2DMS);
|
||||
////renderTargetViewDesc.Texture2D.MipSlice = 0;
|
||||
|
||||
|
||||
ShaderResourceViewDesc shaderResourceViewDesc;
|
||||
shaderResourceViewDesc.Format = format;
|
||||
shaderResourceViewDesc.ViewDimension = (MSAAQ==0 ? RESOURCE_DIMENSION_TEXTURE2D : RESOURCE_DIMENSION_TEXTURE2DMS);
|
||||
//shaderResourceViewDesc.Texture2D.MostDetailedMip = 0; //from most detailed...
|
||||
//shaderResourceViewDesc.Texture2D.MipLevels = -1; //...to least detailed
|
||||
shaderResourceViewDesc.mipLevels = -1;
|
||||
//
|
||||
//ShaderResourceViewDesc shaderResourceViewDesc;
|
||||
//shaderResourceViewDesc.Format = format;
|
||||
//shaderResourceViewDesc.ViewDimension = (MSAAQ==0 ? RESOURCE_DIMENSION_TEXTURE2D : RESOURCE_DIMENSION_TEXTURE2DMS);
|
||||
////shaderResourceViewDesc.Texture2D.MostDetailedMip = 0; //from most detailed...
|
||||
////shaderResourceViewDesc.Texture2D.MipLevels = -1; //...to least detailed
|
||||
//shaderResourceViewDesc.mipLevels = -1;
|
||||
|
||||
for(int i=0;i<numViews;++i){
|
||||
wiRenderer::graphicsDevice->CreateTexture2D(&textureDesc, nullptr, &texture2D[i]);
|
||||
wiRenderer::graphicsDevice->CreateRenderTargetView(texture2D[i], &renderTargetViewDesc, &renderTarget[i]);
|
||||
wiRenderer::graphicsDevice->CreateShaderResourceView(texture2D[i], &shaderResourceViewDesc, &shaderResource[i]);
|
||||
//for(int i=0;i<numViews;++i){
|
||||
// wiRenderer::graphicsDevice->CreateTexture2D(&textureDesc, nullptr, &texture2D[i]);
|
||||
// wiRenderer::graphicsDevice->CreateRenderTargetView(texture2D[i], &renderTargetViewDesc, &renderTarget[i]);
|
||||
// wiRenderer::graphicsDevice->CreateShaderResourceView(texture2D[i], &shaderResourceViewDesc, &shaderResource[i]);
|
||||
//}
|
||||
for (int i = 0; i < numViews; ++i)
|
||||
{
|
||||
wiRenderer::graphicsDevice->CreateTexture2D(&textureDesc, nullptr, &renderTargets[i]);
|
||||
}
|
||||
|
||||
viewPort.Width = (FLOAT)width;
|
||||
@@ -96,12 +113,16 @@ void wiRenderTarget::Initialize(UINT width, UINT height, int numViews, bool hasD
|
||||
}
|
||||
void wiRenderTarget::InitializeCube(UINT size, int numViews, bool hasDepth, DXGI_FORMAT format, UINT mipMapLevelCount)
|
||||
{
|
||||
isCube = true;
|
||||
|
||||
this->numViews = numViews;
|
||||
texture2D.resize(numViews);
|
||||
renderTarget.resize(numViews);
|
||||
shaderResource.resize(numViews);
|
||||
SAVEDshaderResource.resize(numViews);
|
||||
//texture2D.resize(numViews);
|
||||
//renderTarget.resize(numViews);
|
||||
//shaderResource.resize(numViews);
|
||||
//SAVEDshaderResource.resize(numViews);
|
||||
renderTargets_Cube.resize(numViews);
|
||||
|
||||
Texture2DDesc textureDesc;
|
||||
ZeroMemory(&textureDesc, sizeof(textureDesc));
|
||||
textureDesc.Width = size;
|
||||
textureDesc.Height = size;
|
||||
@@ -120,25 +141,30 @@ void wiRenderTarget::InitializeCube(UINT size, int numViews, bool hasDepth, DXGI
|
||||
}
|
||||
|
||||
|
||||
RenderTargetViewDesc renderTargetViewDesc;
|
||||
renderTargetViewDesc.Format = format;
|
||||
renderTargetViewDesc.ViewDimension = RESOURCE_DIMENSION_TEXTURE2DARRAY;
|
||||
// renderTargetViewDesc.Texture2DArray.FirstArraySlice = 0;
|
||||
//renderTargetViewDesc.Texture2DArray.ArraySize = 6;
|
||||
// renderTargetViewDesc.Texture2DArray.MipSlice = 0;
|
||||
renderTargetViewDesc.ArraySize = 6;
|
||||
|
||||
ShaderResourceViewDesc shaderResourceViewDesc;
|
||||
shaderResourceViewDesc.Format = format;
|
||||
shaderResourceViewDesc.ViewDimension = RESOURCE_DIMENSION_TEXTURECUBE;
|
||||
//shaderResourceViewDesc.TextureCube.MostDetailedMip = 0; //from most detailed...
|
||||
//shaderResourceViewDesc.TextureCube.MipLevels = -1; //...to least detailed
|
||||
shaderResourceViewDesc.mipLevels = -1;
|
||||
//RenderTargetViewDesc renderTargetViewDesc;
|
||||
//renderTargetViewDesc.Format = format;
|
||||
//renderTargetViewDesc.ViewDimension = RESOURCE_DIMENSION_TEXTURE2DARRAY;
|
||||
//// renderTargetViewDesc.Texture2DArray.FirstArraySlice = 0;
|
||||
////renderTargetViewDesc.Texture2DArray.ArraySize = 6;
|
||||
//// renderTargetViewDesc.Texture2DArray.MipSlice = 0;
|
||||
//renderTargetViewDesc.ArraySize = 6;
|
||||
//
|
||||
//ShaderResourceViewDesc shaderResourceViewDesc;
|
||||
//shaderResourceViewDesc.Format = format;
|
||||
//shaderResourceViewDesc.ViewDimension = RESOURCE_DIMENSION_TEXTURECUBE;
|
||||
////shaderResourceViewDesc.TextureCube.MostDetailedMip = 0; //from most detailed...
|
||||
////shaderResourceViewDesc.TextureCube.MipLevels = -1; //...to least detailed
|
||||
//shaderResourceViewDesc.mipLevels = -1;
|
||||
|
||||
for(int i=0;i<numViews;++i){
|
||||
wiRenderer::graphicsDevice->CreateTexture2D(&textureDesc, NULL, &texture2D[i]);
|
||||
wiRenderer::graphicsDevice->CreateRenderTargetView(texture2D[i], &renderTargetViewDesc, &renderTarget[i]);
|
||||
wiRenderer::graphicsDevice->CreateShaderResourceView(texture2D[i], &shaderResourceViewDesc, &shaderResource[0]);
|
||||
//for(int i=0;i<numViews;++i){
|
||||
// wiRenderer::graphicsDevice->CreateTexture2D(&textureDesc, NULL, &texture2D[i]);
|
||||
// wiRenderer::graphicsDevice->CreateRenderTargetView(texture2D[i], &renderTargetViewDesc, &renderTarget[i]);
|
||||
// wiRenderer::graphicsDevice->CreateShaderResourceView(texture2D[i], &shaderResourceViewDesc, &shaderResource[0]);
|
||||
//}
|
||||
|
||||
for (int i = 0; i < numViews; ++i)
|
||||
{
|
||||
wiRenderer::graphicsDevice->CreateTextureCube(&textureDesc, nullptr, &renderTargets_Cube[i]);
|
||||
}
|
||||
|
||||
viewPort.Width = (FLOAT)size;
|
||||
@@ -167,7 +193,7 @@ void wiRenderTarget::Activate(GRAPHICSTHREAD threadID, float r, float g, float b
|
||||
Set(threadID);
|
||||
float ClearColor[4] = { r, g, b, a };
|
||||
for(int i=0;i<numViews;++i)
|
||||
wiRenderer::graphicsDevice->ClearRenderTarget(renderTarget[i], ClearColor);
|
||||
wiRenderer::graphicsDevice->ClearRenderTarget(GetTexture(i), ClearColor);
|
||||
if(depth) depth->Clear(threadID);
|
||||
}
|
||||
void wiRenderTarget::Activate(GRAPHICSTHREAD threadID, wiDepthTarget* getDepth, float r, float g, float b, float a)
|
||||
@@ -175,7 +201,7 @@ void wiRenderTarget::Activate(GRAPHICSTHREAD threadID, wiDepthTarget* getDepth,
|
||||
Set(threadID,getDepth);
|
||||
float ClearColor[4] = { r, g, b, a };
|
||||
for(int i=0;i<numViews;++i)
|
||||
wiRenderer::graphicsDevice->ClearRenderTarget(renderTarget[i], ClearColor);
|
||||
wiRenderer::graphicsDevice->ClearRenderTarget(GetTexture(i), ClearColor);
|
||||
}
|
||||
void wiRenderTarget::Activate(GRAPHICSTHREAD threadID, wiDepthTarget* getDepth)
|
||||
{
|
||||
@@ -188,40 +214,41 @@ void wiRenderTarget::Deactivate(GRAPHICSTHREAD threadID)
|
||||
void wiRenderTarget::Set(GRAPHICSTHREAD threadID)
|
||||
{
|
||||
wiRenderer::graphicsDevice->BindViewports(1, &viewPort);
|
||||
wiRenderer::graphicsDevice->BindRenderTargets(numViews, renderTarget.data(),(depth?depth->depthTarget:nullptr));
|
||||
wiRenderer::graphicsDevice->BindRenderTargets(numViews, (isCube ? (Texture2D**)renderTargets_Cube.data() : renderTargets.data()), (depth ? depth->GetTexture() : nullptr));
|
||||
}
|
||||
void wiRenderTarget::Set(GRAPHICSTHREAD threadID, wiDepthTarget* getDepth)
|
||||
{
|
||||
depth = getDepth;
|
||||
wiRenderer::graphicsDevice->BindViewports(1, &viewPort);
|
||||
wiRenderer::graphicsDevice->BindRenderTargets(numViews, renderTarget.data(),(depth?depth->depthTarget:nullptr));
|
||||
}
|
||||
void wiRenderTarget::Retarget(TextureView resource)
|
||||
{
|
||||
retargetted=true;
|
||||
for(unsigned int i=0;i<shaderResource.size();++i){
|
||||
SAVEDshaderResource[i]=shaderResource[i];
|
||||
shaderResource[i]=resource;
|
||||
}
|
||||
}
|
||||
void wiRenderTarget::Restore(){
|
||||
if(retargetted){
|
||||
for(unsigned int i=0;i<shaderResource.size();++i){
|
||||
shaderResource[i]=SAVEDshaderResource[i];
|
||||
}
|
||||
}
|
||||
retargetted=false;
|
||||
wiRenderer::graphicsDevice->BindRenderTargets(numViews, (isCube ? (Texture2D**)renderTargets_Cube.data() : renderTargets.data()), (depth ? depth->GetTexture() : nullptr));
|
||||
}
|
||||
//void wiRenderTarget::Retarget(Texture2D* resource)
|
||||
//{
|
||||
// retargetted=true;
|
||||
// for(unsigned int i=0;i<shaderResource.size();++i){
|
||||
// SAVEDshaderResource[i]=shaderResource[i];
|
||||
// shaderResource[i]=resource;
|
||||
// }
|
||||
//}
|
||||
//void wiRenderTarget::Restore(){
|
||||
// if(retargetted){
|
||||
// for(unsigned int i=0;i<shaderResource.size();++i){
|
||||
// shaderResource[i]=SAVEDshaderResource[i];
|
||||
// }
|
||||
// }
|
||||
// retargetted=false;
|
||||
//}
|
||||
|
||||
UINT wiRenderTarget::GetMipCount()
|
||||
{
|
||||
if (shaderResource.empty())
|
||||
return 0U;
|
||||
//if (shaderResource.empty())
|
||||
// return 0U;
|
||||
Texture2DDesc desc = GetDesc();
|
||||
|
||||
if (textureDesc.MipLevels>0)
|
||||
return textureDesc.MipLevels;
|
||||
if (desc.MipLevels>0)
|
||||
return desc.MipLevels;
|
||||
|
||||
UINT maxDim = max(textureDesc.Width, textureDesc.Height);
|
||||
UINT maxDim = max(desc.Width, desc.Height);
|
||||
return static_cast<UINT>( log2(static_cast<double>(maxDim)) );
|
||||
}
|
||||
|
||||
|
||||
@@ -8,16 +8,19 @@ class wiRenderTarget
|
||||
{
|
||||
private:
|
||||
int numViews;
|
||||
bool retargetted;
|
||||
vector<TextureView> SAVEDshaderResource;
|
||||
//bool retargetted;
|
||||
//vector<Texture2D*> SAVEDshaderResource;
|
||||
void clear();
|
||||
Texture2DDesc textureDesc;
|
||||
//Texture2DDesc textureDesc;
|
||||
vector<Texture2D*> renderTargets;
|
||||
vector<TextureCube*> renderTargets_Cube;
|
||||
bool isCube;
|
||||
public:
|
||||
ViewPort viewPort;
|
||||
vector<Texture2D> texture2D;
|
||||
vector<RenderTargetView> renderTarget;
|
||||
vector<TextureView> shaderResource;
|
||||
wiDepthTarget* depth;
|
||||
//vector<Texture2D> texture2D;
|
||||
//vector<RenderTargetView> renderTarget;
|
||||
//vector<Texture2D*> shaderResource;
|
||||
ViewPort viewPort;
|
||||
wiDepthTarget* depth;
|
||||
|
||||
wiRenderTarget();
|
||||
wiRenderTarget(UINT width, UINT height, int numViews = 1, bool hasDepth = false, UINT MSAAC = 1, UINT MSAAQ = 0, DXGI_FORMAT format = DXGI_FORMAT_R8G8B8A8_UNORM, UINT mipMapLevelCount = 1);
|
||||
@@ -33,10 +36,11 @@ public:
|
||||
void Deactivate(GRAPHICSTHREAD threadID);
|
||||
void Set(GRAPHICSTHREAD threadID);
|
||||
void Set(GRAPHICSTHREAD threadID, wiDepthTarget*);
|
||||
void Retarget(TextureView resource);
|
||||
void Restore();
|
||||
//void Retarget(Texture2D* resource);
|
||||
//void Restore();
|
||||
|
||||
Texture2DDesc GetDesc() const{ return textureDesc; }
|
||||
Texture2D* GetTexture(int viewID = 0) const{ return (isCube ? renderTargets_Cube[viewID] : renderTargets[viewID]); }
|
||||
Texture2DDesc GetDesc(int viewID = 0) const{ return GetTexture(viewID)->desc; }
|
||||
UINT GetMipCount();
|
||||
};
|
||||
|
||||
|
||||
+26
-23
@@ -24,6 +24,8 @@
|
||||
#include "wiGraphicsAPI_DX11.h"
|
||||
|
||||
#pragma region STATICS
|
||||
GraphicsDevice* wiRenderer::graphicsDevice = nullptr;
|
||||
|
||||
Sampler wiRenderer::samplers[SSLOT_COUNT];
|
||||
|
||||
BufferResource wiRenderer::constantBuffers[CBTYPE_LAST];
|
||||
@@ -42,7 +44,7 @@ int wiRenderer::SCREENWIDTH=1280,wiRenderer::SCREENHEIGHT=720,wiRenderer::SHADOW
|
||||
bool wiRenderer::HAIRPARTICLEENABLED=true,wiRenderer::EMITTERSENABLED=true;
|
||||
bool wiRenderer::wireRender = false, wiRenderer::debugSpheres = false, wiRenderer::debugBoneLines = false, wiRenderer::debugBoxes = false;
|
||||
|
||||
TextureView wiRenderer::enviroMap,wiRenderer::colorGrading;
|
||||
Texture2D* wiRenderer::enviroMap,*wiRenderer::colorGrading;
|
||||
float wiRenderer::GameSpeed=1,wiRenderer::overrideGameSpeed=1;
|
||||
int wiRenderer::visibleCount;
|
||||
wiRenderTarget wiRenderer::normalMapRT, wiRenderer::imagesRT, wiRenderer::imagesRTAdd;
|
||||
@@ -1533,7 +1535,7 @@ void wiRenderer::DrawSoftPremulParticles(Camera* camera, GRAPHICSTHREAD threadID
|
||||
e->DrawPremul(camera, threadID, dark);
|
||||
}
|
||||
}
|
||||
void wiRenderer::DrawTrails(GRAPHICSTHREAD threadID, TextureView refracRes){
|
||||
void wiRenderer::DrawTrails(GRAPHICSTHREAD threadID, Texture2D* refracRes){
|
||||
wiRenderer::graphicsDevice->BindPrimitiveTopology(TRIANGLESTRIP,threadID);
|
||||
wiRenderer::graphicsDevice->BindVertexLayout(vertexLayouts[VLTYPE_TRAIL],threadID);
|
||||
|
||||
@@ -1603,12 +1605,12 @@ void wiRenderer::DrawTrails(GRAPHICSTHREAD threadID, TextureView refracRes){
|
||||
}
|
||||
}
|
||||
}
|
||||
void wiRenderer::DrawImagesAdd(GRAPHICSTHREAD threadID, TextureView refracRes){
|
||||
void wiRenderer::DrawImagesAdd(GRAPHICSTHREAD threadID, Texture2D* refracRes){
|
||||
imagesRTAdd.Activate(threadID,0,0,0,1);
|
||||
//wiImage::BatchBegin(threadID);
|
||||
for(wiSprite* x : images){
|
||||
if(x->effects.blendFlag==BLENDMODE_ADDITIVE){
|
||||
/*TextureView nor = x->effects.normalMap;
|
||||
/*Texture2D* nor = x->effects.normalMap;
|
||||
x->effects.setNormalMap(nullptr);
|
||||
bool changedBlend=false;
|
||||
if(x->effects.blendFlag==BLENDMODE_OPAQUE && nor){
|
||||
@@ -1622,12 +1624,12 @@ void wiRenderer::DrawImagesAdd(GRAPHICSTHREAD threadID, TextureView refracRes){
|
||||
}
|
||||
}
|
||||
}
|
||||
void wiRenderer::DrawImages(GRAPHICSTHREAD threadID, TextureView refracRes){
|
||||
void wiRenderer::DrawImages(GRAPHICSTHREAD threadID, Texture2D* refracRes){
|
||||
imagesRT.Activate(threadID,0,0,0,0);
|
||||
//wiImage::BatchBegin(threadID);
|
||||
for(wiSprite* x : images){
|
||||
if(x->effects.blendFlag==BLENDMODE_ALPHA || x->effects.blendFlag==BLENDMODE_OPAQUE){
|
||||
/*TextureView nor = x->effects.normalMap;
|
||||
/*Texture2D* nor = x->effects.normalMap;
|
||||
x->effects.setNormalMap(nullptr);
|
||||
bool changedBlend=false;
|
||||
if(x->effects.blendFlag==BLENDMODE_OPAQUE && nor){
|
||||
@@ -1641,7 +1643,7 @@ void wiRenderer::DrawImages(GRAPHICSTHREAD threadID, TextureView refracRes){
|
||||
}
|
||||
}
|
||||
}
|
||||
void wiRenderer::DrawImagesNormals(GRAPHICSTHREAD threadID, TextureView refracRes){
|
||||
void wiRenderer::DrawImagesNormals(GRAPHICSTHREAD threadID, Texture2D* refracRes){
|
||||
normalMapRT.Activate(threadID,0,0,0,0);
|
||||
//wiImage::BatchBegin(threadID);
|
||||
for(wiSprite* x : images){
|
||||
@@ -1727,7 +1729,7 @@ void wiRenderer::DrawLights(Camera* camera, GRAPHICSTHREAD threadID, unsigned in
|
||||
for (unsigned int shmap = 0; shmap < l->shadowMaps_dirLight.size(); ++shmap){
|
||||
(*lcb).mShM[shmap]=l->shadowCam[shmap].getVP();
|
||||
if(l->shadowMaps_dirLight[shmap].depth)
|
||||
wiRenderer::graphicsDevice->BindTexturePS(l->shadowMaps_dirLight[shmap].depth->shaderResource,TEXSLOT_SHADOW0+shmap,threadID);
|
||||
wiRenderer::graphicsDevice->BindTexturePS(l->shadowMaps_dirLight[shmap].depth->GetTexture(),TEXSLOT_SHADOW0+shmap,threadID);
|
||||
}
|
||||
wiRenderer::graphicsDevice->UpdateBuffer(constantBuffers[CBTYPE_DIRLIGHT],lcb,threadID);
|
||||
|
||||
@@ -1745,7 +1747,7 @@ void wiRenderer::DrawLights(Camera* camera, GRAPHICSTHREAD threadID, unsigned in
|
||||
{
|
||||
(*lcb).enerdis.w = 1.f;
|
||||
if(Light::shadowMaps_pointLight[l->shadowMap_index].depth)
|
||||
wiRenderer::graphicsDevice->BindTexturePS(Light::shadowMaps_pointLight[l->shadowMap_index].depth->shaderResource, TEXSLOT_SHADOW_CUBE, threadID);
|
||||
wiRenderer::graphicsDevice->BindTexturePS(Light::shadowMaps_pointLight[l->shadowMap_index].depth->GetTexture(), TEXSLOT_SHADOW_CUBE, threadID);
|
||||
}
|
||||
wiRenderer::graphicsDevice->UpdateBuffer(constantBuffers[CBTYPE_POINTLIGHT], lcb, threadID);
|
||||
|
||||
@@ -1776,7 +1778,7 @@ void wiRenderer::DrawLights(Camera* camera, GRAPHICSTHREAD threadID, unsigned in
|
||||
{
|
||||
(*lcb).mShM = l->shadowCam[0].getVP();
|
||||
if(Light::shadowMaps_spotLight[l->shadowMap_index].depth)
|
||||
wiRenderer::graphicsDevice->BindTexturePS(Light::shadowMaps_spotLight[l->shadowMap_index].depth->shaderResource, TEXSLOT_SHADOW0, threadID);
|
||||
wiRenderer::graphicsDevice->BindTexturePS(Light::shadowMaps_spotLight[l->shadowMap_index].depth->GetTexture(), TEXSLOT_SHADOW0, threadID);
|
||||
}
|
||||
wiRenderer::graphicsDevice->UpdateBuffer(constantBuffers[CBTYPE_SPOTLIGHT], lcb, threadID);
|
||||
|
||||
@@ -2318,7 +2320,7 @@ void wiRenderer::SetSpotLightShadowProps(int shadowMapCount, int resolution)
|
||||
|
||||
void wiRenderer::DrawWorld(Camera* camera, bool DX11Eff, int tessF, GRAPHICSTHREAD threadID
|
||||
, bool BlackOut, bool isReflection, SHADERTYPE shaded
|
||||
, TextureView refRes, bool grass, GRAPHICSTHREAD thread)
|
||||
, Texture2D* refRes, bool grass, GRAPHICSTHREAD thread)
|
||||
{
|
||||
CulledCollection culledRenderer;
|
||||
CulledList culledObjects;
|
||||
@@ -2329,7 +2331,7 @@ void wiRenderer::DrawWorld(Camera* camera, bool DX11Eff, int tessF, GRAPHICSTHRE
|
||||
if(!culledObjects.empty())
|
||||
{
|
||||
|
||||
TextureView envMaps[] = { enviroMap, enviroMap };
|
||||
Texture2D* envMaps[] = { enviroMap, enviroMap };
|
||||
XMFLOAT3 envMapPositions[] = { XMFLOAT3(0,0,0),XMFLOAT3(0,0,0) };
|
||||
if (!GetScene().environmentProbes.empty())
|
||||
{
|
||||
@@ -2360,7 +2362,7 @@ void wiRenderer::DrawWorld(Camera* camera, bool DX11Eff, int tessF, GRAPHICSTHRE
|
||||
}
|
||||
for (unsigned int i = 0; i < min(sortedEnvProbes.size(), 2); ++i)
|
||||
{
|
||||
envMaps[i] = sortedEnvProbes[i]->cubeMap.shaderResource.front();
|
||||
envMaps[i] = sortedEnvProbes[i]->cubeMap.GetTexture();
|
||||
envMapPositions[i] = sortedEnvProbes[i]->translation;
|
||||
}
|
||||
}
|
||||
@@ -2517,8 +2519,8 @@ void wiRenderer::DrawWorld(Camera* camera, bool DX11Eff, int tessF, GRAPHICSTHRE
|
||||
|
||||
}
|
||||
|
||||
void wiRenderer::DrawWorldTransparent(Camera* camera, TextureView refracRes, TextureView refRes
|
||||
, TextureView waterRippleNormals, GRAPHICSTHREAD threadID)
|
||||
void wiRenderer::DrawWorldTransparent(Camera* camera, Texture2D* refracRes, Texture2D* refRes
|
||||
, Texture2D* waterRippleNormals, GRAPHICSTHREAD threadID)
|
||||
{
|
||||
CulledCollection culledRenderer;
|
||||
CulledList culledObjects;
|
||||
@@ -2818,14 +2820,15 @@ void wiRenderer::SetClipPlane(XMFLOAT4 clipPlane, GRAPHICSTHREAD threadID)
|
||||
{
|
||||
wiRenderer::graphicsDevice->UpdateBuffer(constantBuffers[CBTYPE_CLIPPLANE], &clipPlane, threadID);
|
||||
}
|
||||
void wiRenderer::UpdateGBuffer(vector<TextureView> gbuffer, GRAPHICSTHREAD threadID)
|
||||
void wiRenderer::UpdateGBuffer(Texture2D* slot0, Texture2D* slot1, Texture2D* slot2, Texture2D* slot3, Texture2D* slot4, GRAPHICSTHREAD threadID)
|
||||
{
|
||||
for (unsigned int i = 0; i < gbuffer.size(); ++i)
|
||||
{
|
||||
wiRenderer::graphicsDevice->BindTexturePS(gbuffer[i], TEXSLOT_GBUFFER0 + i, threadID);
|
||||
}
|
||||
wiRenderer::graphicsDevice->BindTexturePS(slot0, TEXSLOT_GBUFFER0, threadID);
|
||||
wiRenderer::graphicsDevice->BindTexturePS(slot1, TEXSLOT_GBUFFER1, threadID);
|
||||
wiRenderer::graphicsDevice->BindTexturePS(slot2, TEXSLOT_GBUFFER2, threadID);
|
||||
wiRenderer::graphicsDevice->BindTexturePS(slot3, TEXSLOT_GBUFFER3, threadID);
|
||||
wiRenderer::graphicsDevice->BindTexturePS(slot4, TEXSLOT_GBUFFER4, threadID);
|
||||
}
|
||||
void wiRenderer::UpdateDepthBuffer(TextureView depth, TextureView linearDepth, GRAPHICSTHREAD threadID)
|
||||
void wiRenderer::UpdateDepthBuffer(Texture2D* depth, Texture2D* linearDepth, GRAPHICSTHREAD threadID)
|
||||
{
|
||||
wiRenderer::graphicsDevice->BindTexturePS(depth, TEXSLOT_DEPTH, threadID);
|
||||
wiRenderer::graphicsDevice->BindTextureVS(depth, TEXSLOT_DEPTH, threadID);
|
||||
@@ -3322,9 +3325,9 @@ void wiRenderer::PutEnvProbe(const XMFLOAT3& position, int resolution)
|
||||
|
||||
probe->cubeMap.Deactivate(threadID);
|
||||
|
||||
wiRenderer::graphicsDevice->GenerateMips(probe->cubeMap.shaderResource[0], threadID);
|
||||
wiRenderer::graphicsDevice->GenerateMips(probe->cubeMap.GetTexture(), threadID);
|
||||
|
||||
enviroMap = probe->cubeMap.shaderResource.front();
|
||||
enviroMap = probe->cubeMap.GetTexture();
|
||||
|
||||
scene->environmentProbes.push_back(probe);
|
||||
|
||||
|
||||
+14
-14
@@ -276,7 +276,7 @@ protected:
|
||||
static bool wireRender, debugSpheres, debugBoneLines, debugBoxes;
|
||||
|
||||
|
||||
static TextureView enviroMap,colorGrading;
|
||||
static Texture2D* enviroMap,*colorGrading;
|
||||
static void LoadBuffers();
|
||||
static void LoadBasicShaders();
|
||||
static void LoadLineShaders();
|
||||
@@ -327,10 +327,10 @@ public:
|
||||
static void SetToDrawDebugBoxes(bool param){debugBoxes=param;}
|
||||
static bool GetToDrawDebugSpheres(){return debugSpheres;};
|
||||
static bool GetToDrawDebugBoxes(){return debugBoxes;};
|
||||
static TextureView GetColorGrading(){return colorGrading;};
|
||||
static void SetColorGrading(TextureView tex){colorGrading=tex;};
|
||||
static void SetEnviromentMap(TextureView tex){ enviroMap = tex; }
|
||||
static TextureView GetEnviromentMap(){ return enviroMap; }
|
||||
static Texture2D* GetColorGrading(){return colorGrading;};
|
||||
static void SetColorGrading(Texture2D* tex){colorGrading=tex;};
|
||||
static void SetEnviromentMap(Texture2D* tex){ enviroMap = tex; }
|
||||
static Texture2D* GetEnviromentMap(){ return enviroMap; }
|
||||
|
||||
|
||||
static Transform* getTransformByName(const string& name);
|
||||
@@ -357,28 +357,28 @@ public:
|
||||
static void UpdateFrameCB(GRAPHICSTHREAD threadID);
|
||||
static void UpdateCameraCB(GRAPHICSTHREAD threadID);
|
||||
static void SetClipPlane(XMFLOAT4 clipPlane, GRAPHICSTHREAD threadID);
|
||||
static void UpdateGBuffer(vector<TextureView> gbuffer, GRAPHICSTHREAD threadID);
|
||||
static void UpdateDepthBuffer(TextureView depth, TextureView linearDepth, GRAPHICSTHREAD threadID);
|
||||
static void UpdateGBuffer(Texture2D* slot0, Texture2D* slot1, Texture2D* slot2, Texture2D* slot3, Texture2D* slot4, GRAPHICSTHREAD threadID);
|
||||
static void UpdateDepthBuffer(Texture2D* depth, Texture2D* linearDepth, GRAPHICSTHREAD threadID);
|
||||
|
||||
static void DrawSky(GRAPHICSTHREAD threadID, bool isReflection = false);
|
||||
static void DrawSun(GRAPHICSTHREAD threadID);
|
||||
static void DrawWorld(Camera* camera, bool DX11Eff, int tessF, GRAPHICSTHREAD threadID
|
||||
, bool BlackOut, bool isReflection, SHADERTYPE shaded, TextureView refRes, bool grass, GRAPHICSTHREAD thread);
|
||||
, bool BlackOut, bool isReflection, SHADERTYPE shaded, Texture2D* refRes, bool grass, GRAPHICSTHREAD thread);
|
||||
static void ClearShadowMaps(GRAPHICSTHREAD threadID);
|
||||
static void DrawForShadowMap(GRAPHICSTHREAD threadID);
|
||||
static void DrawWorldTransparent(Camera* camera, TextureView refracRes, TextureView refRes
|
||||
, TextureView waterRippleNormals, GRAPHICSTHREAD threadID);
|
||||
static void DrawWorldTransparent(Camera* camera, Texture2D* refracRes, Texture2D* refRes
|
||||
, Texture2D* waterRippleNormals, GRAPHICSTHREAD threadID);
|
||||
void DrawDebugSpheres(Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void DrawDebugBoneLines(Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void DrawDebugLines(Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void DrawDebugBoxes(Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void DrawSoftParticles(Camera* camera, GRAPHICSTHREAD threadID, bool dark = false);
|
||||
static void DrawSoftPremulParticles(Camera* camera, GRAPHICSTHREAD threadID, bool dark = false);
|
||||
static void DrawTrails(GRAPHICSTHREAD threadID, TextureView refracRes);
|
||||
static void DrawImagesAdd(GRAPHICSTHREAD threadID, TextureView refracRes);
|
||||
static void DrawTrails(GRAPHICSTHREAD threadID, Texture2D* refracRes);
|
||||
static void DrawImagesAdd(GRAPHICSTHREAD threadID, Texture2D* refracRes);
|
||||
//alpha-opaque
|
||||
static void DrawImages(GRAPHICSTHREAD threadID, TextureView refracRes);
|
||||
static void DrawImagesNormals(GRAPHICSTHREAD threadID, TextureView refracRes);
|
||||
static void DrawImages(GRAPHICSTHREAD threadID, Texture2D* refracRes);
|
||||
static void DrawImagesNormals(GRAPHICSTHREAD threadID, Texture2D* refracRes);
|
||||
static void DrawLights(Camera* camera, GRAPHICSTHREAD threadID, unsigned int stencilRef = 2);
|
||||
static void DrawVolumeLights(Camera* camera, GRAPHICSTHREAD threadID);
|
||||
static void DrawLensFlares(GRAPHICSTHREAD threadID);
|
||||
|
||||
@@ -89,7 +89,7 @@ void* wiResourceManager::add(const string& name, Data_Type newType
|
||||
switch(type){
|
||||
case Data_Type::IMAGE:
|
||||
{
|
||||
TextureView image=nullptr;
|
||||
Texture2D* image=nullptr;
|
||||
//if(
|
||||
// !ext.compare("jpg")
|
||||
// || !ext.compare("JPG")
|
||||
@@ -260,7 +260,7 @@ bool wiResourceManager::del(const string& name, bool forceDelete)
|
||||
switch(res->type){
|
||||
case Data_Type::IMAGE:
|
||||
case Data_Type::IMAGE_STAGING:
|
||||
SAFE_RELEASE(reinterpret_cast<TextureView&>(res->data));
|
||||
SAFE_DELETE(reinterpret_cast<Texture2D*&>(res->data));
|
||||
break;
|
||||
case Data_Type::VERTEXSHADER:
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ int wiResourceManager_BindLua::Get(lua_State *L)
|
||||
switch (data->type)
|
||||
{
|
||||
case wiResourceManager::Data_Type::IMAGE:
|
||||
Luna<Texture_BindLua>::push(L, new Texture_BindLua((TextureView)data->data));
|
||||
Luna<Texture_BindLua>::push(L, new Texture_BindLua((Texture2D*)data->data));
|
||||
return 1;
|
||||
break;
|
||||
case wiResourceManager::Data_Type::MUSIC:
|
||||
|
||||
@@ -40,15 +40,15 @@ void wiSprite::Init(){
|
||||
void wiSprite::CreateReference(const string& newTexture, const string& newMask, const string& newNormal){
|
||||
if(newTexture.length()) {
|
||||
texture = newTexture;
|
||||
texturePointer = (TextureView)ContentHolder->add(newTexture);
|
||||
texturePointer = (Texture2D*)ContentHolder->add(newTexture);
|
||||
}
|
||||
if(newMask.length()) {
|
||||
maskPointer = (TextureView)ContentHolder->add(newMask);
|
||||
maskPointer = (Texture2D*)ContentHolder->add(newMask);
|
||||
effects.setMaskMap( maskPointer );
|
||||
mask = newMask;
|
||||
}
|
||||
if(newNormal.length()) {
|
||||
normalPointer = (TextureView)ContentHolder->add(newNormal);
|
||||
normalPointer = (Texture2D*)ContentHolder->add(newNormal);
|
||||
//effects.setNormalMap( normalPointer );
|
||||
normal = newNormal;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ void wiSprite::CleanUp(){
|
||||
ContentHolder->del(mask);
|
||||
}
|
||||
|
||||
void wiSprite::Draw(TextureView refracRes, GRAPHICSTHREAD threadID){
|
||||
void wiSprite::Draw(Texture2D* refracRes, GRAPHICSTHREAD threadID){
|
||||
if(effects.opacity>0 && ((effects.blendFlag==BLENDMODE_ADDITIVE && effects.fade<1) || effects.blendFlag!=BLENDMODE_ADDITIVE) ){
|
||||
effects.setRefractionSource(refracRes);
|
||||
wiImage::Draw(texturePointer,effects,threadID);
|
||||
|
||||
@@ -9,7 +9,7 @@ class wiSprite : public wiImage
|
||||
{
|
||||
private:
|
||||
string texture, mask, normal;
|
||||
TextureView texturePointer,normalPointer,maskPointer;
|
||||
Texture2D* texturePointer,*normalPointer,*maskPointer;
|
||||
wiResourceManager* ContentHolder;
|
||||
public:
|
||||
wiSprite(wiResourceManager* contentHolder = nullptr);
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
|
||||
void Update(float);
|
||||
void Update();
|
||||
void Draw(TextureView refracRes, GRAPHICSTHREAD threadID);
|
||||
void Draw(Texture2D* refracRes, GRAPHICSTHREAD threadID);
|
||||
void Draw();
|
||||
void DrawNormal(GRAPHICSTHREAD threadID);
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
};
|
||||
Anim anim;
|
||||
|
||||
TextureView getTexture(){return texturePointer;}
|
||||
void setTexture(TextureView value){texturePointer=value;}
|
||||
Texture2D* getTexture(){return texturePointer;}
|
||||
void setTexture(Texture2D* value){texturePointer=value;}
|
||||
};
|
||||
|
||||
|
||||
@@ -14,18 +14,18 @@ wiTextureHelper::wiTextureHelperInstance::~wiTextureHelperInstance()
|
||||
{
|
||||
for (int i = 0; i < HELPERTEXTURE_COUNT; ++i)
|
||||
{
|
||||
SAFE_RELEASE(helperTextures[i]);
|
||||
SAFE_DELETE(helperTextures[i]);
|
||||
}
|
||||
|
||||
for (auto& x : colorTextures)
|
||||
{
|
||||
SAFE_RELEASE(x.second);
|
||||
SAFE_DELETE(x.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
TextureView wiTextureHelper::wiTextureHelperInstance::getRandom64x64()
|
||||
Texture2D* wiTextureHelper::wiTextureHelperInstance::getRandom64x64()
|
||||
{
|
||||
if (helperTextures[HELPERTEXTURE_RANDOM64X64] != nullptr)
|
||||
{
|
||||
@@ -53,7 +53,7 @@ TextureView wiTextureHelper::wiTextureHelperInstance::getRandom64x64()
|
||||
return helperTextures[HELPERTEXTURE_RANDOM64X64];
|
||||
}
|
||||
|
||||
TextureView wiTextureHelper::wiTextureHelperInstance::getColorGradeDefault()
|
||||
Texture2D* wiTextureHelper::wiTextureHelperInstance::getColorGradeDefault()
|
||||
{
|
||||
if (helperTextures[HELPERTEXTURE_COLORGRADEDEFAULT] != nullptr)
|
||||
{
|
||||
@@ -93,27 +93,27 @@ TextureView wiTextureHelper::wiTextureHelperInstance::getColorGradeDefault()
|
||||
return helperTextures[HELPERTEXTURE_COLORGRADEDEFAULT];
|
||||
}
|
||||
|
||||
TextureView wiTextureHelper::wiTextureHelperInstance::getNormalMapDefault()
|
||||
Texture2D* wiTextureHelper::wiTextureHelperInstance::getNormalMapDefault()
|
||||
{
|
||||
return getColor(wiColor(127, 127, 255, 255));
|
||||
}
|
||||
|
||||
TextureView wiTextureHelper::wiTextureHelperInstance::getWhite()
|
||||
Texture2D* wiTextureHelper::wiTextureHelperInstance::getWhite()
|
||||
{
|
||||
return getColor(wiColor(255, 255, 255, 255));
|
||||
}
|
||||
|
||||
TextureView wiTextureHelper::wiTextureHelperInstance::getBlack()
|
||||
Texture2D* wiTextureHelper::wiTextureHelperInstance::getBlack()
|
||||
{
|
||||
return getColor(wiColor(0, 0, 0, 255));
|
||||
}
|
||||
|
||||
TextureView wiTextureHelper::wiTextureHelperInstance::getTransparent()
|
||||
Texture2D* wiTextureHelper::wiTextureHelperInstance::getTransparent()
|
||||
{
|
||||
return getColor(wiColor(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
TextureView wiTextureHelper::wiTextureHelperInstance::getColor(const wiColor& color)
|
||||
Texture2D* wiTextureHelper::wiTextureHelperInstance::getColor(const wiColor& color)
|
||||
{
|
||||
if (colorTextures.find(color.rgba) != colorTextures.end())
|
||||
{
|
||||
@@ -130,7 +130,7 @@ TextureView wiTextureHelper::wiTextureHelperInstance::getColor(const wiColor& co
|
||||
data[i + 3] = color.a;
|
||||
}
|
||||
|
||||
TextureView texture;
|
||||
Texture2D* texture;
|
||||
if (FAILED(CreateTexture(texture, data, 2, 2, 4)))
|
||||
{
|
||||
delete[] data;
|
||||
|
||||
@@ -17,21 +17,21 @@ private:
|
||||
HELPERTEXTURE_NORMALMAPDEFAULT,
|
||||
HELPERTEXTURE_COUNT
|
||||
};
|
||||
TextureView helperTextures[HELPERTEXTURE_COUNT];
|
||||
Texture2D* helperTextures[HELPERTEXTURE_COUNT];
|
||||
|
||||
unordered_map<unsigned long, TextureView> colorTextures;
|
||||
unordered_map<unsigned long, Texture2D*> colorTextures;
|
||||
public:
|
||||
wiTextureHelperInstance();
|
||||
~wiTextureHelperInstance();
|
||||
|
||||
TextureView getRandom64x64();
|
||||
TextureView getColorGradeDefault();
|
||||
TextureView getNormalMapDefault();
|
||||
Texture2D* getRandom64x64();
|
||||
Texture2D* getColorGradeDefault();
|
||||
Texture2D* getNormalMapDefault();
|
||||
|
||||
TextureView getWhite();
|
||||
TextureView getBlack();
|
||||
TextureView getTransparent();
|
||||
TextureView getColor(const wiColor& color);
|
||||
Texture2D* getWhite();
|
||||
Texture2D* getBlack();
|
||||
Texture2D* getTransparent();
|
||||
Texture2D* getColor(const wiColor& color);
|
||||
};
|
||||
|
||||
static wiTextureHelperInstance* instance;
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static HRESULT CreateTexture(TextureView& texture, T* data, UINT width, UINT height, UINT channelCount, DXGI_FORMAT format = DXGI_FORMAT_R8G8B8A8_UNORM)
|
||||
static HRESULT CreateTexture(Texture2D*& texture, T* data, UINT width, UINT height, UINT channelCount, DXGI_FORMAT format = DXGI_FORMAT_R8G8B8A8_UNORM)
|
||||
{
|
||||
if (data == nullptr)
|
||||
{
|
||||
@@ -67,27 +67,27 @@ public:
|
||||
textureDesc.CPUAccessFlags = 0;
|
||||
textureDesc.MiscFlags = 0;
|
||||
|
||||
ShaderResourceViewDesc shaderResourceViewDesc;
|
||||
shaderResourceViewDesc.Format = format;
|
||||
shaderResourceViewDesc.ViewDimension = RESOURCE_DIMENSION_TEXTURE2D;
|
||||
//shaderResourceViewDesc.Texture2D.MostDetailedMip = 0;
|
||||
//shaderResourceViewDesc.Texture2D.MipLevels = 1;
|
||||
shaderResourceViewDesc.mipLevels = 1;
|
||||
//ShaderResourceViewDesc shaderResourceViewDesc;
|
||||
//shaderResourceViewDesc.Format = format;
|
||||
//shaderResourceViewDesc.ViewDimension = RESOURCE_DIMENSION_TEXTURE2D;
|
||||
////shaderResourceViewDesc.Texture2D.MostDetailedMip = 0;
|
||||
////shaderResourceViewDesc.Texture2D.MipLevels = 1;
|
||||
//shaderResourceViewDesc.mipLevels = 1;
|
||||
|
||||
SubresourceData InitData;
|
||||
ZeroMemory(&InitData, sizeof(InitData));
|
||||
InitData.pSysMem = data;
|
||||
InitData.SysMemPitch = static_cast<UINT>(width * channelCount);
|
||||
|
||||
Texture2D texture2D = nullptr;
|
||||
//Texture2D* texture2D = nullptr;
|
||||
HRESULT hr;
|
||||
hr = wiRenderer::graphicsDevice->CreateTexture2D(&textureDesc, &InitData, &texture2D);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
return hr;
|
||||
}
|
||||
hr = wiRenderer::graphicsDevice->CreateShaderResourceView(texture2D, &shaderResourceViewDesc, &texture);
|
||||
SAFE_RELEASE(texture2D);
|
||||
hr = wiRenderer::graphicsDevice->CreateTexture2D(&textureDesc, &InitData, &texture);
|
||||
//if (FAILED(hr))
|
||||
//{
|
||||
// return hr;
|
||||
//}
|
||||
//hr = wiRenderer::graphicsDevice->CreateShaderResourceView(texture2D, &shaderResourceViewDesc, &texture);
|
||||
//SAFE_RELEASE(texture2D);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user