Advertisement Jump to content
  • Advertisement

Balma Alparisi

Member
  • Content Count

    3
  • Joined

  • Last visited

Community Reputation

-2 Poor

About Balma Alparisi

  • Rank
    Newbie

Personal Information

  • Interests
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Balma Alparisi

    Read Access Violation in vkCreateGraphicsPipelines

    I only has one subpass with no depth/stencil. So i dont need pDepthStencilState according the vulkan documentation. i have enabled the validation layer and fix VkShaderModule::sType but still no luck, The validation reports nothing. And lastly this is mu rendepass creation VkAttachmentDescription attachmentDescriptions[2] = {}; attachmentDescriptions[0].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; attachmentDescriptions[0].finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; attachmentDescriptions[0].format = VK_FORMAT_B8G8R8A8_UNORM; attachmentDescriptions[0].samples = VK_SAMPLE_COUNT_8_BIT; attachmentDescriptions[0].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; attachmentDescriptions[0].storeOp = VK_ATTACHMENT_STORE_OP_STORE; attachmentDescriptions[0].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; attachmentDescriptions[0].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; attachmentDescriptions[1].initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; attachmentDescriptions[1].finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; attachmentDescriptions[1].format = VK_FORMAT_B8G8R8A8_UNORM; attachmentDescriptions[1].samples = VK_SAMPLE_COUNT_1_BIT; attachmentDescriptions[1].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; attachmentDescriptions[1].storeOp = VK_ATTACHMENT_STORE_OP_STORE; attachmentDescriptions[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; attachmentDescriptions[1].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; VkAttachmentReference colorAttachmentReference = { 0,VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; VkAttachmentReference resolveAttachmentReference = { 1,VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; VkSubpassDescription subpassDesc = {}; subpassDesc.colorAttachmentCount = 1; subpassDesc.pColorAttachments = &colorAttachmentReference; subpassDesc.pResolveAttachments = &resolveAttachmentReference; VkRenderPassCreateInfo renderPassCreateInfo = {}; renderPassCreateInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; renderPassCreateInfo.attachmentCount = 2; renderPassCreateInfo.pAttachments = attachmentDescriptions; renderPassCreateInfo.subpassCount = 1; renderPassCreateInfo.pSubpasses = &subpassDesc; VkRenderPass renderPass; vkCreateRenderPass(device.GetVkDevice(), &renderPassCreateInfo, nullptr, &renderPass);
  2. It has been 2 day figuring out what's wrong but stil no success. Here's the code. VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo = {}; pipelineLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; VkPipelineLayout pipelineLayout; vkRes = vkCreatePipelineLayout(device.GetVkDevice(), &pipelineLayoutCreateInfo, nullptr, &pipelineLayout); if (vkRes != VK_SUCCESS) { std::cout << "Failed to create pipelineLayout \n"; return -1; } VkPipelineColorBlendAttachmentState colorBlendAttachmentState = {}; colorBlendAttachmentState.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; VkPipelineColorBlendStateCreateInfo colorBlendStates = {}; colorBlendStates.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO; colorBlendStates.attachmentCount = 1; colorBlendStates.pAttachments = &colorBlendAttachmentState; VkVertexInputBindingDescription vertexInputBindingDesc = {}; vertexInputBindingDesc.binding = 0; vertexInputBindingDesc.inputRate = VK_VERTEX_INPUT_RATE_VERTEX; vertexInputBindingDesc.stride = sizeof(float) * 6; VkVertexInputAttributeDescription vertexInputAttribDescs[2] = {}; vertexInputAttribDescs[0].binding = 0; vertexInputAttribDescs[0].format = VK_FORMAT_R32G32B32_SFLOAT; vertexInputAttribDescs[0].location = 0; vertexInputAttribDescs[0].offset = 0; vertexInputAttribDescs[1].binding = 0; vertexInputAttribDescs[1].format = VK_FORMAT_R32G32B32_SFLOAT; vertexInputAttribDescs[1].location = 1; vertexInputAttribDescs[1].offset = sizeof(float) * 3; VkPipelineVertexInputStateCreateInfo vertexInputState = {}; vertexInputState.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO; vertexInputState.vertexBindingDescriptionCount = 1; vertexInputState.pVertexBindingDescriptions = &vertexInputBindingDesc; vertexInputState.vertexAttributeDescriptionCount = 2; vertexInputState.pVertexAttributeDescriptions = vertexInputAttribDescs; VkPipelineViewportStateCreateInfo viewportState = {}; viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; viewportState.viewportCount = 1; viewportState.scissorCount = 1; VkPipelineInputAssemblyStateCreateInfo inputAssemblyState = {}; inputAssemblyState.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; inputAssemblyState.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; VkPipelineRasterizationStateCreateInfo rasterizerState = {}; rasterizerState.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO; rasterizerState.cullMode = VK_CULL_MODE_NONE; rasterizerState.polygonMode = VK_POLYGON_MODE_FILL; rasterizerState.lineWidth = 1.0f; rasterizerState.frontFace = VK_FRONT_FACE_CLOCKWISE; VkPipelineMultisampleStateCreateInfo multisampleState = {}; multisampleState.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; multisampleState.rasterizationSamples = VK_SAMPLE_COUNT_8_BIT; VkDynamicState dynamicState[2] = { VK_DYNAMIC_STATE_VIEWPORT,VK_DYNAMIC_STATE_SCISSOR }; VkPipelineDynamicStateCreateInfo dynamicPipelineState = {}; dynamicPipelineState.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; dynamicPipelineState.dynamicStateCount = 2; dynamicPipelineState.pDynamicStates = dynamicState; VkShaderModule shaders[2]; std::ifstream inputFile("Shaders/color.vert.spv"); inputFile.seekg(0, std::ios_base::end); UINT64 fileSize = inputFile.tellg(); inputFile.seekg(0, std::ios_base::beg); std::vector<char> byteCode(fileSize); inputFile.read(byteCode.data(), fileSize); inputFile.close(); VkShaderModuleCreateInfo shaderModuleCreateInfo = {}; shaderModuleCreateInfo.codeSize = fileSize; shaderModuleCreateInfo.pCode = (UINT*)byteCode.data(); vkRes = vkCreateShaderModule(device.GetVkDevice(), &shaderModuleCreateInfo, nullptr, &shaders[0]); if (vkRes != VK_SUCCESS) { std::cout << "Failed to create shader\n"; return -1; } inputFile.open("Shaders/color.frag.spv"); inputFile.seekg(0, std::ios_base::end); fileSize = inputFile.tellg(); inputFile.seekg(0, std::ios_base::beg); byteCode.resize(fileSize); inputFile.read(byteCode.data(), fileSize); inputFile.close(); shaderModuleCreateInfo.codeSize = fileSize; shaderModuleCreateInfo.pCode = (UINT*)byteCode.data(); vkRes = vkCreateShaderModule(device.GetVkDevice(), &shaderModuleCreateInfo, nullptr, &shaders[1]); if (vkRes != VK_SUCCESS) { std::cout << "Failed to create shader\n"; return -1; } VkPipelineShaderStageCreateInfo shaderStages[2]; shaderStages[0] = {}; shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; shaderStages[0].module = shaders[0]; shaderStages[0].pName = "main"; shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; shaderStages[1] = {}; shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; shaderStages[1].module = shaders[1]; shaderStages[1].pName = "main"; shaderStages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT; VkGraphicsPipelineCreateInfo graphicsPipelineCreateInfo[1] = {}; graphicsPipelineCreateInfo[0].sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; graphicsPipelineCreateInfo[0].layout = pipelineLayout; graphicsPipelineCreateInfo[0].pColorBlendState = &colorBlendStates; graphicsPipelineCreateInfo[0].stageCount = 2; graphicsPipelineCreateInfo[0].pStages = shaderStages; graphicsPipelineCreateInfo[0].pDynamicState = &dynamicPipelineState; graphicsPipelineCreateInfo[0].pInputAssemblyState = &inputAssemblyState; graphicsPipelineCreateInfo[0].pRasterizationState = &rasterizerState; graphicsPipelineCreateInfo[0].pVertexInputState = &vertexInputState; graphicsPipelineCreateInfo[0].pMultisampleState = &multisampleState; graphicsPipelineCreateInfo[0].renderPass = renderPass; graphicsPipelineCreateInfo[0].pViewportState = &viewportState; VkPipeline pipeline; vkRes = vkCreateGraphicsPipelines(device.GetVkDevice(), VK_NULL_HANDLE, 1, graphicsPipelineCreateInfo, nullptr, &pipeline); if (vkRes != VK_SUCCESS) { std::cout << "Failed to create pipeline\n"; return -1; }
  3. Balma Alparisi

    OpenGL glError 1282

    i got error 1282 in my code. sf::ContextSettings settings; settings.majorVersion = 4; settings.minorVersion = 5; settings.attributeFlags = settings.Core; sf::Window window; window.create(sf::VideoMode(1600, 900), "Texture Unit Rectangle", sf::Style::Close, settings); window.setActive(true); window.setVerticalSyncEnabled(true); glewInit(); GLuint shaderProgram = createShaderProgram("FX/Rectangle.vss", "FX/Rectangle.fss"); float vertex[] = { -0.5f,0.5f,0.0f, 0.0f,0.0f, -0.5f,-0.5f,0.0f, 0.0f,1.0f, 0.5f,0.5f,0.0f, 1.0f,0.0f, 0.5,-0.5f,0.0f, 1.0f,1.0f, }; GLuint indices[] = { 0,1,2, 1,2,3, }; GLuint vao; glGenVertexArrays(1, &vao); glBindVertexArray(vao); GLuint vbo; glGenBuffers(1, &vbo); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(vertex), vertex, GL_STATIC_DRAW); GLuint ebo; glGenBuffers(1, &ebo); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ebo); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices,GL_STATIC_DRAW); glVertexAttribPointer(0, 3, GL_FLOAT, false, sizeof(float) * 5, (void*)0); glEnableVertexAttribArray(0); glVertexAttribPointer(1, 2, GL_FLOAT, false, sizeof(float) * 5, (void*)(sizeof(float) * 3)); glEnableVertexAttribArray(1); GLuint texture[2]; glGenTextures(2, texture); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture[0]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); sf::Image* imageOne = new sf::Image; bool isImageOneLoaded = imageOne->loadFromFile("Texture/container.jpg"); if (isImageOneLoaded) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imageOne->getSize().x, imageOne->getSize().y, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageOne->getPixelsPtr()); glGenerateMipmap(GL_TEXTURE_2D); } delete imageOne; glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, texture[1]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); sf::Image* imageTwo = new sf::Image; bool isImageTwoLoaded = imageTwo->loadFromFile("Texture/awesomeface.png"); if (isImageTwoLoaded) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imageTwo->getSize().x, imageTwo->getSize().y, 0, GL_RGBA, GL_UNSIGNED_BYTE, imageTwo->getPixelsPtr()); glGenerateMipmap(GL_TEXTURE_2D); } delete imageTwo; glUniform1i(glGetUniformLocation(shaderProgram, "inTextureOne"), 0); glUniform1i(glGetUniformLocation(shaderProgram, "inTextureTwo"), 1); GLenum error = glGetError(); std::cout << error << std::endl; sf::Event event; bool isRunning = true; while (isRunning) { while (window.pollEvent(event)) { if (event.type == event.Closed) { isRunning = false; } } glClear(GL_COLOR_BUFFER_BIT); if (isImageOneLoaded && isImageTwoLoaded) { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture[0]); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, texture[1]); glUseProgram(shaderProgram); } glBindVertexArray(vao); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr); glBindVertexArray(0); window.display(); } glDeleteVertexArrays(1, &vao); glDeleteBuffers(1, &vbo); glDeleteBuffers(1, &ebo); glDeleteProgram(shaderProgram); glDeleteTextures(2,texture); return 0; } and this is the vertex shader #version 450 core layout(location=0) in vec3 inPos; layout(location=1) in vec2 inTexCoord; out vec2 TexCoord; void main() { gl_Position=vec4(inPos,1.0); TexCoord=inTexCoord; } and the fragment shader #version 450 core in vec2 TexCoord; uniform sampler2D inTextureOne; uniform sampler2D inTextureTwo; out vec4 FragmentColor; void main() { FragmentColor=mix(texture(inTextureOne,TexCoord),texture(inTextureTwo,TexCoord),0.2); } I was expecting awesomeface.png on top of container.jpg
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!