I'm trying to define a simple SamplerState in an HLSL file to use for textures.
When compiling the shader, I get an error:
error X3004: undeclared identifier 'Filter'
Source:
// part of render.hlsl
SamplerState linear_sample=
{
Filter=MIN_MAG_MIP_LINEAR;
AddressU = Wrap;
AddressV = Wrap;
};
Compilation:
hr=D3DX10CreateEffectFromFile("render.hlsl",NULL,NULL,"fx_4_0",D3D10_SHADER_ENABLE_STRICTNESS | D3D10_SHADER_DEBUG,0,dx_device,NULL,NULL,&dx_effect,&dx_err,NULL);'
I've checked on MSDN, and nothing appears to be wrong with my HLSL file. Am I compiling incorrectly?
Remove the = sign after linear_sample.
Related
I am trying to write a compute shader that raytraces an image, pixels on the right of the yz plane sample from image A, those on the left from image B.
I don't want to have to sample both images so I am trying to use non uniform access by doing:
texture(textures[nonuniformEXT(sampler_id)], vec2(0.5));
and enabling the relevant extension in the shader. This triggers the following validaiton layer error:
Message: Validation Error: [ VUID-VkShaderModuleCreateInfo-pCode-01091 ] Object 0: handle = 0x55a1c21315d0, name = Logical device: AMD RADV RAVEN2, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xa7bb8db6 | vkCreateShaderModule(): The SPIR-V Capability (SampledImageArrayNonUniformIndexing) was declared, but none of the requirements were met to use it. The Vulkan spec states: If pCode declares any of the capabilities listed in the SPIR-V Environment appendix, one of the corresponding requirements must be satisfied (https://vulkan.lunarg.com/doc/view/1.2.182.0/linux/1.2-extensions/vkspec.html#VUID-VkShaderModuleCreateInfo-pCode-01091)
If I read the docs it would seem this is a hardware feature, but someone said I can still have non uniform access if create the correct extension object. But I am not entirely sure how to do that.
You have to enable the feature at device creation.
You can check for support of the feature by calling vkGetPhysicalDeviceFeatures2 and following the pNext chain through to a VkPhysicalDeviceVulkan12Features, and checking that shaderSampledImageArrayNonUniformIndexing member is to VK_TRUE.
After that when creating the device with vkCreateDevice, inside the pCreateInfo structure, in the pNext chain you have to have a VkPhysicalDeviceVulkan12Features with shaderSampledImageArrayNonUniformIndexing set to VK_TRUE.
bool checkForNonUniformIndexing(VkPhysicalDevice physicalDevice)
{
VkPhysicalDeviceFeatures2 features;
vkGetPhysicalDeviceFeatures2(physicalDevice, &features);
if(features.sType != VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2)
{
return false;
}
const VkPhysicalDeviceFeatures2* next = &features;
do
{
// We know the type of the struct based on the `sType` member, but the first
// two fields are the same in all of these structs. There may be a more appropriate
// generic structure to use, but as long as we don't access any further members
// we should be mostly fine.
next = reinterpret_cast<const VkPhysicalDeviceFeatures*>(next->pNext);
if(next.sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES)
{
const VkPhysicalDeviceVulkan12Features* pVk12Features = reinterpret_cast<const VkPhysicalDeviceVulkan12Features*>(next);
return next.shaderSampledImageArrayNonUniformIndexing == VK_TRUE;
}
} while(next);
return false;
}
VkDevice* createDevice(VkPhysicalDevice physicalDevice, const VkAllocationCallbacks* pAllocator)
{
VkPhysicalDeviceVulkan12Features features;
features.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
features.shaderSampledImageArrayNonUniformIndexing = VK_TRUE;
VkDeviceCreateInfo createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
createInfo.pNext = &features;
// Setting other create data
VkDevice device;
vkCreateDevice(physicalDevice, &createInfo, pAllocator, &device);
// Error checking
return device;
}
I'm trying to create a shadow map in my DirectX application, but currently having trouble when creating the Depth Stencil view. CreateDepthStencilView() is leaving my ID3D11DepthStencilView* variable as NULL.
The only error I've managed to get from the HRESULT is "The parameter is incorrect". It seems the problem is with both the D3D11_TEXTURE2D_DESC and the ID3D11_DEPTH_STENCIL_VIEW_DESC as when I've replaced them with the depth texture and nullptr respectively, it works. I then replaced the working function parameters with the shadow map values one at a time and it did not work with either.
I have also tried setting shadowDsv.Flags = 0 , as suggested in this post, but had the same result.
I'm following this tutorial, the code is the same as his (except mine is DX11 not DX10), I'm unsure what the problem could be. This is my code:
Application.h
ID3D11Texture2D* _shadowMapTexture;
ID3D11DepthStencilView* _shadowMapStencil;
ID3D11ShaderResourceView* _shadowMapRV;
Application.cpp
//Set up shadow map
D3D11_TEXTURE2D_DESC shadowTexDesc;
shadowTexDesc.Width = _WindowWidth;
shadowTexDesc.Height = _WindowHeight;
shadowTexDesc.MipLevels = 1;
shadowTexDesc.ArraySize = 1;
shadowTexDesc.Format = DXGI_FORMAT_R32_TYPELESS;
shadowTexDesc.SampleDesc.Count = 1;
shadowTexDesc.SampleDesc.Quality = 0;
shadowTexDesc.Usage = D3D11_USAGE_DEFAULT;
shadowTexDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
shadowTexDesc.CPUAccessFlags = 0;
shadowTexDesc.MiscFlags = 0;
D3D11_DEPTH_STENCIL_VIEW_DESC shadowDsv;
shadowDsv.Format = shadowTexDesc.Format;
shadowDsv.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
shadowDsv.Texture2D.MipSlice = 0;
D3D11_SHADER_RESOURCE_VIEW_DESC shadowSrv;
shadowSrv.Format = DXGI_FORMAT_R32_FLOAT;
shadowSrv.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
shadowSrv.Texture2D.MipLevels = shadowTexDesc.MipLevels;
shadowSrv.Texture2D.MostDetailedMip = 0;
hr = _pd3dDevice->CreateTexture2D(&shadowTexDesc, nullptr, &_shadowMapTexture);
hr = _pd3dDevice->CreateDepthStencilView(_shadowMapTexture, &shadowDsv, &_shadowMapStencil);
hr = _pd3dDevice->CreateShaderResourceView(_shadowMapTexture, &shadowSrv, &_shadowMapRV);
EDIT:
This is the console output when CreateDepthStencilView() is called. Thank you for the help so far.
D3D11 ERROR: ID3D11Device::CreateDepthStencilView: The Format (0x27, R32_TYPELESS) is invalid, when creating a View; it is not a fully qualified Format castable from the Format of the Resource (0x27, R32_TYPELESS). [ STATE_CREATION ERROR #144: CREATEDEPTHSTENCILVIEW_INVALIDFORMAT]
D3D11 ERROR: ID3D11Device::CreateDepthStencilView: The format (0x27, R32_TYPELESS) cannot be used with a DepthStencil view. [ STATE_CREATION ERROR #144: CREATEDEPTHSTENCILVIEW_INVALIDFORMAT]
D3D11 ERROR: ID3D11Device::CreateDepthStencilView: There were unrecognized flags specified in the DepthStencilView Flags field. The flags value was 0xcccccccc, while the valid flags are limited to 0x3. [ STATE_CREATION ERROR #2097153: CREATEDEPTHSTENCILVIEW_INVALIDFLAGS]
Exception thrown at 0x76D235D2 in DX11 Framework.exe: Microsoft C++ exception: _com_error at memory location 0x00B3EE98.
D3D11 ERROR: ID3D11Device::CreateDepthStencilView: Returning E_INVALIDARG, meaning invalid parameters were passed. [ STATE_CREATION ERROR #148: CREATEDEPTHSTENCILVIEW_INVALIDARG_RETURN]
It seems the R32_TYPELESS format is what's causing the error. After looking at the documentation I see there are only a few allowable formats. Does anyone recommend a specific format for a shadow map? I've not done this before so unsure if any of the following would be a good subsitute:
DXGI_FORMAT_D16_UNORM
DXGI_FORMAT_D24_UNORM_S8_UINT
DXGI_FORMAT_D32_FLOAT
DXGI_FORMAT_D32_FLOAT_S8X24_UINT
DXGI_FORMAT_UNKNOWN
Thanks again :)
To anyone else having this problem: my fix was to set the D3D11_DEPTH_STENCIL_VIEW_DESC format to DXGI_FORMAT_D32_FLOAT, and the D3D11_DEPTH_STENCIL_VIEW_DESC Flags equal to 0.
I'm following a tutorial to make a game with UE4 and C++ and a error appear when I type the following line
FActorSpawnParameters params;
It says that the identifier FActorSpawnParameters is not defined.
I've tried to modify some of my code but it didn't change...
So I replace all the things in order.
void AUltimatePawn::Shoot()
{
if (BulletClass)
{
FActorSpawnParameters params;
params.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
params.bNoFail = true;
params.Owner = this;
params.Instigator = this;
FTransform BulletSpawnTransform;
BulletSpawnTransform.SetLocation(GetActorForwardVector() * 500.f + GetActorLocation());
BulletSpawnTransform.SetRotation(GetActorRotation().Quaternion());
BulletSpawnTransform.SetScale3D(FVector(1.f));
GetWorld()->SpawnActor<ABullet>(BulletClass, BulletSpawnTransform, params);
}
}
I just want you to tell me how to fix this error,
Thank's
Make sure that you include Runtime/Engine/Classes/Engine/World.h.
I extracted this information from the official API reference.
I get a compilation error on the line:
GLPADATA &sDamage = sItemCustom.getdamage();
nExtraValue = sItemCustom.GETGRADE_DAMAGE();
uGRADE = sItemCustom.GETGRADE(EMGRINDING_DAMAGE);
AddInfoItemAddonRange ( sDamage.dwLow, sDamage.dwHigh, nExtraValue, uGRADE,ID2GAMEWORD("ITEM_ADVANCED_INFO", 0) );
AddTextNoSplit (uGRADE, NS_UITEXTCOLOR::GOLD);
I don't know how to resolve this error, and what I'm trying to do is to have the uGRADE a different color from the default color of ID2GAMEWORD. I'm currently still learning
I get the following error when I try to execute the code below.
Uncaught TypeError: Object true has no method 'dartObjectLocalStorage$getter'
I started a Web Application in Dart Editor Version 0.1.0.201201150611 Build 3331. Here is the complete code for the lone dart file. The if statement that results in the error is commented below.
#import('dart:html');
class Test3D {
CanvasElement theCanvas;
WebGLRenderingContext gl;
static String vertexShaderSrc = """
attribute vec3 aVertexPosition;
void main(void) {
gl_Position = vec4(aVertexPosition, 1.0);
}
""";
Test3D() {
}
void run() {
write("Hello World!");
// Set up canvas
theCanvas = new Element.html("<canvas></canvas>");
theCanvas.width = 100;
theCanvas.height = 100;
document.body.nodes.add(theCanvas);
// Set up context
gl = theCanvas.getContext("experimental-webgl");
gl.clearColor(0.5, 0.5, 0.5, 1.0);
gl.clear(WebGLRenderingContext.COLOR_BUFFER_BIT);
WebGLShader vertexShader = gl.createShader(WebGLRenderingContext.VERTEX_SHADER);
gl.shaderSource(vertexShader, vertexShaderSrc);
gl.compileShader(vertexShader);
// Adding this line results in the error: Uncaught TypeError: Object true has no method 'dartObjectLocalStorage$getter
var wasSuccessful = gl.getShaderParameter(vertexShader, WebGLRenderingContext.COMPILE_STATUS);
}
void write(String message) {
// the HTML library defines a global "document" variable
document.query('#status').innerHTML = message;
}
}
void main() {
new Test3D().run();
}
I'm really keen on dart and would appreciate any help you could give me on this.
Here is the console output for the error:
Uncaught TypeError: Object true has no method 'dartObjectLocalStorage$getter'
htmlimpl0a8e4b$LevelDom$Dart.wrapObject$member
htmlimpl0a8e4b$WebGLRenderingContextWrappingImplementation$Dart.getShaderParameter$member
htmlimpl0a8e4b$WebGLRenderingContextWrappingImplementation$Dart.getShaderParameter$named
unnamedb54266$Test3D$Dart.run$member
unnamedb54266$Test3D$Dart.run$named
unnamedb54266$main$member
RunEntry.isolate$current
isolate$Isolate.run
isolate$IsolateEvent.process
isolate$doOneEventLoopIteration
next
isolate$doRunEventLoop
isolate$runEventLoop
RunEntry
(anonymous function)
The error indicates that somewhere in your code the field 'dartObjectLocalStorage' is accessed on the boolean true. The given code-snippet does not contain this identifier and is thus probably not responsible for the error.
It could be that the error-reporting gives the wrong line number (potentially even the wrong file).
To debug this:
try to find a reference to 'dartObjectLocalStorage' in your code.
try to find a reference to 'dartObjectLocalStorage$getter' in the generated code.
run on the VM or compile with a different compiler (frogc vs dartc).
good luck.
According to the documentation for WebGLRenderingContext the return type is Object, if you know the object is bool you can just use it as a bool or dynamic
var v=gl.getShaderParameter(vertexShader, WebGLRenderingContext.COMPILE_STATUS)
or more explicitly
var v=gl.getShaderParameter(vertexShader, WebGLRenderingContext.COMPILE_STATUS).dynamic
and then use it in your conditional statement. Also try compiling it with frogc rather than the build in JavaScript compiler, it usually results in better errors.