Why my texture can't show up in full screen mode DX11 game - fullscreen

I'm drawing a texture in a DX11 game. It's strange that the texture never shows up in the full screen mode.
I list my state setting here for reference.
BOOL BlendEnable[] = {TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE};
UINT8 RenderTargetWriteMask[] = {0xF, 0xF, 0xF, 0xF, 0xF, 0xF, 0xF, 0xF};
D3D11_BLEND_DESC bs11 = {0};
bs11.AlphaToCoverageEnable = 0;
bs11.IndependentBlendEnable = false;
for(size_t i = sizeof(BlendEnable) / sizeof(BlendEnable[0]); i--;)
{
bs11.RenderTarget[i].BlendEnable = BlendEnable[i];
bs11.RenderTarget[i].RenderTargetWriteMask = RenderTargetWriteMask[i];
}
bs11.RenderTarget[0].BlendOp = D3D10_DDI_BLEND_OP_ADD;
bs11.RenderTarget[0].BlendOpAlpha = D3D10_DDI_BLEND_OP_ADD;
bs11.RenderTarget[0].DestBlend = D3D10_DDI_BLEND_INV_SRC_ALPHA;
bs11.RenderTarget[0].DestBlendAlpha = D3D10_DDI_BLEND_ZERO;
bs11.RenderTarget[0].SrcBlend = D3D10_DDI_BLEND_SRC_ALPHA;
bs11.RenderTarget[0].SrcBlendAlpha = D3D10_DDI_BLEND_ONE;
bs11.RenderTarget[0].RenderTargetWriteMask = D3D10_DDI_COLOR_WRITE_ENABLE_ALL;
D3D11_DEPTH_STENCIL_DESC depthDesc;
depthDesc.DepthEnable = 0;
depthDesc.DepthWriteMask = D3D10_DEPTH_WRITE_MASK_ZERO;
depthDesc.DepthFunc = D3D10_COMPARISON_NEVER;
depthDesc.BackEnable = 0;
depthDesc.FrontEnable = 0;
depthDesc.StencilEnable = 0;
depthDesc.StencilReadMask = 0;
depthDesc.StencilWriteMask = 0;
depthDesc.FrontFace.StencilDepthFailOp = D3D10_DDI_STENCIL_OP_KEEP;
depthDesc.FrontFace.StencilFailOp = D3D10_DDI_STENCIL_OP_KEEP;
depthDesc.FrontFace.StencilFunc = D3D10_DDI_COMPARISON_ALWAYS;
depthDesc.FrontFace.StencilPassOp = D3D10_DDI_STENCIL_OP_KEEP;
depthDesc.BackFace.StencilDepthFailOp = D3D10_DDI_STENCIL_OP_KEEP;
depthDesc.BackFace.StencilFailOp = D3D10_DDI_STENCIL_OP_KEEP;
depthDesc.BackFace.StencilFunc = D3D10_DDI_COMPARISON_ALWAYS;
depthDesc.BackFace.StencilPassOp = D3D10_DDI_STENCIL_OP_KEEP;
What's the most likely issue it can be?
Thanks,
Marshall

Not sure if this will solve your issues but the D3D11_BLEND_DESC/D3D11_DEPTH_STENCIL_DESC variables are being set as D3D10_ flags as far as I know this usually compiles but should be the D3D11_ equivalent.
So the texture shows under windowed mode?

Related

"Failed to get the task for process -1"

am new to working with iOS, so apologies for what may be a simple question. I have an iOS app that recently stopped working with upgrade to iOS 15. I loaded my previous xcode project into the latest version of Xcode and tried loading again on my iPhone. I'm getting an error stating: "Could not launch "my app name"" "failed to get the process for task -1". In details it provides this additional information. Appreciate any thoughts or input!
{
DVTRadarComponentKey = 855031;
IDERunOperationFailingWorker = DBGLLDBLauncher;
RawUnderlyingErrorMessage = "failed to get the task for process -1";
}
--
Analytics Event: com.apple.dt.IDERunOperationWorkerFinished : {
"device_model" = "iPhone11,2";
"device_osBuild" = "15.0 (19A346)";
"device_platform" = "com.apple.platform.iphoneos";
"launchSession_schemeCommand" = Run;
"launchSession_state" = 1;
"launchSession_targetArch" = arm64;
"operation_duration_ms" = 5872;
"operation_errorCode" = 3;
"operation_errorDomain" = IDEDebugSessionErrorDomain;
"operation_errorWorker" = DBGLLDBLauncher;
"operation_name" = IDEiPhoneRunOperationWorkerGroup;
"param_consoleMode" = 0;
"param_debugger_attachToExtensions" = 0;
"param_debugger_attachToXPC" = 0;
"param_debugger_type" = 5;
"param_destination_isProxy" = 0;
"param_destination_platform" = "com.apple.platform.iphoneos";
"param_diag_MainThreadChecker_stopOnIssue" = 0;
"param_diag_MallocStackLogging_enableDuringAttach" = 0;
"param_diag_MallocStackLogging_enableForXPC" = 1;
"param_diag_allowLocationSimulation" = 1;
"param_diag_gpu_frameCapture_enable" = 0;
"param_diag_gpu_shaderValidation_enable" = 0;
"param_diag_gpu_validation_enable" = 1;
"param_diag_memoryGraphOnResourceException" = 0;
"param_diag_queueDebugging_enable" = 0;
"param_diag_runtimeProfile_generate" = 0;
"param_diag_sanitizer_asan_enable" = 0;
"param_diag_sanitizer_tsan_enable" = 0;
"param_diag_sanitizer_tsan_stopOnIssue" = 0;
"param_diag_sanitizer_ubsan_stopOnIssue" = 0;
"param_diag_showNonLocalizedStrings" = 0;
"param_diag_viewDebugging_enabled" = 1;
"param_diag_viewDebugging_insertDylibOnLaunch" = 1;
"param_install_style" = 0;
"param_launcher_UID" = 2;
"param_launcher_allowDeviceSensorReplayData" = 0;
"param_launcher_kind" = 0;
"param_launcher_style" = 0;
"param_launcher_substyle" = 0;
"param_runnable_appExtensionHostRunMode" = 0;
"param_runnable_productType" = "com.apple.product-type.application";
"param_runnable_swiftVersion" = "5.5";
"param_runnable_type" = 2;
"param_testing_launchedForTesting" = 0;
"param_testing_suppressSimulatorApp" = 0;
"param_testing_usingCLI" = 0;
"sdk_canonicalName" = "iphoneos15.0";
"sdk_osVersion" = "15.0";
"sdk_variant" = iphoneos;
}
--
System Information
macOS Version 11.4 (Build 20F71)
Xcode 13.0 (19234) (Build 13A233)
Timestamp: 2021-09-27T11:54:55-07:00

Trouble properly setting up descriptor sets for multiple models in Vulkan

I'm having a problem trying to implement multiple models in Vulkan. I used the official Vulkan tutorial to set up most of the boilerplate code, then the rest is custom. At the moment, I am able to get one model to render perfectly, while the other identical model renders in about 60% of frames and doesn't render at all in others, as shown in the gif: Engine output
I've tried changing many things to fix it, but I can't pinpoint what is causing the issue. Any help would be appreciated wholly. I'm attaching the code snippets I think most relevant but I can include more if it helps solve the issue.
CreateCommandBuffers():
...
vkCmdBindVertexBuffers(commandBuffers[i], 0, 1, vertexBuffers, offsets);
vkCmdBindIndexBuffer(commandBuffers[i], indexBuffer, 0, VK_INDEX_TYPE_UINT32);
vkCmdBindDescriptorSets(commandBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSets[i], 0, nullptr); //COMEBACKTO
vkCmdDrawIndexed(commandBuffers[i], models[0].getModelIndicesSize(), 1, 0, 0, 0);
vkCmdBindDescriptorSets(commandBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayout, 0, 1, &descriptorSets[i + 1], 0, nullptr);
vkCmdDrawIndexed(commandBuffers[i], models[0].getModelIndicesSize(), 1, 0, 0, 0);
...
createDescriptorSets():
std::vector<VkDescriptorSetLayout> layouts(swapChainImages.size() * models.size(), descriptorSetLayout);
VkDescriptorSetAllocateInfo allocInfo{};
allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
allocInfo.descriptorPool = descriptorPool;
allocInfo.descriptorSetCount = static_cast<uint32_t>(swapChainImages.size() * models.size());
allocInfo.pSetLayouts = layouts.data();
descriptorSets.resize(swapChainImages.size() * models.size());
if (vkAllocateDescriptorSets(device, &allocInfo, descriptorSets.data()) != VK_SUCCESS) {
throw std::runtime_error("failed to allocate descriptor sets!");
}
for (int i = 0; i < swapChainImages.size(); i++) {
std::vector<VkWriteDescriptorSet> descWrites;
descWrites.resize(models.size() * 2);
for (int j = 0; j < models.size(); j++) {
VkDescriptorBufferInfo bufferInfo{};
bufferInfo.offset = 0;
bufferInfo.range = sizeof(UniformBufferObject);
//bufferInfo.buffer = uniformBuffers[i];
bufferInfo.buffer = uniformBuffers[j + (i * (models.size() - 1))];
VkDescriptorImageInfo imageInfo{};
imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
imageInfo.imageView = textureImageView; //set these up
imageInfo.sampler = textureSampler; //set these up
int tmp = j * 2;
int tmp1 = tmp + 1;
descWrites[tmp].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
descWrites[tmp].dstSet = descriptorSets[j + (i * (models.size() - 1))];
descWrites[tmp].dstBinding = 0;
descWrites[tmp].dstArrayElement = 0;
descWrites[tmp].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
descWrites[tmp].descriptorCount = 1;
descWrites[tmp].pBufferInfo = &bufferInfo;
descWrites[tmp1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
descWrites[tmp1].dstSet = descriptorSets[j + (i * (models.size() - 1))];
descWrites[tmp1].dstBinding = 1;
descWrites[tmp1].dstArrayElement = 0;
descWrites[tmp1].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
descWrites[tmp1].descriptorCount = 1;
descWrites[tmp1].pImageInfo = &imageInfo;
}
vkUpdateDescriptorSets(device, static_cast<uint32_t>(descWrites.size()), descWrites.data(), 0, nullptr);
}

Confusion about Texture2D and ShaderResourceViews

I am new to Direct3D11 and I am currently trying to create a texture programatically within my code using this code I found online:
// Some Constants
int w = 256;
int h = 256;
int bpp = 4;
int *buf = new int[w*h];
//declarations
ID3D11Texture2D* tex;
D3D11_TEXTURE2D_DESC sTexDesc;
D3D11_SUBRESOURCE_DATA tbsd;
// filling the image
for (int i = 0; i<h; i++)
for (int j = 0; j<w; j++)
{
if ((i & 32) == (j & 32))
buf[i*w + j] = 0x00000000;
else
buf[i*w + j] = 0xffffffff;
}
// setting up D3D11_SUBRESOURCE_DATA
tbsd.pSysMem = (void *)buf;
tbsd.SysMemPitch = w*bpp;
tbsd.SysMemSlicePitch = w*h*bpp; // Not needed since this is a 2d texture
// initializing sTexDesc
sTexDesc.Width = w;
sTexDesc.Height = h;
sTexDesc.MipLevels = 1;
sTexDesc.ArraySize = 1;
sTexDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sTexDesc.SampleDesc.Count = 1;
sTexDesc.SampleDesc.Quality = 0;
sTexDesc.Usage = D3D11_USAGE_DEFAULT;
sTexDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
sTexDesc.CPUAccessFlags = 0;
sTexDesc.MiscFlags = 0;
hr = m_pd3dDevice->CreateTexture2D(&sTexDesc, &tbsd, &tex);
and that' all fine and dandy, but I am a bit confused about how to actually load this into the shader. Below I initialized this ID3D11ShaderResourceView:
ID3D11ShaderResourceView* m_pTextureRV = nullptr;
I found on the Microsoft tutorials I need to use the CreateShaderResourceView. But how exactly do I use it? I tried this:
hr = m_pd3dDevice->CreateShaderResourceView(tex, NULL , m_pTextureRV);
but it gives me an error, telling me that m_pTextureRV is not a valid argument for the function. What am I doing wrong here?
The correct way to call that function is:
hr = m_pd3dDevice->CreateShaderResourceView(tex, nullptr, &m_pTextureRV);
Remember that ID3D11ShaderResourceView* is a pointer to an interface. You need a pointer-to-a-pointer to get a new instance of one back.
You should really consider using a COM smart-pointer like Microsoft::WRL::ComPtr instead of raw pointers for these interfaces.
Once you have created the shader resource view for your texture object, then you need to associate it with whatever slot the HLSL expects to find it in. So, for example, if you were to write an HLSL source file as:
Texture2D texture : register( t0 );
SamplerState sampler: register( s0 );
float4 PS(float2 tex : TEXCOORD0) : SV_Target
{
return texture.Sample( sampler, tex );
}
Then compile it as a Pixel Shader, and bind it to the render pipeline via PSSetShader. Then you'd need to call:
ID3D11ShaderResourceView* srv[1] = { m_pTextureRV };
m_pImmediateContext->PSSetShaderResources( 0, 1, srv );
Of course you also need a ID3D11SamplerState* sampler bound as well:
ID3D11SamplerState* m_pSamplerLinear = nullptr;
D3D11_SAMPLER_DESC sampDesc = {};
sampDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
sampDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
sampDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
sampDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
sampDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
sampDesc.MinLOD = 0;
sampDesc.MaxLOD = D3D11_FLOAT32_MAX;
hr = m_pd3dDevice->CreateSamplerState( &sampDesc, &m_pSamplerLinear );
Then when you are about to draw:
m_pImmediateContext->PSSetSamplers( 0, 1, &m_pSamplerLinear );
I strongly recommend you check out the DirectX Tool Kit and the tutorials there.

Counting Shapes/Objects Created Continuously within Processing

My code takes an image and creates a pointillist image through creating ellipses with a pixel's color.
After a while, the image is fully 'painted' and I want to automatically switch to another image in my sketch folder.
I would like to be able to count the number of ellipses generated. Once 'z' ellipses are generated I want to tell my code to erase all ellipses and start over with a new image.
CODE:
PImage img;
int smallPoint, largePoint;
void setup() {
size(1920, 1080);
img = loadImage("rio.jpg");
smallPoint = 12;
largePoint = 12;
imageMode(CENTER);
noStroke();
background(255);
}
void draw() {
for (int i = 0; i < 1000; i++)
{
drawADot();
}
}
void drawADot()
{
int imageWidth = img.width;
int imageHeight = img.height;
int ptSize = int(random(100)) + 4;
float pointillize = map(mouseX, 0, width, smallPoint, largePoint); //not used right now but for controlling ellipse size
int x = int(random(0, imageWidth/8));
int y = int(random(0, imageHeight/8));
color pix = img.get(x*8, y*8);
fill(pix, 255);
ellipse(x*8, y*8, pointillize, pointillize);
}
Store the images in an array, count the dots added, and conditionally (based in number of dots) change the image being used to next one in the array, you can pass the image to the drawADot() function as a parameter. Something like:
PImage img[] = new PImage[2];
int smallPoint, largePoint;
final int DOTSPERDRAW = 500;
int numberOfDots = 0;
final int MAXDOTS = DOTSPERDRAW * 100;
PImage workingImage ;
int index;
void setup() {
size(810, 455);
img[0] = loadImage("http://assets2.exame.abril.com.br/assets/images/2014/8/506584/size_810_16_9_rio.jpg");
img[1] = loadImage("http://upload.wikimedia.org/wikipedia/commons/1/1e/Pilcomayo_rio.jpg");
img[1].resize(810, 0);
smallPoint = 12;
largePoint = 12;
imageMode(CENTER);
noStroke();
background(255);
workingImage = img[0];
}
void draw() {
if (numberOfDots > MAXDOTS) {
index = (index + 1) % img.length;
workingImage = img[index];
numberOfDots = 0;
}
for (int i = 0; i < DOTSPERDRAW; i++)
{
drawADot(workingImage);
}
numberOfDots += DOTSPERDRAW;
}
void drawADot(PImage theImage)
{
int imageWidth = theImage.width;
int imageHeight = theImage.height;
int ptSize = int(random(100)) + 4;
float pointillize = map(mouseX, 0, width, smallPoint, largePoint); //not used right now but for controlling ellipse size
int x = int(random(0, imageWidth/8));
int y = int(random(0, imageHeight/8));
color pix = theImage.get(x*8, y*8);
fill(pix, 255);
ellipse(x*8, y*8, pointillize, pointillize);
}

Extracting a portion of Image in C#

I have made a C# Windows application with two Picture-Boxes one as MainPictureBox and other as ThumbnailBox, I want to Extract a portion of Image upon moving mouse over Main Image and load it into ThumbnailPictureBox.
Here is a way to get a thumbnail from the image.
public static Bitmap Thumb(this Image inputStream, int width, int height)
{
using (var bitMap = new Bitmap(inputStream))
{
int originalWidth = bitMap.Width;
int originalHeight = bitMap.Height;
int startPositionHeight = 0;
int startPosionWidth = 0;
int widthHeight = 0;
if (originalWidth > originalHeight)
{
startPosionWidth = (originalWidth - originalHeight) / 2;
widthHeight = originalHeight;
}
else if (originalHeight > originalWidth)
{
startPositionHeight = (originalHeight - originalWidth) / 2;
widthHeight = originalWidth;
}
else if (originalWidth == originalHeight)
{
widthHeight = originalHeight;
}
var rect = new Rectangle(startPosionWidth, startPositionHeight, widthHeight, widthHeight);
using (Bitmap cropped = bitMap.Clone(rect, bitMap.PixelFormat))
{
using (var newbitmap = new Bitmap(cropped, width, height))
{
var stream = new MemoryStream();
newbitmap.Save(stream, ImageFormat.Tiff);
stream.Position = 0;
return new Bitmap(stream);
}
}
}
}

Resources